Skip to content

MIR0220

InvalidArrayAssignment

An assignment of the form $value[key] = ... is made to a value whose type does not support array-style assignment. Only arrays and objects implementing ArrayAccess support this syntax.

<?php
function setFirst(string $items, mixed $val): void {
$items[0] = $val; // string does not support array-style assignment
}

Change the type to an array or an ArrayAccess implementation, or avoid array-style assignment.