Inspectopedia Help

Modification of the array returned from function by value won't have any effect

Reports call to a function that returns array by value, which makes the assignment operation non-working. Return by reference shall be used instead.

For example:

<?php class A { private $values = []; public function getValues() { return $this->values; } } $config = new A(); $config->getValues()['a'] = 'a';

Inspection Details

Available in:

PhpStorm 2023.3, Qodana for PHP 2023.3

Plugin:

PHP, 233.SNAPSHOT

Last modified: 13 July 2023