summaryrefslogtreecommitdiff
path: root/vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php')
-rw-r--r--vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php b/vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php
new file mode 100644
index 0000000..e2367ec
--- /dev/null
+++ b/vendor/doctrine/persistence/src/Persistence/Reflection/RuntimePublicReflectionProperty.php
@@ -0,0 +1,61 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\Persistence\Reflection;
6
7use Doctrine\Common\Proxy\Proxy;
8use ReflectionProperty;
9use ReturnTypeWillChange;
10
11/**
12 * PHP Runtime Reflection Public Property - special overrides for public properties.
13 *
14 * @deprecated since version 3.1, use RuntimeReflectionProperty instead.
15 */
16class RuntimePublicReflectionProperty extends ReflectionProperty
17{
18 /**
19 * {@inheritDoc}
20 *
21 * Returns the value of a public property without calling
22 * `__get` on the provided $object if it exists.
23 *
24 * @return mixed
25 */
26 #[ReturnTypeWillChange]
27 public function getValue($object = null)
28 {
29 return $object !== null ? ((array) $object)[$this->getName()] ?? null : parent::getValue();
30 }
31
32 /**
33 * {@inheritDoc}
34 *
35 * Avoids triggering lazy loading via `__set` if the provided object
36 * is a {@see \Doctrine\Common\Proxy\Proxy}.
37 *
38 * @link https://bugs.php.net/bug.php?id=63463
39 *
40 * @param object|null $object
41 * @param mixed $value
42 *
43 * @return void
44 */
45 #[ReturnTypeWillChange]
46 public function setValue($object, $value = null)
47 {
48 if (! ($object instanceof Proxy && ! $object->__isInitialized())) {
49 parent::setValue($object, $value);
50
51 return;
52 }
53
54 $originalInitializer = $object->__getInitializer();
55 $object->__setInitializer(null);
56
57 parent::setValue($object, $value);
58
59 $object->__setInitializer($originalInitializer);
60 }
61}