InaccessibleProperty
Emitted when attempting to access a protected/private property from outside its available scope
<?php
class A {
/** @return string */
protected $foo;
}
echo (new A)->foo;
It is also emitted when writing to a property whose asymmetric set visibility (PHP 8.4) is not accessible from the current context:
<?php
class A {
public private(set) string $foo = 'bar';
}
$a = new A();
$a->foo = 'baz';
It is also emitted when a readonly property is written anywhere but in a constructor (or __clone, unserialize) of its class:
<?php
class Test {}
class A {
public function __construct(private readonly Test $test) {}
public function change(Test $test): void {
$this->test = $test; // InaccessibleProperty: A::$test is marked readonly
}
}