@@ -75,18 +75,28 @@ public function __construct(array $data)
7575 }
7676 switch (\count ($ type )) {
7777 case 1 :
78- // array
79- $ this ->_properties [$ property ] = [];
80- foreach ($ data [$ property ] as $ item ) {
81- if ($ type [0 ] === Type::STRING ) {
82- if (!is_string ($ item )) {
83- $ this ->_errors [] = "property ' $ property' must be array of strings, but array has " . gettype ($ item ) . " element. " ;
78+ if (isset ($ data [$ property ]['$ref ' ])) {
79+ $ this ->_properties [$ property ] = new Reference ($ data [$ property ], null );
80+ } else {
81+ // array
82+ $ this ->_properties [$ property ] = [];
83+ foreach ($ data [$ property ] as $ item ) {
84+ if ($ type [0 ] === Type::STRING ) {
85+ if (!is_string ($ item )) {
86+ $ this ->_errors [] = "property ' $ property' must be array of strings, but array has " . gettype ($ item ) . " element. " ;
87+ }
88+ $ this ->_properties [$ property ][] = $ item ;
89+ } elseif (Type::isScalar ($ type [0 ])) {
90+ $ this ->_properties [$ property ][] = $ item ;
91+ } elseif ($ type [0 ] === Type::ANY ) {
92+ if (is_array ($ item ) && isset ($ item ['$ref ' ])) {
93+ $ this ->_properties [$ property ][] = new Reference ($ item , null );
94+ } else {
95+ $ this ->_properties [$ property ][] = $ item ;
96+ }
97+ } else {
98+ $ this ->_properties [$ property ][] = $ this ->instantiate ($ type [0 ], $ item );
8499 }
85- $ this ->_properties [$ property ][] = $ item ;
86- } elseif ($ type [0 ] === Type::ANY || Type::isScalar ($ type [0 ])) {
87- $ this ->_properties [$ property ][] = $ item ;
88- } else {
89- $ this ->_properties [$ property ][] = $ this ->instantiate ($ type [0 ], $ item );
90100 }
91101 }
92102 break ;
@@ -110,8 +120,14 @@ public function __construct(array $data)
110120 }
111121 break ;
112122 }
113- } elseif ($ type === Type:: ANY || Type::isScalar ($ type )) {
123+ } elseif (Type::isScalar ($ type )) {
114124 $ this ->_properties [$ property ] = $ data [$ property ];
125+ } elseif ($ type === Type::ANY ) {
126+ if (is_array ($ data [$ property ]) && isset ($ data [$ property ]['$ref ' ])) {
127+ $ this ->_properties [$ property ] = new Reference ($ data [$ property ], null );
128+ } else {
129+ $ this ->_properties [$ property ] = $ data [$ property ];
130+ }
115131 } else {
116132 $ this ->_properties [$ property ] = $ this ->instantiate ($ type , $ data [$ property ]);
117133 }
@@ -353,7 +369,7 @@ public function resolveReferences(ReferenceContext $context = null)
353369 if ($ value instanceof Reference) {
354370 $ referencedObject = $ value ->resolve ($ context );
355371 $ this ->_properties [$ property ] = $ referencedObject ;
356- if (!$ referencedObject instanceof Reference && $ referencedObject !== null ) {
372+ if (!$ referencedObject instanceof Reference && $ referencedObject instanceof SpecObjectInterface ) {
357373 $ referencedObject ->resolveReferences ();
358374 }
359375 } elseif ($ value instanceof SpecObjectInterface) {
@@ -363,7 +379,7 @@ public function resolveReferences(ReferenceContext $context = null)
363379 if ($ item instanceof Reference) {
364380 $ referencedObject = $ item ->resolve ($ context );
365381 $ this ->_properties [$ property ][$ k ] = $ referencedObject ;
366- if (!$ referencedObject instanceof Reference && $ referencedObject !== null ) {
382+ if (!$ referencedObject instanceof Reference && $ referencedObject instanceof SpecObjectInterface ) {
367383 $ referencedObject ->resolveReferences ();
368384 }
369385 } elseif ($ item instanceof SpecObjectInterface) {
0 commit comments