1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/Zend/tests/nullsafe_operator/019.phpt
Ilija Tovilo 9bf119832d Implement nullsafe ?-> operator
RFC: https://wiki.php.net/rfc/nullsafe_operator

Closes GH-5619.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-07-24 10:05:03 +02:00

28 lines
375 B
PHP

--TEST--
Test nullsafe in new
--FILE--
<?php
class Bar {}
class Foo {
public $bar;
}
$foo = new Foo();
$foo->bar = 'bar';
var_dump(new $foo?->bar);
$foo = null;
var_dump(new $foo?->bar);
?>
--EXPECTF--
object(Bar)#2 (0) {
}
Fatal error: Uncaught Error: Class name must be a valid object or a string in %s.php:14
Stack trace:
#0 {main}
thrown in %s.php on line 14