Skip to content

MIR0234

PossiblyInvalidPropertyAssignmentValue

Only some types of a value assigned to a property match the property’s type.

<?php
class Counter {
public int $n = 0;
public function set(int|string $value): void {
$this->n = $value;
}
}

Narrow the value to the property’s type before assigning, or widen the property type.