1.2.158. Coalesce Equal¶
Usage of coalesce assignment operator. The operator is available in PHP since PHP 7.4.
<?php
// Coalesce operator, since PHP 5.3
$a ??= 'default value';
// Equivalent to the line above
$a = $a ?? 'default value';
?>
See also Ternary Operator.
1.2.158.1. Suggestions¶
Use the short assignment syntax
1.2.158.2. Specs¶
Short name |
Php/CoalesceEqual |
Rulesets |
All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72, CompatibilityPHP73 |
Exakat since |
2.0.4 |
PHP Version |
With PHP 7.4 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Features |
coalesce, short-syntax |
Available in |