class_on_object.phpt 517 B

12345678910111213141516171819202122232425262728
  1. --TEST--
  2. Using ::class on an object
  3. --FILE--
  4. <?php
  5. $obj = new stdClass;
  6. var_dump($obj::class);
  7. $ref =& $obj;
  8. var_dump($ref::class);
  9. var_dump((new stdClass)::class);
  10. // Placed in a function to check that opcache doesn't perform incorrect constprop.
  11. function test() {
  12. $other = null;
  13. var_dump($other::class);
  14. }
  15. try {
  16. test();
  17. } catch (TypeError $e) {
  18. echo $e->getMessage(), "\n";
  19. }
  20. ?>
  21. --EXPECT--
  22. string(8) "stdClass"
  23. string(8) "stdClass"
  24. string(8) "stdClass"
  25. Cannot use "::class" on value of type null