mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
72bd55902d
In order of preference, the generated name will be: new class extends ParentClass {}; // -> ParentClass@anonymous new class implements FirstInterface, SecondInterface {}; // -> FirstInterface@anonymous new class {}; // -> class@anonymous This is intended to display a more useful class name in error messages and stack traces, and thus make debugging easier. Closes GH-5153.
31 lines
736 B
PHP
31 lines
736 B
PHP
--TEST--
|
|
Generated names for anonymous classes
|
|
--FILE--
|
|
<?php
|
|
|
|
namespace DeclaringNS {
|
|
class Test1 {}
|
|
interface Test2 {}
|
|
interface Test3 {}
|
|
}
|
|
|
|
namespace UsingNS {
|
|
function print_name(object $obj) {
|
|
echo strstr(get_class($obj), "\0", true), "\n";
|
|
}
|
|
|
|
print_name(new class {});
|
|
print_name(new class extends \DeclaringNS\Test1 {});
|
|
print_name(new class extends \DeclaringNS\Test1 implements \DeclaringNS\Test2 {});
|
|
print_name(new class implements \DeclaringNS\Test2 {});
|
|
print_name(new class implements \DeclaringNS\Test2, \DeclaringNS\Test3 {});
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
class@anonymous
|
|
DeclaringNS\Test1@anonymous
|
|
DeclaringNS\Test1@anonymous
|
|
DeclaringNS\Test2@anonymous
|
|
DeclaringNS\Test2@anonymous
|