99
1010namespace JsonSchema \Constraints ;
1111
12+ use JsonSchema \Uri \UriResolver ;
13+
1214/**
1315 * The Undefined Constraints
1416 *
@@ -30,10 +32,10 @@ public function check($value, $schema = null, $path = null, $i = null)
3032 $ path = $ this ->incrementPath ($ path , $ i );
3133
3234 // check special properties
33- $ this ->validateCommonProperties ($ value , $ schema , $ path, $ i );
35+ $ this ->validateCommonProperties ($ value , $ schema , $ path );
3436
3537 // check allOf, anyOf, and oneOf properties
36- $ this ->validateOfProperties ($ value , $ schema , $ path, $ i );
38+ $ this ->validateOfProperties ($ value , $ schema , $ path );
3739
3840 // check known types
3941 $ this ->validateTypes ($ value , $ schema , $ path , $ i );
@@ -89,7 +91,7 @@ public function validateTypes($value, $schema = null, $path = null, $i = null)
8991 * @param string $path
9092 * @param string $i
9193 */
92- protected function validateCommonProperties ($ value , $ schema = null , $ path = null , $ i = null )
94+ protected function validateCommonProperties ($ value , $ schema = null , $ path = null , $ i = "" )
9395 {
9496 // if it extends another schema, it must pass that schema as well
9597 if (isset ($ schema ->extends )) {
@@ -120,10 +122,10 @@ protected function validateCommonProperties($value, $schema = null, $path = null
120122 }
121123 }
122124 } else {
123- $ this ->checkType ($ value , $ schema , $ path, $ i );
125+ $ this ->checkType ($ value , $ schema , $ path );
124126 }
125127 } else {
126- $ this ->checkType ($ value , $ schema , $ path, $ i );
128+ $ this ->checkType ($ value , $ schema , $ path );
127129 }
128130
129131 // Verify disallowed items
@@ -132,7 +134,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null
132134
133135 $ typeSchema = new \stdClass ();
134136 $ typeSchema ->type = $ schema ->disallow ;
135- $ this ->checkType ($ value , $ typeSchema , $ path, $ i );
137+ $ this ->checkType ($ value , $ typeSchema , $ path );
136138
137139 // if no new errors were raised it must be a disallowed value
138140 if (count ($ this ->getErrors ()) == count ($ initErrors )) {
@@ -170,7 +172,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null
170172
171173 // Verify that dependencies are met
172174 if (is_object ($ value ) && isset ($ schema ->dependencies )) {
173- $ this ->validateDependencies ($ value , $ schema ->dependencies , $ path, $ i );
175+ $ this ->validateDependencies ($ value , $ schema ->dependencies , $ path );
174176 }
175177 }
176178
@@ -182,7 +184,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null
182184 * @param string $path
183185 * @param string $i
184186 */
185- protected function validateOfProperties ($ value , $ schema , $ path , $ i )
187+ protected function validateOfProperties ($ value , $ schema , $ path , $ i = "" )
186188 {
187189 if (isset ($ schema ->allOf )) {
188190 $ isValid = true ;
@@ -239,7 +241,7 @@ protected function validateOfProperties($value, $schema, $path, $i)
239241 * @param string $path
240242 * @param string $i
241243 */
242- protected function validateDependencies ($ value , $ dependencies , $ path , $ i )
244+ protected function validateDependencies ($ value , $ dependencies , $ path , $ i = "" )
243245 {
244246 foreach ($ dependencies as $ key => $ dependency ) {
245247 if (property_exists ($ value , $ key )) {
@@ -265,14 +267,15 @@ protected function validateDependencies($value, $dependencies, $path, $i)
265267
266268 protected function validateUri ($ schema , $ schemaUri = null )
267269 {
268- $ resolver = new \ JsonSchema \ Uri \ UriResolver ();
270+ $ resolver = new UriResolver ();
269271 $ retriever = $ this ->getUriRetriever ();
270272
273+ $ jsonSchema = null ;
271274 if ($ resolver ->isValid ($ schemaUri )) {
272275 $ schemaId = property_exists ($ schema , 'id ' ) ? $ schema ->id : null ;
273276 $ jsonSchema = $ retriever ->retrieve ($ schemaId , $ schemaUri );
274-
275- return $ jsonSchema ;
276277 }
278+
279+ return $ jsonSchema ;
277280 }
278281}
0 commit comments