@@ -73,6 +73,11 @@ public function __construct(array $data)
73
73
$ this ->_errors [] = "property ' $ property' must be array, but " . gettype ($ data [$ property ]) . " given. " ;
74
74
continue ;
75
75
}
76
+ if (isset ($ data [$ property ]['$ref ' ])) {
77
+ $ this ->_properties [$ property ] = new Reference ($ data [$ property ], null );
78
+ unset($ data [$ property ]);
79
+ continue ;
80
+ }
76
81
switch (\count ($ type )) {
77
82
case 1 :
78
83
// array
@@ -83,8 +88,14 @@ public function __construct(array $data)
83
88
$ this ->_errors [] = "property ' $ property' must be array of strings, but array has " . gettype ($ item ) . " element. " ;
84
89
}
85
90
$ this ->_properties [$ property ][] = $ item ;
86
- } elseif ($ type [ 0 ] === Type:: ANY || Type::isScalar ($ type [0 ])) {
91
+ } elseif (Type::isScalar ($ type [0 ])) {
87
92
$ this ->_properties [$ property ][] = $ item ;
93
+ } elseif ($ type [0 ] === Type::ANY ) {
94
+ if (is_array ($ item ) && isset ($ item ['$ref ' ])) {
95
+ $ this ->_properties [$ property ][] = new Reference ($ item , null );
96
+ } else {
97
+ $ this ->_properties [$ property ][] = $ item ;
98
+ }
88
99
} else {
89
100
$ this ->_properties [$ property ][] = $ this ->instantiate ($ type [0 ], $ item );
90
101
}
@@ -110,8 +121,14 @@ public function __construct(array $data)
110
121
}
111
122
break ;
112
123
}
113
- } elseif ($ type === Type:: ANY || Type::isScalar ($ type )) {
124
+ } elseif (Type::isScalar ($ type )) {
114
125
$ this ->_properties [$ property ] = $ data [$ property ];
126
+ } elseif ($ type === Type::ANY ) {
127
+ if (is_array ($ data [$ property ]) && isset ($ data [$ property ]['$ref ' ])) {
128
+ $ this ->_properties [$ property ] = new Reference ($ data [$ property ], null );
129
+ } else {
130
+ $ this ->_properties [$ property ] = $ data [$ property ];
131
+ }
115
132
} else {
116
133
$ this ->_properties [$ property ] = $ this ->instantiate ($ type , $ data [$ property ]);
117
134
}
@@ -353,7 +370,7 @@ public function resolveReferences(ReferenceContext $context = null)
353
370
if ($ value instanceof Reference) {
354
371
$ referencedObject = $ value ->resolve ($ context );
355
372
$ this ->_properties [$ property ] = $ referencedObject ;
356
- if (!$ referencedObject instanceof Reference && $ referencedObject !== null ) {
373
+ if (!$ referencedObject instanceof Reference && $ referencedObject instanceof SpecObjectInterface ) {
357
374
$ referencedObject ->resolveReferences ();
358
375
}
359
376
} elseif ($ value instanceof SpecObjectInterface) {
@@ -363,7 +380,7 @@ public function resolveReferences(ReferenceContext $context = null)
363
380
if ($ item instanceof Reference) {
364
381
$ referencedObject = $ item ->resolve ($ context );
365
382
$ this ->_properties [$ property ][$ k ] = $ referencedObject ;
366
- if (!$ referencedObject instanceof Reference && $ referencedObject !== null ) {
383
+ if (!$ referencedObject instanceof Reference && $ referencedObject instanceof SpecObjectInterface ) {
367
384
$ referencedObject ->resolveReferences ();
368
385
}
369
386
} elseif ($ item instanceof SpecObjectInterface) {
0 commit comments