Property in interface cannot be final

Description

While PHP 8.4 supports properties in an interface, as long as they are defining hooks, it is not possible to use the final option: in fact, the property hook does not have a body, so there is no code to finalize.

Example

<?php

interface I {
    final $p { get; }
}

?>

Solutions

  • Remove the final option.

  • Move the property definition to an abstract class.