On Wed, Jul 19, 2017 at 9:53 AM, Bartłomiej Krukowski < krukowski.bartlom...@gmail.com> wrote:
> Hello, > > Class *ReflectionProperty* allows to get access to private properties in > library. Unfortunately there is one unexpected (or at least undocumented) > case - *ReflectionProperty* tries execute *__call* method. In my opinion > this approach is bad, because method *__call* can change state of > application (I'd like to read value, not execute code). This is expected behavior - the reflection API does not work around the rules of the engine, just the rules of scope (like closures do). See https://bugs.php.net/bug.php?id=63463 for a very similar report that was discussed and marked as "not a bug" ages ago. > I'd like to suggest > different approach: > > > - Method *ReflectionProperty->getValue* will throw exception when > property is removed. > It should just call `__get` as before - see also https://bugs.php.net/bug.php?id=72174 and https://github.com/php/php- src/commit/a1ed4ab3caf33b59742897b43462d033864bb490 - reflection shouldn't check if the property exists upfront. > - Class *ReflectionProperty* will receive new method - *exists*. > You can already use `array_key_exists($propertyFqn, (array) $object);` for that. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/