I actually implemented that for PHP7. It's now at RFC proposal stage.
https://github.com/php/php-src/pull/1795
Actually it was a question about null coalescing operator in PHP7. Check this:
$this->request->data['comments']['user_id'] = $this->request->data['comments']['user_id'] ?? ‘value’;
I want to check if some var is null and if the same var is null set the same var to ‘value’.
Hence I am repeating the same variable after the equal operator, this does not feels right.
So I feel that we need another operator like “??=“ similar to +=;
$this->request->data['comments']['user_id’] ??= ‘value’. So if the var is null it’s set to ‘value’ and else stays the same.
In that pull request I tried to implement this.
$ sapi/cli/php -r '$num = null;$num ??= 5; echo $num;'
5