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

Code Inspection: Array write access is not used

Last modified: 16 May 2022

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.