Skip to content

Commit

Permalink
Add dedicated test for anon class names
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Feb 7, 2020
1 parent 891047e commit 6cad62b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Zend/tests/anon_class_name.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--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

0 comments on commit 6cad62b

Please sign in to comment.