I would like to have a private property in a class, and be able to set it with another, via a ReflectionClass.
I know that if I create ReflectionProperties of the class’ properties, I can set them to accessible, and then set their values.
However, if I set the property to accessible, does it become accessible everywhere (like a public property), or is it just in the context of the ReflectionProperty?
It will only be accessible through the
ReflectionProperty::getValue()andReflectionProperty::setValue(), so the original class and all its instances will not have their visibility changed.Example: