PhpStorm 2023.3 Help

Code Inspection: Array write access is not used

Reports the array write access expressions that are not used in code afterwards. The most common source of such problems is modifying an array passed via a parameter: if an array is passed by value, the change will not be visible outside the function.

In the following example, the modifyArray() function is intended to modify the array passed as a parameter. Initially, the $myArr array parameter is passed by value, so modifying it will not have any effect outside the function. After the quick-fix is applied, the reference sign & is added to the parameter in the function declaration, which means that the array parameter is passed by reference and will therefore be modified is intended.

function modifyArray(array $myArr) { $myArr['key'] = 'value'; }
function modifyArray(array &$myArr) { $myArr['key'] = 'value'; }

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: 25 March 2024