php-src/Zend/tests/assign_coalesce_005.phpt
Nikita Popov a50198d0fe Implement ??= operator
RFC: https://wiki.php.net/rfc/null_coalesce_equal_operator

$a ??= $b is $a ?? ($a = $b), with the difference that $a is only
evaluated once, to the degree that this is possible. In particular
in $a[foo()] ?? $b function foo() is only ever called once.
However, the variable access themselves will be reevaluated.
2019-01-22 11:12:04 +01:00

15 lines
214 B
PHP

--TEST--
Coalesce assign (??=): Cannot reassign $this
--FILE--
<?php
class Test {
public function foobar() {
$this ??= 123;
}
}
?>
--EXPECTF--
Fatal error: Cannot re-assign $this in %s on line %d