PhpStorm
 
Get PhpStorm
You are viewing the documentation for an earlier version of PhpStorm.

Code Inspection: Dangerous array initialization

Last modified: 16 May 2022

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.