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
Tyson Andre 12ffee57d6 Fixed bug #77631
Do not include unbound anonymous classes in get_declared_classes().

Note that earlier PHP versions would include the anonymous class in
get_declared_classes(), and return false until the class was bound,
but would not crash.
2019-02-19 10:07:40 +01:00

36 lines
791 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, '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 class@%s
true
Done