[Debug][DebugClassLoader] Match callable() type for parameters not defined in sub classes
This commit is contained in:
parent
14d458d0dc
commit
89c89c9776
@ -352,7 +352,7 @@ class DebugClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (self::$annotatedParameters[$class][$method->name] as $parameterName => $deprecation) {
|
foreach (self::$annotatedParameters[$class][$method->name] as $parameterName => $deprecation) {
|
||||||
if (!isset($definedParameters[$parameterName]) && !($doc && preg_match("/\\n\\s+\\* @param (.*?)(?<= )\\\${$parameterName}\\b/", $doc))) {
|
if (!isset($definedParameters[$parameterName]) && !($doc && preg_match("/\\n\\s+\\* @param +((?(?!callable *\().*?|callable *\(.*\).*?))(?<= )\\\${$parameterName}\\b/", $doc))) {
|
||||||
$deprecations[] = sprintf($deprecation, $class);
|
$deprecations[] = sprintf($deprecation, $class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ class DebugClassLoader
|
|||||||
if ($finalOrInternal || $method->isConstructor() || false === \strpos($doc, '@param') || StatelessInvocation::class === $class) {
|
if ($finalOrInternal || $method->isConstructor() || false === \strpos($doc, '@param') || StatelessInvocation::class === $class) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!preg_match_all('#\n\s+\* @param (.*?)(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)#', $doc, $matches, PREG_SET_ORDER)) {
|
if (!preg_match_all('#\n\s+\* @param +((?(?!callable *\().*?|callable *\(.*\).*?))(?<= )\$([a-zA-Z0-9_\x7f-\xff]++)#', $doc, $matches, PREG_SET_ORDER)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!isset(self::$annotatedParameters[$class][$method->name])) {
|
if (!isset(self::$annotatedParameters[$class][$method->name])) {
|
||||||
|
@ -287,6 +287,11 @@ class DebugClassLoaderTest extends TestCase
|
|||||||
$this->assertSame([
|
$this->assertSame([
|
||||||
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::quzMethod()" method will require a new "Quz $quz" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::quzMethod()" method will require a new "Quz $quz" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::whereAmI()" method will require a new "bool $matrix" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::whereAmI()" method will require a new "bool $matrix" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "$noType" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "callable(\Throwable|null $reason, mixed $value) $callback" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "string $param" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "callable ($a, $b) $anotherOne" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::iAmHere()" method will require a new "Type$WithDollarIsStillAType $ccc" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\InterfaceWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::isSymfony()" method will require a new "true $yes" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
|
'The "Symfony\Component\Debug\Tests\Fixtures\SubClassWithAnnotatedParameters::isSymfony()" method will require a new "true $yes" argument in the next major version of its parent class "Symfony\Component\Debug\Tests\Fixtures\ClassWithAnnotatedParameters", not defining it is deprecated.',
|
||||||
], $deprecations);
|
], $deprecations);
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,17 @@ interface InterfaceWithAnnotatedParameters
|
|||||||
* @param bool $matrix
|
* @param bool $matrix
|
||||||
*/
|
*/
|
||||||
public function whereAmI();
|
public function whereAmI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $noType
|
||||||
|
* @param callable(\Throwable|null $reason, mixed $value) $callback and a comment
|
||||||
|
* about this great param
|
||||||
|
* @param string $param (comment with $dollar)
|
||||||
|
* @param $defined
|
||||||
|
* @param callable ($a, $b) $anotherOne
|
||||||
|
* @param callable (mixed $a, $b) $definedCallable
|
||||||
|
* @param Type$WithDollarIsStillAType $ccc
|
||||||
|
* @param \JustAType
|
||||||
|
*/
|
||||||
|
public function iAmHere();
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,12 @@ class SubClassWithAnnotatedParameters extends ClassWithAnnotatedParameters imple
|
|||||||
public function whereAmI()
|
public function whereAmI()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $defined
|
||||||
|
* @param Type\Does\Not\Matter $definedCallable
|
||||||
|
*/
|
||||||
|
public function iAmHere()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user