Type of %s::$%s must not be defined (as in class %s)

Description

Property definitions must be compatible one another, between a parent and a child class. With this error message, the parent class did not define a type for the property, and so, the child class should also not define it. On the other hand, it may change the default value.

Example

<?php

class X {
    public $a;
}

class Y extends X {
    public array $a;
}

?>

Literal Examples

  • Type of Y::$a must not be defined (as in class X)

Solutions

  • Add the type to the parent class, and the sibling classes.

  • Remove the type in the child class.