MIR1707
ImpureByRefAssignment
An impure function modifies a parameter that was passed by reference, which introduces side effects that can make code harder to reason about and test.
Example
Section titled “Example”<?phpfunction updateConfig(array &$config, string $key, mixed $value): void { $config[$key] = $value; // Modifies caller's array by reference}How to fix
Section titled “How to fix”Return a new value instead of modifying by reference, or document the side effect clearly:
<?phpfunction updateConfig(array $config, string $key, mixed $value): array { $config[$key] = $value; return $config;}
// Usage$config = updateConfig($config, 'key', 'value');