Cannot inherit previously-inherited or override constant %s from interface %s

Description

Until PHP 8.1, it was not possible to override a constant when it was defined in an interface, even with the same definition.

Example

<?php

interface I {
    const A = 1;
}

class X implements I {
    const A = 2;
}

?>

Literal Examples

  • Cannot inherit previously-inherited or override constant x from interface i

Solutions

  • Remove the constant from the class.

  • Remove the constant from the interface.

  • Move to PHP 8.1 or more recent.