Skip to content

MIR0232

PossiblyNullPropertyAssignmentValue

A value assigned to a property may be null, which the property’s type doesn’t accept.

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

Check for null before assigning, or make the property nullable.