Only hooked properties may be declared abstract¶
Description¶
Hooked properties may be declared abstract, as long as the class is also abstract, and that one of the hook, get
or set
or both, have no body block.
In previous version, PHP would never allow properties to be abstract.
Example¶
<?php
abstract class X {
public abstract string $x;
}
?>
Solutions¶
Add an identity hook to the class, such as
get => $this->x
orset => $this->x = $value;
.Remove the abstract keyword.
In previous PHP versions, this error message used to be Cannot use the abstract modifier on a property.