Private constant %s::%s cannot be final as it is not visible to other classes

Description

A private constant is restricted to being used by its definition class only: as such, it is not visible to other classes, including children. A final class constant cannot be overwritten by a child class.

private and final a both mutually exclusive.

Example

<?php

class X {
    private final const A = 1;
}

?>

Literal Examples

  • Private constant C::A cannot be final as it is not visible to other classes

Solutions

  • Relax the private keyword with protected, or public.

  • Remove the final keyword.