9
9
10
10
namespace JsonSchema \Constraints ;
11
11
12
+ use JsonSchema \Uri \UriResolver ;
13
+
12
14
/**
13
15
* The Undefined Constraints
14
16
*
@@ -30,10 +32,10 @@ public function check($value, $schema = null, $path = null, $i = null)
30
32
$ path = $ this ->incrementPath ($ path , $ i );
31
33
32
34
// check special properties
33
- $ this ->validateCommonProperties ($ value , $ schema , $ path, $ i );
35
+ $ this ->validateCommonProperties ($ value , $ schema , $ path );
34
36
35
37
// check allOf, anyOf, and oneOf properties
36
- $ this ->validateOfProperties ($ value , $ schema , $ path, $ i );
38
+ $ this ->validateOfProperties ($ value , $ schema , $ path );
37
39
38
40
// check known types
39
41
$ this ->validateTypes ($ value , $ schema , $ path , $ i );
@@ -89,7 +91,7 @@ public function validateTypes($value, $schema = null, $path = null, $i = null)
89
91
* @param string $path
90
92
* @param string $i
91
93
*/
92
- protected function validateCommonProperties ($ value , $ schema = null , $ path = null , $ i = null )
94
+ protected function validateCommonProperties ($ value , $ schema = null , $ path = null , $ i = "" )
93
95
{
94
96
// if it extends another schema, it must pass that schema as well
95
97
if (isset ($ schema ->extends )) {
@@ -120,10 +122,10 @@ protected function validateCommonProperties($value, $schema = null, $path = null
120
122
}
121
123
}
122
124
} else {
123
- $ this ->checkType ($ value , $ schema , $ path, $ i );
125
+ $ this ->checkType ($ value , $ schema , $ path );
124
126
}
125
127
} else {
126
- $ this ->checkType ($ value , $ schema , $ path, $ i );
128
+ $ this ->checkType ($ value , $ schema , $ path );
127
129
}
128
130
129
131
// Verify disallowed items
@@ -132,7 +134,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null
132
134
133
135
$ typeSchema = new \stdClass ();
134
136
$ typeSchema ->type = $ schema ->disallow ;
135
- $ this ->checkType ($ value , $ typeSchema , $ path, $ i );
137
+ $ this ->checkType ($ value , $ typeSchema , $ path );
136
138
137
139
// if no new errors were raised it must be a disallowed value
138
140
if (count ($ this ->getErrors ()) == count ($ initErrors )) {
@@ -170,7 +172,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null
170
172
171
173
// Verify that dependencies are met
172
174
if (is_object ($ value ) && isset ($ schema ->dependencies )) {
173
- $ this ->validateDependencies ($ value , $ schema ->dependencies , $ path, $ i );
175
+ $ this ->validateDependencies ($ value , $ schema ->dependencies , $ path );
174
176
}
175
177
}
176
178
@@ -182,7 +184,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null
182
184
* @param string $path
183
185
* @param string $i
184
186
*/
185
- protected function validateOfProperties ($ value , $ schema , $ path , $ i )
187
+ protected function validateOfProperties ($ value , $ schema , $ path , $ i = "" )
186
188
{
187
189
if (isset ($ schema ->allOf )) {
188
190
$ isValid = true ;
@@ -239,7 +241,7 @@ protected function validateOfProperties($value, $schema, $path, $i)
239
241
* @param string $path
240
242
* @param string $i
241
243
*/
242
- protected function validateDependencies ($ value , $ dependencies , $ path , $ i )
244
+ protected function validateDependencies ($ value , $ dependencies , $ path , $ i = "" )
243
245
{
244
246
foreach ($ dependencies as $ key => $ dependency ) {
245
247
if (property_exists ($ value , $ key )) {
@@ -265,14 +267,15 @@ protected function validateDependencies($value, $dependencies, $path, $i)
265
267
266
268
protected function validateUri ($ schema , $ schemaUri = null )
267
269
{
268
- $ resolver = new \ JsonSchema \ Uri \ UriResolver ();
270
+ $ resolver = new UriResolver ();
269
271
$ retriever = $ this ->getUriRetriever ();
270
272
273
+ $ jsonSchema = null ;
271
274
if ($ resolver ->isValid ($ schemaUri )) {
272
275
$ schemaId = property_exists ($ schema , 'id ' ) ? $ schema ->id : null ;
273
276
$ jsonSchema = $ retriever ->retrieve ($ schemaId , $ schemaUri );
274
-
275
- return $ jsonSchema ;
276
277
}
278
+
279
+ return $ jsonSchema ;
277
280
}
278
281
}
0 commit comments