@@ -168,7 +168,7 @@ private function extractFromConstraints(array $constraints)
168
168
foreach ($ constraints as $ constraint ) {
169
169
$ ref = new \ReflectionClass ($ constraint );
170
170
$ defaultValues = $ ref ->getDefaultProperties ();
171
-
171
+ $ defaultParameters = null !== $ ref -> getConstructor () ? $ ref -> getConstructor ()-> getParameters () : [];
172
172
$ properties = $ ref ->getProperties ();
173
173
174
174
foreach ($ properties as $ property ) {
@@ -177,9 +177,18 @@ private function extractFromConstraints(array $constraints)
177
177
// If the property ends with 'Message'
178
178
if (strtolower (substr ($ propName , -1 * strlen ('Message ' ))) === 'message ' ) {
179
179
// If it is different from the default value
180
- if ($ defaultValues [$ propName ] !== $ constraint ->{$ propName }) {
180
+ if (array_key_exists ( $ propName , $ defaultValues ) && $ defaultValues [$ propName ] !== $ constraint ->{$ propName }) {
181
181
$ message = new Message ($ constraint ->{$ propName }, 'validators ' );
182
182
$ this ->catalogue ->add ($ message );
183
+ } elseif (method_exists ($ property , 'isPromoted ' ) && $ property ->isPromoted ()) {
184
+ foreach ($ defaultParameters as $ defaultParameter ) {
185
+ if ($ defaultParameter ->getName () === $ propName && $ defaultParameter ->isDefaultValueAvailable () && $ defaultParameter ->getDefaultValue () !== $ constraint ->{$ propName }) {
186
+ $ message = new Message ($ constraint ->{$ propName }, 'validators ' );
187
+ $ this ->catalogue ->add ($ message );
188
+
189
+ break ;
190
+ }
191
+ }
183
192
}
184
193
}
185
194
}
0 commit comments