
ternary_to_null_coalescing
¶Use null
coalescing operator ??
where possible. Requires PHP >= 7.0.
--- Original
+++ New
<?php
-$sample = isset($a) ? $a : $b;
+$sample = $a ?? $b;
The rule is part of the following rule sets:
Using the @PHP70Migration rule set will enable the ternary_to_null_coalescing
rule.
Using the @PHP71Migration rule set will enable the ternary_to_null_coalescing
rule.
Using the @PHP73Migration rule set will enable the ternary_to_null_coalescing
rule.
Using the @PHP74Migration rule set will enable the ternary_to_null_coalescing
rule.
Using the @PHP80Migration rule set will enable the ternary_to_null_coalescing
rule.
Using the @PHP81Migration rule set will enable the ternary_to_null_coalescing
rule.
Using the @PHP82Migration rule set will enable the ternary_to_null_coalescing
rule.