Skip to content

MIR0011

InaccessibleClassConstant

A private or protected class constant is accessed from a scope that does not have permission to read it. Private constants are only accessible within the declaring class; protected constants are accessible within the declaring class and its subclasses.

<?php
class Config {
private const SECRET = 'abc123';
}
echo Config::SECRET; // cannot access private constant from outside the class

Change the constant’s visibility to public, or access it only from within the declaring class (or a subclass, for protected).