PhpStorm 2024.1 Help

Code Inspection: Expression is always 'null'

Reports the variables in return statements that are always null.

In the following example, the $var variable returned from within the conditional statement is always null. After the quick-fix is applied, the variable is replaced with the explicit null value.

function getValue($var) { if ($var === null) { return $var; } return $var; }
function getValue($var) { if ($var === null) { return null; } return $var; }

Suppress an inspection in the editor

  1. Place the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 17 April 2024