1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Doctrine\ORM\Mapping; |
||
6 | |||
7 | use Doctrine\ORM\Reflection\ReflectionService; |
||
8 | |||
9 | /** |
||
10 | * Class AssociationMetadata |
||
11 | * |
||
12 | */ |
||
13 | class AssociationMetadata implements Property |
||
14 | { |
||
15 | /** @var ClassMetadata */ |
||
16 | private $declaringClass; |
||
17 | |||
18 | /** @var \ReflectionProperty */ |
||
19 | private $reflection; |
||
20 | |||
21 | /** @var string */ |
||
22 | private $name; |
||
23 | |||
24 | /** @var bool */ |
||
25 | protected $primaryKey = false; |
||
26 | |||
27 | /** @var string */ |
||
28 | private $fetchMode = FetchMode::LAZY; |
||
29 | |||
30 | /** @var string */ |
||
31 | private $targetEntity; |
||
32 | |||
33 | /** @var string */ |
||
34 | private $sourceEntity; |
||
35 | |||
36 | /** @var string|null */ |
||
37 | private $mappedBy; |
||
38 | |||
39 | /** @var string|null */ |
||
40 | private $inversedBy; |
||
41 | |||
42 | /** @var string[] */ |
||
43 | private $cascade = []; |
||
44 | |||
45 | /** @var bool */ |
||
46 | private $owningSide = true; |
||
47 | |||
48 | /** @var bool */ |
||
49 | private $orphanRemoval = false; |
||
50 | |||
51 | /** @var CacheMetadata|null */ |
||
52 | private $cache; |
||
53 | |||
54 | /** |
||
55 | * AssociationMetadata constructor. |
||
56 | */ |
||
57 | 315 | public function __construct(string $name) |
|
58 | { |
||
59 | 315 | $this->name = $name; |
|
60 | 315 | } |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 621 | public function getDeclaringClass() : ComponentMetadata |
|
66 | { |
||
67 | 621 | return $this->declaringClass; |
|
68 | } |
||
69 | |||
70 | 284 | public function setDeclaringClass(ComponentMetadata $declaringClass) : void |
|
71 | { |
||
72 | 284 | $this->declaringClass = $declaringClass; |
|
0 ignored issues
–
show
|
|||
73 | 284 | } |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 724 | public function getName() : string |
|
79 | { |
||
80 | 724 | return $this->name; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function setName($name) : void |
||
87 | { |
||
88 | $this->name = $name; |
||
89 | } |
||
90 | |||
91 | 44 | public function setPrimaryKey(bool $isPrimaryKey) : void |
|
92 | { |
||
93 | 44 | $this->primaryKey = $isPrimaryKey; |
|
94 | 44 | } |
|
95 | |||
96 | 986 | public function isPrimaryKey() : bool |
|
97 | { |
||
98 | 986 | return $this->primaryKey; |
|
99 | } |
||
100 | |||
101 | 1339 | public function getTargetEntity() : string |
|
102 | { |
||
103 | 1339 | return $this->targetEntity; |
|
104 | } |
||
105 | |||
106 | 284 | public function setTargetEntity(string $targetEntity) : void |
|
107 | { |
||
108 | 284 | $this->targetEntity = $targetEntity; |
|
109 | 284 | } |
|
110 | |||
111 | 829 | public function getSourceEntity() : string |
|
112 | { |
||
113 | 829 | return $this->sourceEntity; |
|
114 | } |
||
115 | |||
116 | 284 | public function setSourceEntity(string $sourceEntity) : void |
|
117 | { |
||
118 | 284 | $this->sourceEntity = $sourceEntity; |
|
119 | 284 | } |
|
120 | |||
121 | /** |
||
122 | * @return string[] |
||
123 | */ |
||
124 | 1064 | public function getCascade() : array |
|
125 | { |
||
126 | 1064 | return $this->cascade; |
|
127 | } |
||
128 | |||
129 | /** |
||
130 | * @param string[] $cascade |
||
131 | */ |
||
132 | 280 | public function setCascade(array $cascade) : void |
|
133 | { |
||
134 | 280 | $this->cascade = $cascade; |
|
135 | 280 | } |
|
136 | |||
137 | 283 | public function setOwningSide(bool $owningSide) : void |
|
138 | { |
||
139 | 283 | $this->owningSide = $owningSide; |
|
140 | 283 | } |
|
141 | |||
142 | 1308 | public function isOwningSide() : bool |
|
143 | { |
||
144 | 1308 | return $this->owningSide; |
|
145 | } |
||
146 | |||
147 | 588 | public function getFetchMode() : string |
|
148 | { |
||
149 | 588 | return $this->fetchMode; |
|
150 | } |
||
151 | |||
152 | 351 | public function setFetchMode(string $fetchMode) : void |
|
153 | { |
||
154 | 351 | $this->fetchMode = $fetchMode; |
|
155 | 351 | } |
|
156 | |||
157 | 1127 | public function getMappedBy() : ?string |
|
158 | { |
||
159 | 1127 | return $this->mappedBy; |
|
160 | } |
||
161 | |||
162 | 156 | public function setMappedBy(string $mappedBy) : void |
|
163 | { |
||
164 | 156 | $this->mappedBy = $mappedBy; |
|
165 | 156 | } |
|
166 | |||
167 | 974 | public function getInversedBy() : ?string |
|
168 | { |
||
169 | 974 | return $this->inversedBy; |
|
170 | } |
||
171 | |||
172 | 161 | public function setInversedBy(?string $inversedBy = null) : void |
|
173 | { |
||
174 | 161 | $this->inversedBy = $inversedBy; |
|
175 | 161 | } |
|
176 | |||
177 | 214 | public function setOrphanRemoval(bool $orphanRemoval) : void |
|
178 | { |
||
179 | 214 | $this->orphanRemoval = $orphanRemoval; |
|
180 | 214 | } |
|
181 | |||
182 | 308 | public function isOrphanRemoval() : bool |
|
183 | { |
||
184 | 308 | return $this->orphanRemoval; |
|
185 | } |
||
186 | |||
187 | 597 | public function getCache() : ?CacheMetadata |
|
188 | { |
||
189 | 597 | return $this->cache; |
|
190 | } |
||
191 | |||
192 | 66 | public function setCache(?CacheMetadata $cache = null) : void |
|
193 | { |
||
194 | 66 | $this->cache = $cache; |
|
195 | 66 | } |
|
196 | |||
197 | /** |
||
198 | * {@inheritdoc} |
||
199 | */ |
||
200 | 892 | public function setValue($object, $value) : void |
|
201 | { |
||
202 | 892 | $this->reflection->setValue($object, $value); |
|
203 | 892 | } |
|
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | 932 | public function getValue($object) |
|
209 | { |
||
210 | 932 | return $this->reflection->getValue($object); |
|
211 | } |
||
212 | |||
213 | /** |
||
214 | * {@inheritdoc} |
||
215 | */ |
||
216 | public function isAssociation() : bool |
||
217 | { |
||
218 | return true; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * {@inheritdoc} |
||
223 | */ |
||
224 | public function isField() : bool |
||
225 | { |
||
226 | return false; |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * {@inheritdoc} |
||
231 | */ |
||
232 | 1695 | public function setReflectionProperty(\ReflectionProperty $reflectionProperty) : void |
|
233 | { |
||
234 | 1695 | $this->reflection = $reflectionProperty; |
|
235 | 1695 | } |
|
236 | |||
237 | /** |
||
238 | * {@inheritdoc} |
||
239 | */ |
||
240 | 1454 | public function wakeupReflection(ReflectionService $reflectionService) : void |
|
241 | { |
||
242 | 1454 | $this->setReflectionProperty( |
|
243 | 1454 | $reflectionService->getAccessibleProperty($this->declaringClass->getClassName(), $this->name) |
|
244 | ); |
||
245 | 1454 | } |
|
246 | |||
247 | 52 | public function __clone() |
|
248 | { |
||
249 | 52 | if ($this->cache) { |
|
250 | 12 | $this->cache = clone $this->cache; |
|
251 | } |
||
252 | 52 | } |
|
253 | } |
||
254 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.