Skip to content

MIR0712

PropertyTypeRedeclarationMismatch

A property type declaration in a child class is incompatible with the parent class declaration. A redeclared property keeps the parent’s type, and is typed only if the parent’s is: adding a type to an untyped parent property, or dropping the parent’s type, is a fatal error too.

<?php
class Parent {
public string $name;
}
class Child extends Parent {
public int $name; // Error: incompatible type
}

Ensure the child class property type is compatible with the parent:

<?php
class Parent {
public string $name;
}
class Child extends Parent {
// Keep the same type
public string $name;
}