File tree Expand file tree Collapse file tree 5 files changed +17
-13
lines changed Expand file tree Collapse file tree 5 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ CHANGELOG
96
96
3.2.0
97
97
-----
98
98
99
- * deprecated ` Tests\Constraints\AbstractContraintValidatorTest ` in favor of ` Test\ConstraintValidatorTestCase `
99
+ * deprecated ` Tests\Constraints\AbstractConstraintValidatorTest ` in favor of ` Test\ConstraintValidatorTestCase `
100
100
* added support for PHP constants in YAML configuration files
101
101
102
102
3.1.0
Original file line number Diff line number Diff line change 25
25
*
26
26
* Constraint instances are immutable and serializable.
27
27
*
28
- * @property string[] $groups The groups that the constraint belongs to
29
- *
30
28
* @author Bernhard Schussek <[email protected] >
31
29
*/
32
30
abstract class Constraint
@@ -58,6 +56,13 @@ abstract class Constraint
58
56
*/
59
57
public $ payload ;
60
58
59
+ /**
60
+ * The groups that the constraint belongs to.
61
+ *
62
+ * @var string[]
63
+ */
64
+ public $ groups ;
65
+
61
66
/**
62
67
* Returns the name of the given error code.
63
68
*
@@ -105,14 +110,13 @@ public static function getErrorName($errorCode)
105
110
*/
106
111
public function __construct ($ options = null )
107
112
{
113
+ unset($ this ->groups ); // enable lazy initialization
114
+
108
115
$ defaultOption = $ this ->getDefaultOption ();
109
116
$ invalidOptions = [];
110
117
$ missingOptions = array_flip ((array ) $ this ->getRequiredOptions ());
111
118
$ knownOptions = get_class_vars (static ::class);
112
119
113
- // The "groups" option is added to the object lazily
114
- $ knownOptions ['groups ' ] = true ;
115
-
116
120
if (\is_array ($ options ) && isset ($ options ['value ' ]) && !property_exists ($ this , 'value ' )) {
117
121
if (null === $ defaultOption ) {
118
122
throw new ConstraintDefinitionException (sprintf ('No default option is configured for constraint "%s". ' , static ::class));
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function __construct($options = null)
79
79
}
80
80
}
81
81
82
- if (!property_exists ( $ this , 'groups ' )) {
82
+ if (!isset ((( array ) $ this )[ 'groups ' ] )) {
83
83
$ mergedGroups = [];
84
84
85
85
foreach ($ nestedConstraints as $ constraint ) {
@@ -96,7 +96,7 @@ public function __construct($options = null)
96
96
}
97
97
98
98
foreach ($ nestedConstraints as $ constraint ) {
99
- if (property_exists ( $ constraint, 'groups ' )) {
99
+ if (isset ((( array ) $ constraint)[ 'groups ' ] )) {
100
100
$ excessGroups = array_diff ($ constraint ->groups , $ this ->groups );
101
101
102
102
if (\count ($ excessGroups ) > 0 ) {
@@ -141,7 +141,7 @@ abstract protected function getCompositeOption();
141
141
*
142
142
* @return Constraint[]
143
143
*/
144
- public function getNestedContraints ()
144
+ public function getNestedConstraints ()
145
145
{
146
146
/* @var Constraint[] $nestedConstraints */
147
147
return $ this ->{$ this ->getCompositeOption ()};
Original file line number Diff line number Diff line change @@ -490,8 +490,8 @@ private function checkConstraint(Constraint $constraint)
490
490
}
491
491
492
492
if ($ constraint instanceof Composite) {
493
- foreach ($ constraint ->getNestedContraints () as $ nestedContraint ) {
494
- $ this ->checkConstraint ($ nestedContraint );
493
+ foreach ($ constraint ->getNestedConstraints () as $ nestedConstraint ) {
494
+ $ this ->checkConstraint ($ nestedConstraint );
495
495
}
496
496
}
497
497
}
Original file line number Diff line number Diff line change @@ -188,8 +188,8 @@ private function checkConstraint(Constraint $constraint)
188
188
}
189
189
190
190
if ($ constraint instanceof Composite) {
191
- foreach ($ constraint ->getNestedContraints () as $ nestedContraint ) {
192
- $ this ->checkConstraint ($ nestedContraint );
191
+ foreach ($ constraint ->getNestedConstraints () as $ nestedConstraint ) {
192
+ $ this ->checkConstraint ($ nestedConstraint );
193
193
}
194
194
}
195
195
}
You can’t perform that action at this time.
0 commit comments