Code Inspection: Dangerous array initialization
Reports dangerous array initializations (such as $arr[] = value
).
$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
Position the caret at the highlighted line and press Alt+Enter or click .
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.
Last modified: 11 February 2022