PhpStorm 2021.2 Help

Code Inspection: 'foreach' variable overwrites already defined variable

Reports the keys and values in foreach loops that are assigned a non-primitive value before the foreach loop and are accessed after it. Such usages may unwillingly overwrite an already defined value and cause latent bugs.

Suppress an inspection in the editor

  1. Position 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: 16 July 2021