mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
a50198d0fe
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.
15 lines
214 B
PHP
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
|