@@ -28,7 +28,8 @@ class ObjectConstraint extends Constraint
28
28
/**
29
29
* {@inheritdoc}
30
30
*/
31
- public function check (&$ element , $ definition = null , JsonPointer $ path = null , $ additionalProp = null , $ patternProperties = null , $ appliedDefaults = array ())
31
+ public function check (&$ element , $ schema = null , JsonPointer $ path = null , $ properties = null ,
32
+ $ additionalProp = null , $ patternProperties = null , $ appliedDefaults = array ())
32
33
{
33
34
if ($ element instanceof UndefinedConstraint) {
34
35
return ;
@@ -38,16 +39,17 @@ public function check(&$element, $definition = null, JsonPointer $path = null, $
38
39
39
40
$ matches = array ();
40
41
if ($ patternProperties ) {
42
+ // validate the element pattern properties
41
43
$ matches = $ this ->validatePatternProperties ($ element , $ path , $ patternProperties );
42
44
}
43
45
44
- if ($ definition ) {
45
- // validate the definition properties
46
- $ this ->validateDefinition ($ element , $ definition , $ path );
46
+ if ($ properties ) {
47
+ // validate the element properties
48
+ $ this ->validateProperties ($ element , $ properties , $ path );
47
49
}
48
50
49
- // additional the element properties
50
- $ this ->validateElement ($ element , $ matches , $ definition , $ path , $ additionalProp );
51
+ // validate additional element properties & constraints
52
+ $ this ->validateElement ($ element , $ matches , $ schema , $ path, $ properties , $ additionalProp );
51
53
}
52
54
53
55
public function validatePatternProperties ($ element , JsonPointer $ path = null , $ patternProperties )
@@ -82,18 +84,20 @@ public function validatePatternProperties($element, JsonPointer $path = null, $p
82
84
/**
83
85
* Validates the element properties
84
86
*
85
- * @param \stdClass $element Element to validate
86
- * @param array $matches Matches from patternProperties (if any)
87
- * @param \stdClass $objectDefinition ObjectConstraint definition
88
- * @param JsonPointer|null $path Path to test?
89
- * @param mixed $additionalProp Additional properties
87
+ * @param \StdClass $element Element to validate
88
+ * @param array $matches Matches from patternProperties (if any)
89
+ * @param \StdClass $schema ObjectConstraint definition
90
+ * @param JsonPointer|null $path Current test path
91
+ * @param \StdClass $properties Properties
92
+ * @param mixed $additionalProp Additional properties
90
93
*/
91
- public function validateElement ($ element , $ matches , $ objectDefinition = null , JsonPointer $ path = null , $ additionalProp = null )
94
+ public function validateElement ($ element , $ matches , $ schema = null , JsonPointer $ path = null ,
95
+ $ properties = null , $ additionalProp = null )
92
96
{
93
- $ this ->validateMinMaxConstraint ($ element , $ objectDefinition , $ path );
97
+ $ this ->validateMinMaxConstraint ($ element , $ schema , $ path );
94
98
95
99
foreach ($ element as $ i => $ value ) {
96
- $ definition = $ this ->getProperty ($ objectDefinition , $ i );
100
+ $ definition = $ this ->getProperty ($ properties , $ i );
97
101
98
102
// no additional properties allowed
99
103
if (!in_array ($ i , $ matches ) && $ additionalProp === false && $ this ->inlineSchemaProperty !== $ i && !$ definition ) {
@@ -128,17 +132,17 @@ public function validateElement($element, $matches, $objectDefinition = null, Js
128
132
/**
129
133
* Validates the definition properties
130
134
*
131
- * @param \stdClass $element Element to validate
132
- * @param \stdClass $objectDefinition ObjectConstraint definition
133
- * @param JsonPointer|null $path Path?
135
+ * @param \stdClass $element Element to validate
136
+ * @param \stdClass $properties Property definitions
137
+ * @param JsonPointer|null $path Path?
134
138
*/
135
- public function validateDefinition (&$ element , $ objectDefinition = null , JsonPointer $ path = null )
139
+ public function validateProperties (&$ element , $ properties = null , JsonPointer $ path = null )
136
140
{
137
141
$ undefinedConstraint = $ this ->factory ->createInstanceFor ('undefined ' );
138
142
139
- foreach ($ objectDefinition as $ i => $ value ) {
143
+ foreach ($ properties as $ i => $ value ) {
140
144
$ property = &$ this ->getProperty ($ element , $ i , $ undefinedConstraint );
141
- $ definition = $ this ->getProperty ($ objectDefinition , $ i );
145
+ $ definition = $ this ->getProperty ($ properties , $ i );
142
146
143
147
if (is_object ($ definition )) {
144
148
// Undefined constraint will check for is_object() and quit if is not - so why pass it?
0 commit comments