IsNullFunctionUsage
info off by default quick-fixGroup: Code style · PhpStorm name: IsNullFunctionUsageInspection
is_null($v) is a function call doing what the === null comparison does natively. This opt-in rule rewrites is_null() calls (including negations and comparisons of the result against true/false) into an identity comparison with null.
Example
Regular style:
php
<?php
$a = is_null($row);
$b = !is_null($row);
$c = is_null($cfg->get()) == TRUE;
$d = false === is_null($cfg->get());
$e = is_null($row) != false;
$f = \is_null($row) !== true;
$g = $ok and is_null($row);
$h = !is_null($left ?? $right);
$i = is_null($n = next($it));
$j = is_null((int) $raw);
$k = is_null($p, $q);php
<?php
$a = $row === null;
$b = $row !== null;
$c = $cfg->get() === null;
$d = $cfg->get() !== null;
$e = $row === null;
$f = $row !== null;
$g = $ok and $row === null;
$h = ($left ?? $right) !== null;
$i = ($n = next($it)) === null;
$j = (int) $raw === null;
$k = is_null($p, $q);Reported:
- line 3: Replace with '$row === null'.
- line 4: Replace with '$row !== null'.
- line 5: Replace with '$cfg->get() === null'.
- line 6: Replace with '$cfg->get() !== null'.
- line 7: Replace with '$row === null'.
- line 8: Replace with '$row !== null'.
- line 9: Replace with '$row === null'.
- line 10: Replace with '($left ?? $right) !== null'.
- line 11: Replace with '($n = next($it)) === null'.
- line 12: Replace with '(int) $raw === null'.
Options
| Option | Type | Default | Effect |
|---|---|---|---|
| (none) | Operand order follows the global comparison style (regular default / yoda). |
Configure
In custos.json:
json
{
"rules": {
"IsNullFunctionUsage": {
"enabled": true
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore IsNullFunctionUsage
/**
* @noinspection IsNullFunctionUsageInspection
*/