Reflection Doesn’t Return Static
Reflection used to return the original static type, including its case. Since PHP 8.5, it is now returning the actual name of the class, instead of the relative type.
PHP code
<?php
// code from https://www.reddit.com/r/PHP/comments/1rd3j74/php_85_reflectionnamedtypegetname_change/
class Foo
{
function poop (static $a): static
{
}
}
$refMethod = new ReflectionMethod('Foo', 'poop');
$refParam = $refMethod->getParameters()[0];
print_r(array(
'paramType' => $refParam->getType()->getName(),
'returnType' => $refMethod->getReturnType()->getName(),
));
?>
Before
Array
(
[paramType] => static
[returnType] => static
)
After
Array
(
[paramType] => Foo
[returnType] => Foo
)
PHP version change
This behavior changed in 8.5.