Access level to %s::%s must be %s (as in %s %s)%s

Description

This error is emitted when a class constant is given more restrictive visibility than in the interface.

Anything in an interface is public, and so does any re-declaration in the host class.

Example

<?php

interface I {
    public const A   = 'public';
}

class X implements I {
    private const A   = 'public';
}

?>

Literal Examples

  • Access level to x::A must be public (as in interface i)

  • Access level to Z::B must be protected (as in class Y)

Solutions

  • Remove the constant from the interface.

  • Remove the constant from the class.