Property in interface cannot be protected or private

Description

While PHP 8.4 supports properties in an interface, as long as they are defining hooks, it is not possible to use another visibility than public.

Example

<?php

interface I {
    private $p { get; }
}

?>

Solutions

  • Make the property visible.

  • Move the property definition to an abstract class.