|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Doctrine\Tests\ODM\CouchDB\Mapping; |
|
5
|
|
|
|
|
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
7
|
|
|
use Doctrine\ODM\CouchDB\Mapping\EmbeddedDocumentSerializer; |
|
8
|
|
|
use Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory; |
|
9
|
|
|
use Doctrine\ODM\CouchDB\Mapping\MetadataResolver\DoctrineResolver; |
|
10
|
|
|
/* |
|
11
|
|
|
public function __constrct(DocumentManager $dm) |
|
12
|
|
|
public function serializeEmbeddedDocument($embeddedValue, $embeddedFieldMapping) |
|
13
|
|
|
public function createEmbeddedDocument($data, $embeddedFieldMapping) |
|
14
|
|
|
public function compare($jsonValue, $embeddedDocument) |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
class EmbeddedDocumentSerializerTest extends \Doctrine\Tests\ODM\CouchDB\CouchDBFunctionalTestCase |
|
18
|
|
|
{ |
|
19
|
|
|
private $serializer; |
|
20
|
|
|
public function setUp() |
|
21
|
|
|
{ |
|
22
|
|
|
$dm = $this->createDocumentManager(); |
|
23
|
|
|
$this->metadataFactory = new ClassMetadataFactory($dm); |
|
|
|
|
|
|
24
|
|
|
$resolver = new DoctrineResolver(); |
|
25
|
|
|
$this->serializer = new EmbeddedDocumentSerializer($this->metadataFactory, $resolver); |
|
26
|
|
|
|
|
27
|
|
|
$this->arrayDataFixture = array( |
|
|
|
|
|
|
28
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Embedded', |
|
29
|
|
|
'name' => 'embedded-1', |
|
30
|
|
|
'embeds' => array( |
|
31
|
|
|
'one' => array( |
|
32
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Nested', |
|
33
|
|
|
'nestedName' => 'a111' |
|
34
|
|
|
), |
|
35
|
|
|
'two' => array( |
|
36
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Nested', |
|
37
|
|
|
'nestedName' => 'a222' |
|
38
|
|
|
) |
|
39
|
|
|
), |
|
40
|
|
|
); |
|
41
|
|
|
$this->embedOneFixture = array( |
|
|
|
|
|
|
42
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Embedded', |
|
43
|
|
|
'name' => 'embeddedAnyOne', |
|
44
|
|
|
|
|
45
|
|
|
); |
|
46
|
|
|
$this->embedAnyFixture = array( |
|
|
|
|
|
|
47
|
|
|
'any_1' => array( |
|
48
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Embedded', |
|
49
|
|
|
'name' => 'embedAny_1' |
|
50
|
|
|
), |
|
51
|
|
|
'any_2' => array( |
|
52
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Nested', |
|
53
|
|
|
'nestedName' => 'embedAny_2' |
|
54
|
|
|
) |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
View Code Duplication |
public function testCreateEmbeddedDocument() |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
$embedderMetadata = |
|
61
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
62
|
|
|
|
|
63
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
64
|
|
|
$this->arrayDataFixture, |
|
65
|
|
|
$embedderMetadata->fieldMappings['embedded']); |
|
66
|
|
|
|
|
67
|
|
|
$this->assertNotNull($instance); |
|
68
|
|
|
$this->assertEquals('embedded-1', $instance->name); |
|
69
|
|
|
$this->assertTrue($instance->embeds->containsKey('one')); |
|
70
|
|
|
$this->assertTrue($instance->embeds->containsKey('two')); |
|
71
|
|
|
$this->assertCount(2, $instance->embeds); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testCreateEmbeddedNoTargetDocument() |
|
75
|
|
|
{ |
|
76
|
|
|
$embedderMetadata = |
|
77
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
78
|
|
|
|
|
79
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
80
|
|
|
$this->embedOneFixture, |
|
81
|
|
|
$embedderMetadata->fieldMappings['embedAnyOne']); |
|
82
|
|
|
$this->assertInstanceOf('Doctrine\Tests\ODM\CouchDB\Mapping\Embedded', $instance); |
|
83
|
|
|
$this->assertEquals('embeddedAnyOne', $instance->name); |
|
84
|
|
|
|
|
85
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
86
|
|
|
$this->embedAnyFixture, |
|
87
|
|
|
$embedderMetadata->fieldMappings['embedAny']); |
|
88
|
|
|
$this->assertInstanceOf('Doctrine\Common\Collections\ArrayCollection',$instance); |
|
89
|
|
|
$this->assertCount(2, $instance); |
|
90
|
|
|
$this->assertTrue($instance->containsKey('any_1')); |
|
91
|
|
|
$this->assertTrue($instance->containsKey('any_2')); |
|
92
|
|
|
$this->assertInstanceOf('Doctrine\Tests\ODM\CouchDB\Mapping\Embedded', $instance['any_1']); |
|
93
|
|
|
$this->assertInstanceOf('Doctrine\Tests\ODM\CouchDB\Mapping\Nested', $instance['any_2']); |
|
94
|
|
|
$this->assertEquals('embedAny_1', $instance['any_1']->name); |
|
95
|
|
|
$this->assertEquals('embedAny_2', $instance['any_2']->nestedName); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* If there is no doctrine_metadata inside of an embedded array, classmetadata should help |
|
100
|
|
|
*/ |
|
101
|
|
View Code Duplication |
public function testCreateNoMetadata() |
|
|
|
|
|
|
102
|
|
|
{ |
|
103
|
|
|
unset($this->arrayDataFixture['doctrine_metadata']); |
|
104
|
|
|
|
|
105
|
|
|
$embedderMetadata = |
|
106
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
107
|
|
|
|
|
108
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
109
|
|
|
$this->arrayDataFixture, |
|
110
|
|
|
$embedderMetadata->fieldMappings['embedded']); |
|
111
|
|
|
$this->assertNotNull($instance); |
|
112
|
|
|
$this->assertEquals('embedded-1', $instance->name); |
|
113
|
|
|
$this->assertTrue($instance->embeds->containsKey('one')); |
|
114
|
|
|
$this->assertTrue($instance->embeds->containsKey('two')); |
|
115
|
|
|
$this->assertCount(2, $instance->embeds); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function testCreateThorwsWhenNoTargetNoMetadata() |
|
119
|
|
|
{ |
|
120
|
|
|
$embedderMetadata = |
|
121
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
122
|
|
|
|
|
123
|
|
|
$this->arrayDataFixture['embedAny'] = $this->embedAnyFixture; |
|
124
|
|
|
unset($this->arrayDataFixture['embedAny']['any_2']['doctrine_metadata']); |
|
125
|
|
|
|
|
126
|
|
|
$this->setExpectedException('InvalidArgumentException'); |
|
127
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
|
|
|
|
|
128
|
|
|
$this->arrayDataFixture, |
|
129
|
|
|
$embedderMetadata->fieldMappings['embedAny']); |
|
130
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function testCreateMetadataConflict() |
|
134
|
|
|
{ |
|
135
|
|
|
$embedderMetadata = |
|
136
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
137
|
|
|
|
|
138
|
|
|
$this->arrayDataFixture['embeds']['two']['type'] = 'Doctrine.Tests.ODM.CouchDB.Mapping.Embedded'; |
|
139
|
|
|
$this->setExpectedException('InvalidArgumentException'); |
|
140
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
|
|
|
|
|
141
|
|
|
$this->arrayDataFixture, |
|
142
|
|
|
$embedderMetadata->fieldMappings['embedAny']); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
View Code Duplication |
public function testSerialize() |
|
|
|
|
|
|
146
|
|
|
{ |
|
147
|
|
|
$embedderMetadata = |
|
148
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
149
|
|
|
|
|
150
|
|
|
$embedder = new Embedder; |
|
151
|
|
|
$embedder->id = 'embedder-1'; |
|
152
|
|
|
|
|
153
|
|
|
$embedded = new Embedded; |
|
154
|
|
|
$embedded->name = 'embedded-1'; |
|
155
|
|
|
|
|
156
|
|
|
$nested1 = new Nested; |
|
157
|
|
|
$nested1->nestedName = 'a111'; |
|
158
|
|
|
$embedded->embeds['one'] = $nested1; |
|
159
|
|
|
$nested2 = new Nested; |
|
160
|
|
|
$nested2->nestedName = 'a222'; |
|
161
|
|
|
$embedded->embeds['two'] = $nested2; |
|
162
|
|
|
|
|
163
|
|
|
$embedder->embedded = $embedded; |
|
164
|
|
|
$arrayData = $this->serializer->serializeEmbeddedDocument( |
|
165
|
|
|
$embedded, |
|
166
|
|
|
$embedderMetadata->fieldMappings['embedded']); |
|
167
|
|
|
|
|
168
|
|
|
$this->assertEquals($this->arrayDataFixture, $arrayData); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
View Code Duplication |
public function testSerializeMismatchingTargetDocument() |
|
|
|
|
|
|
172
|
|
|
{ |
|
173
|
|
|
$embedderMetadata = |
|
174
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
175
|
|
|
|
|
176
|
|
|
$embedder = new Embedder; |
|
177
|
|
|
$embedder->id = 'embedder-1'; |
|
178
|
|
|
|
|
179
|
|
|
$embedded = new Embedded; |
|
180
|
|
|
$embedded->name = 'embedded-1'; |
|
181
|
|
|
|
|
182
|
|
|
$nested1 = new Nested; |
|
183
|
|
|
$nested1->nestedName = 'a111'; |
|
184
|
|
|
$embedded->embeds['one'] = $nested1; |
|
185
|
|
|
$nested2 = new Embedded; |
|
186
|
|
|
$nested2->name = 'a222'; |
|
187
|
|
|
$embedded->embeds['two'] = $nested2; |
|
188
|
|
|
|
|
189
|
|
|
$embedder->embedded = $embedded; |
|
190
|
|
|
|
|
191
|
|
|
$this->setExpectedException('InvalidArgumentException'); |
|
192
|
|
|
$arrayData = $this->serializer->serializeEmbeddedDocument( |
|
193
|
|
|
$embedded, |
|
194
|
|
|
$embedderMetadata->fieldMappings['embedded']); |
|
195
|
|
|
|
|
196
|
|
|
$this->assertEquals($this->arrayDataFixture, $arrayData); |
|
197
|
|
|
|
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
public function testSerializeNoTargetDocument() |
|
201
|
|
|
{ |
|
202
|
|
|
$embedder = new Embedder; |
|
203
|
|
|
$embeddedMany_1 = new Embedded; |
|
204
|
|
|
$embeddedMany_1->name = 'embeddedMany_1'; |
|
205
|
|
|
$embeddedMany_2 = new Nested; |
|
206
|
|
|
$embeddedMany_2->nestedName = 'embeddedMany_2'; |
|
207
|
|
|
|
|
208
|
|
|
$embedder->embedAny = array($embeddedMany_1, $embeddedMany_2); |
|
209
|
|
|
|
|
210
|
|
|
$embedOne = new Nested; |
|
211
|
|
|
$embedOne->nestedName = 'embedOne'; |
|
212
|
|
|
$embedder->embedAnyOne = $embedOne; |
|
213
|
|
|
|
|
214
|
|
|
$embedderMetadata = |
|
215
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
216
|
|
|
|
|
217
|
|
|
$arrayData = $this->serializer->serializeEmbeddedDocument( |
|
218
|
|
|
$embedder->embedAny, |
|
|
|
|
|
|
219
|
|
|
$embedderMetadata->fieldMappings['embedAny']); |
|
220
|
|
|
|
|
221
|
|
|
$this->assertEquals( |
|
222
|
|
|
array( |
|
223
|
|
|
array( |
|
224
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Embedded', |
|
225
|
|
|
'name' => 'embeddedMany_1', |
|
226
|
|
|
'embeds' => array(), |
|
227
|
|
|
), |
|
228
|
|
|
array( |
|
229
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Nested', |
|
230
|
|
|
'nestedName' => 'embeddedMany_2' |
|
231
|
|
|
) |
|
232
|
|
|
), |
|
233
|
|
|
$arrayData); |
|
234
|
|
|
|
|
235
|
|
|
$arrayData = $this->serializer->serializeEmbeddedDocument( |
|
236
|
|
|
$embedder->embedAnyOne, |
|
237
|
|
|
$embedderMetadata->fieldMappings['embedAnyOne']); |
|
238
|
|
|
$this->assertEquals( |
|
239
|
|
|
array( |
|
240
|
|
|
'type' => 'Doctrine.Tests.ODM.CouchDB.Mapping.Nested', |
|
241
|
|
|
'nestedName' => 'embedOne' |
|
242
|
|
|
), |
|
243
|
|
|
$arrayData); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
public function testIsChanged() |
|
247
|
|
|
{ |
|
248
|
|
|
$embedderMetadata = |
|
249
|
|
|
$this->metadataFactory->getMetadataFor('Doctrine\Tests\ODM\CouchDB\Mapping\Embedder'); |
|
250
|
|
|
|
|
251
|
|
|
$fieldMapping = $embedderMetadata->fieldMappings['embedded']; |
|
252
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
253
|
|
|
$this->arrayDataFixture, |
|
254
|
|
|
$fieldMapping); |
|
255
|
|
|
|
|
256
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
$name = $instance->name; |
|
259
|
|
|
$instance->name = 'changed'; |
|
260
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
261
|
|
|
$instance->name = $name; |
|
262
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
263
|
|
|
|
|
264
|
|
|
|
|
265
|
|
|
$nestedName = $instance->embeds['one']->nestedName; |
|
266
|
|
|
$instance->embeds['one']->nestedName = 'changed'; |
|
267
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
268
|
|
|
$instance->embeds['one']->nestedName = $nestedName; |
|
269
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
270
|
|
|
|
|
271
|
|
|
// testing same data representation but different class |
|
272
|
|
|
$newNested = new Nested2; |
|
273
|
|
|
$newNested->nestedName = $nestedName; |
|
274
|
|
|
$instance->embeds['one'] = $newNested; |
|
275
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
276
|
|
|
|
|
277
|
|
|
$newNested = new Nested; |
|
278
|
|
|
$newNested->nestedName = $nestedName; |
|
279
|
|
|
$instance->embeds['one'] = $newNested; |
|
280
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
281
|
|
|
|
|
282
|
|
|
// testing that to null a property is a change |
|
283
|
|
|
$instance->embeds['one']->nestedName = null; |
|
284
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
285
|
|
|
|
|
286
|
|
|
$instance->embeds['one']->nestedName = $nestedName; |
|
287
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
288
|
|
|
|
|
289
|
|
|
// adding a new value is a change |
|
290
|
|
|
$instance->embeds['three'] = new Nested; |
|
291
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
292
|
|
|
unset($instance->embeds['three']); |
|
293
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
294
|
|
|
|
|
295
|
|
|
// removing one is a change |
|
296
|
|
|
unset($instance->embeds['two']); |
|
297
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
298
|
|
|
|
|
299
|
|
|
// same number of embeds, but different key |
|
300
|
|
|
$instance->embeds['1'] = new Nested; |
|
301
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
302
|
|
|
|
|
303
|
|
|
|
|
304
|
|
|
// ----------------------------------------------------------------------------- |
|
305
|
|
|
// reset things |
|
306
|
|
|
// ----------------------------------------------------------------------------- |
|
307
|
|
|
$instance = $this->serializer->createEmbeddedDocument( |
|
308
|
|
|
$this->arrayDataFixture, |
|
309
|
|
|
$embedderMetadata->fieldMappings['embedded']); |
|
310
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
311
|
|
|
|
|
312
|
|
|
|
|
313
|
|
|
// adding an EmbedOne type of embedded document |
|
314
|
|
|
// also tesing the no targetDocument case |
|
315
|
|
|
$instance->embedOne = new Nested; |
|
316
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $this->arrayDataFixture, $fieldMapping)); |
|
|
|
|
|
|
317
|
|
|
|
|
318
|
|
|
$fixture = $this->arrayDataFixture; |
|
319
|
|
|
$fixture['embedOne'] = array('doctrine_metadata'=>array('type'=>'Doctrine.Tests.ODM.CouchDB.Mapping.Nested')); |
|
320
|
|
|
$this->assertFalse($this->serializer->isChanged($instance, $fixture, $fieldMapping)); |
|
|
|
|
|
|
321
|
|
|
|
|
322
|
|
|
$instance->embedOne->nestedName = 'so this is nested'; |
|
323
|
|
|
$this->assertTrue($this->serializer->isChanged($instance, $fixture, $fieldMapping)); |
|
|
|
|
|
|
324
|
|
|
} |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
|
|
328
|
|
|
|
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* @Document |
|
332
|
|
|
*/ |
|
333
|
|
|
class Embedder { |
|
334
|
|
|
/** |
|
335
|
|
|
* @Id(strategy="ASSIGNED") |
|
336
|
|
|
*/ |
|
337
|
|
|
public $id; |
|
338
|
|
|
|
|
339
|
|
|
/** |
|
340
|
|
|
* @EmbedOne(targetDocument="Doctrine\Tests\ODM\CouchDB\Mapping\Embedded") |
|
341
|
|
|
*/ |
|
342
|
|
|
public $embedded; |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* @EmbedOne |
|
346
|
|
|
*/ |
|
347
|
|
|
public $embedAnyOne; |
|
348
|
|
|
|
|
349
|
|
|
/** |
|
350
|
|
|
* @EmbedMany |
|
351
|
|
|
*/ |
|
352
|
|
|
public $embedAny = array(); |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @EmbeddedDocument |
|
357
|
|
|
*/ |
|
358
|
|
|
class Embedded { |
|
359
|
|
|
/** |
|
360
|
|
|
* @Field |
|
361
|
|
|
*/ |
|
362
|
|
|
public $name; |
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* @EmbedMany(targetDocument="Doctrine\Tests\ODM\CouchDB\Mapping\Nested") |
|
366
|
|
|
*/ |
|
367
|
|
|
public $embeds = array(); |
|
368
|
|
|
|
|
369
|
|
|
/** |
|
370
|
|
|
* @EmbedOne |
|
371
|
|
|
*/ |
|
372
|
|
|
public $embedOne; |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
/** |
|
376
|
|
|
* @EmbeddedDocument |
|
377
|
|
|
*/ |
|
378
|
|
|
class Nested { |
|
379
|
|
|
/** |
|
380
|
|
|
* @Field |
|
381
|
|
|
*/ |
|
382
|
|
|
public $nestedName; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
/** |
|
386
|
|
|
* @EmbeddedDocument |
|
387
|
|
|
*/ |
|
388
|
|
|
class Nested2 extends Nested { |
|
389
|
|
|
/** |
|
390
|
|
|
* @Field |
|
391
|
|
|
*/ |
|
392
|
|
|
public $nestedName; |
|
393
|
|
|
} |
|
394
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: