It is not possible to access the $storage property through Reflection because it does not exist.
What you see when you call print_r (or var_dump ) in a class is debugging information. This information is provided through the internal get_debug_info class handler. This handler allows inner classes to display meaningful debugging information without defining the actual properties.
A tangentially related problem shows the following snippet:
$r = new ReflectionClass('DateTime'); var_dump($r->hasProperty("timezone"));
In the above code, you will be told that the class does not have a timezone property, even if you can access the timezone property on DateTime objects. The reason is that this property is not declared, it is provided only through the internal get_properties handler. Once again, this property, which is not intended for direct access, exists only for: a) providing meaningful debug output and b) determining what should be serialized when the object is serialized.
In short: Reflection on the โpropertiesโ of inner classes usually does not work, simply because these properties often do not actually exist.
source share