summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/Mapping/EmbeddedClassMapping.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/EmbeddedClassMapping.php')
-rw-r--r--vendor/doctrine/orm/src/Mapping/EmbeddedClassMapping.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/EmbeddedClassMapping.php b/vendor/doctrine/orm/src/Mapping/EmbeddedClassMapping.php
new file mode 100644
index 0000000..8fd02c9
--- /dev/null
+++ b/vendor/doctrine/orm/src/Mapping/EmbeddedClassMapping.php
@@ -0,0 +1,93 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\ORM\Mapping;
6
7use ArrayAccess;
8
9use function property_exists;
10
11/** @template-implements ArrayAccess<string, mixed> */
12final class EmbeddedClassMapping implements ArrayAccess
13{
14 use ArrayAccessImplementation;
15
16 public string|false|null $columnPrefix = null;
17 public string|null $declaredField = null;
18 public string|null $originalField = null;
19
20 /**
21 * This is set when this embedded-class field is inherited by this class
22 * from another (inheritance) parent <em>entity</em> class. The value is
23 * the FQCN of the topmost entity class that contains mapping information
24 * for this field. (If there are transient classes in the class hierarchy,
25 * these are ignored, so the class property may in fact come from a class
26 * further up in the PHP class hierarchy.) Fields initially declared in
27 * mapped superclasses are <em>not</em> considered 'inherited' in the
28 * nearest entity subclasses.
29 *
30 * @var class-string|null
31 */
32 public string|null $inherited = null;
33
34 /**
35 * This is set when the embedded-class field does not appear for the first
36 * time in this class, but is originally declared in another parent
37 * <em>entity or mapped superclass</em>. The value is the FQCN of the
38 * topmost non-transient class that contains mapping information for this
39 * field.
40 *
41 * @var class-string|null
42 */
43 public string|null $declared = null;
44
45 /** @param class-string $class */
46 public function __construct(public string $class)
47 {
48 }
49
50 /**
51 * @psalm-param array{
52 * class: class-string,
53 * columnPrefix?: false|string|null,
54 * declaredField?: string|null,
55 * originalField?: string|null,
56 * inherited?: class-string|null,
57 * declared?: class-string|null,
58 * } $mappingArray
59 */
60 public static function fromMappingArray(array $mappingArray): self
61 {
62 $mapping = new self($mappingArray['class']);
63 foreach ($mappingArray as $key => $value) {
64 if ($key === 'class') {
65 continue;
66 }
67
68 if (property_exists($mapping, $key)) {
69 $mapping->$key = $value;
70 }
71 }
72
73 return $mapping;
74 }
75
76 /** @return list<string> */
77 public function __sleep(): array
78 {
79 $serialized = ['class'];
80
81 if ($this->columnPrefix) {
82 $serialized[] = 'columnPrefix';
83 }
84
85 foreach (['declaredField', 'originalField', 'inherited', 'declared'] as $property) {
86 if ($this->$property !== null) {
87 $serialized[] = $property;
88 }
89 }
90
91 return $serialized;
92 }
93}