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