Type of %s::$%s must be omitted to match the parent definition in class %s

Description

A property cannot be redefined, by adding the mixed type to it. It looks like untyped property and mixed type property should behave the same, but they are not: in particular, typed properties have an ‘uninitialized’ state, which yields fatal errors when the property is read, which does not apply to untyped properties.

Example

<?php

class Foo
{
    public $property;
}

class Bar extends Foo
{
    public mixed $property;
}

?>

Literal Examples

  • Type of X::$p must be omitted to match the parent definition in class X

Solutions

  • Add the mixed type to the parent property definition.

  • Remove the mixed type from the child property definition.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.