ReflectionProperty::setAccessible
Устанавливает доступность свойства
&reftitle.description;
public voidReflectionProperty::setAccessible
boolaccessible
Метод открывает доступ к защищённому или закрытому свойству методам
ReflectionProperty::getValue
и ReflectionProperty::setValue.
С PHP 8.1.0 вызов метода утратил смысл; свойства доступны по умолчанию.
&reftitle.parameters;
accessible
Значение &true; делает свойство доступным, &false; — закрывает доступ к свойству.
&reftitle.returnvalues;
&return.void;
&reftitle.examples;
Определение простого класса
setAccessible(true);
$obj = new MyClass();
echo $property->getValue($obj);
echo $obj->foo;
?>
]]>
&example.outputs.similar;
&reftitle.seealso;
ReflectionProperty::isPrivate
ReflectionProperty::isProtected