019.phpt 375 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Test nullsafe in new
  3. --FILE--
  4. <?php
  5. class Bar {}
  6. class Foo {
  7. public $bar;
  8. }
  9. $foo = new Foo();
  10. $foo->bar = 'bar';
  11. var_dump(new $foo?->bar);
  12. $foo = null;
  13. var_dump(new $foo?->bar);
  14. ?>
  15. --EXPECTF--
  16. object(Bar)#2 (0) {
  17. }
  18. Fatal error: Uncaught Error: Class name must be a valid object or a string in %s.php:14
  19. Stack trace:
  20. #0 {main}
  21. thrown in %s.php on line 14