Skip to content

MIR0717

InvalidReadonlyPropertyDeclaration

A readonly property is declared in a way that violates PHP’s readonly rules, such as declaring it as static or abstract.

<?php
class User {
public static readonly string $name; // Error: readonly cannot be static
}

Remove the invalid modifier combination:

<?php
class User {
public readonly string $name; // Correct: instance property with readonly
}