Skip to content

Commit ed5e302

Browse files
committed
[+]: add hack to prevent fatal parse errors
-> hack, until this is merged: phpDocumentor/TypeResolver#139
1 parent 9dd8461 commit ed5e302

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

src/voku/SimplePhpParser/Model/PHPClass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ private function readPhpDocProperties(string $docComment): void
350350
return;
351351
}
352352

353+
// hack, until this is merged: https://github.com/phpDocumentor/TypeResolver/pull/139
354+
$docComment = preg_replace('#int<.*>#i', 'int', $docComment);
355+
353356
try {
354357
$phpDoc = Utils::createDocBlockInstance()->create($docComment);
355358

src/voku/SimplePhpParser/Model/PHPFunction.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ protected function readPhpDoc(string $docComment): void
233233
return;
234234
}
235235

236+
// hack, until this is merged: https://github.com/phpDocumentor/TypeResolver/pull/139
237+
$docComment = preg_replace('#int<.*>#i', 'int', $docComment);
238+
236239
try {
237240
$phpDoc = Utils::createDocBlockInstance()->create($docComment);
238241

src/voku/SimplePhpParser/Model/PHPParameter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ private function readPhpDoc(string $docComment, string $parameterName): void
232232
return;
233233
}
234234

235+
// hack, until this is merged: https://github.com/phpDocumentor/TypeResolver/pull/139
236+
$docComment = preg_replace('#int<.*>#i', 'int', $docComment);
237+
235238
try {
236239
$phpDoc = Utils::createDocBlockInstance()->create($docComment);
237240

src/voku/SimplePhpParser/Model/PHPProperty.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ private function readPhpDoc(string $docComment): void
230230
return;
231231
}
232232

233+
// hack, until this is merged: https://github.com/phpDocumentor/TypeResolver/pull/139
234+
$docComment = preg_replace('#int<.*>#i', 'int', $docComment);
235+
233236
try {
234237
$phpDoc = Utils::createDocBlockInstance()->create($docComment);
235238

@@ -263,7 +266,7 @@ private function readPhpDoc(string $docComment): void
263266
}
264267

265268
/** @noinspection AdditionOperationOnArraysInspection */
266-
$parsedParamTags = $phpDoc->getTagsByName('Psalm-var')
269+
$parsedParamTags = $phpDoc->getTagsByName('psalm-var')
267270
+ $phpDoc->getTagsByName('phpstan-var');
268271

269272
if (!empty($parsedParamTags)) {

src/voku/SimplePhpParser/Model/PHPTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ private function readPhpDocProperties(string $docComment): void
276276
return;
277277
}
278278

279+
// hack, until this is merged: https://github.com/phpDocumentor/TypeResolver/pull/139
280+
$docComment = preg_replace('#int<.*>#i', 'int', $docComment);
281+
279282
try {
280283
$phpDoc = Utils::createDocBlockInstance()->create($docComment);
281284

tests/DummyTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
trait DummyTrait
1111
{
1212
/**
13-
* @var null|float|int
13+
* @var null|float|int<0,10>
1414
*/
1515
public $lall_trait;
1616

0 commit comments

Comments
 (0)