1--TEST-- 2ReflectionClass::isSubclassOf() - fixed crash for unbound anonymous class 3--SKIPIF-- 4<?php 5if (getenv('SKIP_PRELOAD')) die('skip Anon class is linked during preloading'); 6?> 7--FILE-- 8<?php 9class X { 10 public static function main() { 11 return new class() extends Base {}; 12 } 13} 14class Base {} 15$check = function () { 16 $base = Base::class; 17 foreach (get_declared_classes() as $class) { 18 if (strpos($class, '@anonymous') === false) { 19 continue; 20 } 21 echo "Checking for $class\n"; 22 flush(); 23 $rc = new ReflectionClass($class); 24 var_export($rc->isSubclassOf($base)); 25 echo "\n"; 26 } 27}; 28// Should not show up in get_declared_classes until the anonymous class is bound. 29$check(); 30echo "After first check\n"; 31X::main(); 32$check(); 33echo "Done\n"; 34?> 35--EXPECTF-- 36After first check 37Checking for Base@%s 38true 39Done 40