PhpStorm 2021.2 Help

Code Inspection: Dangerous array initialization

Reports dangerous array initializations (such as $arr[] = value).

This practice is discouraged because if $arr already contains some value (for example, a string from a request variable), then this value will stay in place and [] may actually stand for string access operator. It is always preferable to initialize a variable by direct assignment.

See Creating/modifying with square bracket syntax (php.net) for details.

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