123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace Doctrine\Common\Reflection;
- use Doctrine\Common\Proxy\Proxy;
- use ReflectionProperty;
- class RuntimePublicReflectionProperty extends ReflectionProperty
- {
-
- public function getValue($object = null)
- {
- $name = $this->getName();
- if ($object instanceof Proxy && ! $object->__isInitialized()) {
- $originalInitializer = $object->__getInitializer();
- $object->__setInitializer(null);
- $val = $object->$name ?? null;
- $object->__setInitializer($originalInitializer);
- return $val;
- }
- return isset($object->$name) ? parent::getValue($object) : null;
- }
-
- public function setValue($object, $value = null)
- {
- if (! ($object instanceof Proxy && ! $object->__isInitialized())) {
- parent::setValue($object, $value);
- return;
- }
- $originalInitializer = $object->__getInitializer();
- $object->__setInitializer(null);
- parent::setValue($object, $value);
- $object->__setInitializer($originalInitializer);
- }
- }
|