vendredi 20 octobre 2017

How to check if ReflectionProperty is accessible?

Is there a way to check that I've already set a ReflectionProperty to be accessible?

class Foo {
    private   $baz  = 'bar';
}

$foo = new Foo();

$prop = new ReflectionProperty($foo, 'baz');
$prop->setAccessible(true);

Doing $prop->isPrivate(); will return true before and after setting the accessibility (as expected). Is there a way to tell that I've already set the accessibility to true?

The documentation doesn't show anything like an $accessible property in the ReflectionProperty class, so I'm not sure how it's making it accessible, unless it's done on the Foo class.





Aucun commentaire:

Enregistrer un commentaire