WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Review sniff handling of PHP 7.4 null coalesce equal operator

Open dingo-d opened this issue 2 years ago • 0 comments

Since PHP 7.4 null coalesce equal operator was introduced (??=).

Now instead of using null coalesce operator when assigning to a variable like:

$_GET['variable'] = $_GET['variable'] ?? 'default';

You can write

$_GET['variable'] ??= ''default';

We need to see what sniffs cover usage of this operator upstream and in the utils and if we can just use them in the WPCS ruleset.

Refs:

  • PHP RFC: https://wiki.php.net/rfc/null_coalesce_equal_operator

Related to #764

dingo-d avatar Apr 22 '22 07:04 dingo-d