Interfaces may not include properties

Description

Interfaces can define methods and constants, though they can’t define properties.

Example

<?php

interface I {
     private $property;
}

?>

Solutions

  • Upgrade PHP version to 8.4.

  • Turn the interface in an abstract class.

  • Turn the interface in a trait.

In previous PHP versions, this error message used to be Interfaces may only include hooked properties.