stringable_automatic_implementation.phpt 589 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. Stringable is automatically implemented
  3. --FILE--
  4. <?php
  5. class Test {
  6. public function __toString() {
  7. return "foo";
  8. }
  9. }
  10. var_dump(new Test instanceof Stringable);
  11. var_dump((new ReflectionClass(Test::class))->getInterfaceNames());
  12. class Test2 extends Test {
  13. public function __toString() {
  14. return "bar";
  15. }
  16. }
  17. var_dump(new Test2 instanceof Stringable);
  18. var_dump((new ReflectionClass(Test2::class))->getInterfaceNames());
  19. ?>
  20. --EXPECT--
  21. bool(true)
  22. array(1) {
  23. [0]=>
  24. string(10) "Stringable"
  25. }
  26. bool(true)
  27. array(1) {
  28. [0]=>
  29. string(10) "Stringable"
  30. }