%s::%s cannot override final constant %s::%s

Description

The final keyword prevents any child class to define the same constant or method. The final const may overwrite a parent’s definition, but this is the definitive value associated to the constant. Child class must define a distinct constant name.

Example

<?php

class X {
     final const A = 1;
}

class Y extends X {
     const A = 1;
}

?>

Literal Examples

  • Y::A cannot override final constant X::Y

Solutions

  • Remove the final option in the parent class.

  • Rename the non-final constant in the child class.