PhpStorm 2024.1 Help

Code Inspection: Unused assignment

Reports a variable whose value is never used after assignment.


Suggests removing the unused variable to shorten the code and to avoid redundant allocations.

The following cases are reported:

  • A variable is never read after assignment.

  • The value of a variable is always overwritten with another assignment before the variable is read next time.

  • The initializer of a variable is redundant (for one of the above-mentioned reasons).

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