Cannot redeclare %s property %s::$%s as %s %s::$%s

Description

A property must be always readonly or non-readonly, in every classes of the same family. It cannot alternate between the two options, with inheritance.

The same applies also to the static option of properties.

Example

<?php

class X {
    private readonly $property;
}

class Y extends X {
    private $property;
}

?>

Literal Examples

  • Cannot redeclare readonly property X::$property as non-readonly Y::$property

  • Cannot redeclare non-readonly property X::$property as readonly Y::$property

  • Cannot redeclare static property X::$property as non-static Y::$property

  • Cannot redeclare non-static property X::$property as static Y::$property

Solutions

  • Make all the property definitions readonly.

  • Make all the property definitions non-readonly.

  • Remove some the conflicting property definitions.