1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/reflection/tests/ReflectionClass_isSubclassOf_error2.phpt
Gabriel Caruso 4aabfe911e Revert "Update versions for PHP 8.0.21"
This reverts commit 6eedacdf15.
2022-07-06 12:06:48 +02:00

36 lines
785 B
PHP

--TEST--
ReflectionClass::isSubclassOf() - fixed crash for unbound anonymous class
--FILE--
<?php
class X {
public static function main() {
return new class() extends Base {};
}
}
class Base {}
$check = function () {
$base = Base::class;
foreach (get_declared_classes() as $class) {
if (strpos($class, '@anonymous') === false) {
continue;
}
echo "Checking for $class\n";
flush();
$rc = new ReflectionClass($class);
var_export($rc->isSubclassOf($base));
echo "\n";
}
};
// Should not show up in get_declared_classes until the anonymous class is bound.
$check();
echo "After first check\n";
X::main();
$check();
echo "Done\n";
?>
--EXPECTF--
After first check
Checking for Base@%s
true
Done