Skip to content

MIR0014

InaccessibleProperty

A private or protected property is read from a scope that does not have permission to read it. Private properties are only accessible within the declaring class; protected properties are accessible within the declaring class and its subclasses. This applies to both instance ($obj->prop) and static (Class::$prop) property access.

<?php
class Vault {
private string $secret = 'classified';
}
echo (new Vault())->secret; // cannot access private property from outside the class

Change the property’s visibility to public, add an accessor method, or access it only from within the declaring class (or a subclass, for protected).