Skip to content

Commit 0d15daf

Browse files
committed
bug #44013 [ErrorHandler] fix parsing @param with dollars in the description (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [ErrorHandler] fix parsing ``@param`` with dollars in the description | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #43936 | License | MIT | Doc PR | - Commits ------- 8046b3b [ErrorHandler] fix parsing ``@param`` with dollars in the description
2 parents 42b994c + 8046b3b commit 0d15daf

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,11 +1180,8 @@ private function parsePhpDoc(\Reflector $reflector): array
11801180
if (false === $i = strpos($param, '$')) {
11811181
continue;
11821182
}
1183-
if (false !== $j = strpos($param, ' $') ?: strpos($param, '&$')) {
1184-
$i = 1 + $j;
1185-
}
11861183

1187-
$type = 0 === $i ? '' : rtrim(substr($param, 0, $i - 1));
1184+
$type = 0 === $i ? '' : rtrim(substr($param, 0, $i), ' &');
11881185
$param = substr($param, 1 + $i, (strpos($param, ' ', $i) ?: (1 + $i + \strlen($param))) - $i - 1);
11891186

11901187
$tags['param'][$param] = $type;

src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ class_exists(Fixtures\SubClassWithAnnotatedParameters::class, true);
295295
'The "Symfony\Component\ErrorHandler\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "callable $callback" argument in the next major version of its interface "Symfony\Component\ErrorHandler\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
296296
'The "Symfony\Component\ErrorHandler\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "string $param" argument in the next major version of its interface "Symfony\Component\ErrorHandler\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
297297
'The "Symfony\Component\ErrorHandler\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "callable $anotherOne" argument in the next major version of its interface "Symfony\Component\ErrorHandler\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
298-
'The "Symfony\Component\ErrorHandler\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "Type$WithDollarIsStillAType $ccc" argument in the next major version of its interface "Symfony\Component\ErrorHandler\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
299298
'The "Symfony\Component\ErrorHandler\Tests\Fixtures\SubClassWithAnnotatedParameters::isSymfony()" method will require a new "true $yes" argument in the next major version of its parent class "Symfony\Component\ErrorHandler\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
300299
], $deprecations);
301300
}

src/Symfony/Component/ErrorHandler/Tests/Fixtures/InterfaceWithAnnotatedParameters.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ interface InterfaceWithAnnotatedParameters
1313
public function whereAmI();
1414

1515
/**
16-
* @param $noType
16+
* @param $noType with $dollar after
1717
* @param callable(\Throwable|null $reason, mixed $value) $callback and a comment
1818
* about this great param
1919
* @param string $param (comment with $dollar)
2020
* @param $defined
2121
* @param callable ($a, $b) $anotherOne
2222
* @param callable (mixed $a, $b) $definedCallable
23-
* @param Type$WithDollarIsStillAType $ccc
2423
* @param \JustAType
2524
*/
2625
public function iAmHere();

0 commit comments

Comments
 (0)