Property %s::$%s cannot have type %s

Description

Some native PHP types are not allowed with a property. This is the case of void, never and callable. Any mention of them, alone or in a compsed type generates this error.

Example

<?php

class X {
     public callable|int $property = 1;
}

?>

Literal Examples

  • Property x::$p cannot have type callable

Solutions

  • Remove any illegal type from the definition of the property.

  • Remove all types from the definition of the property.