19
19
use PHPUnit \Framework \ExpectationFailedException ;
20
20
use PHPUnit \Framework \TestCase ;
21
21
use Symfony \Component \Validator \Constraint ;
22
+ use Symfony \Component \Validator \Constraints \GroupSequence ;
22
23
use Symfony \Component \Validator \Constraints \NotNull ;
23
24
use Symfony \Component \Validator \Constraints \Valid ;
24
25
use Symfony<
F438
/span>\Component \Validator \ConstraintValidatorInterface ;
@@ -168,13 +169,13 @@ protected function createContext()
168
169
return $ context ;
169
170
}
170
171
171
- protected function setGroup ($ group )
172
+ protected function setGroup (? string $ group )
172
173
{
173
174
$ this ->group = $ group ;
174
175
$ this ->context ->setGroup ($ group );
175
176
}
176
177
177
- protected function setObject ($ object )
178
+ protected function setObject (mixed $ object )
178
179
{
179
180
$ this ->object = $ object ;
180
181
$ this ->metadata = \is_object ($ object )
@@ -184,7 +185,7 @@ protected function setObject($object)
184
185
$ this ->context ->setNode ($ this ->value , $ this ->object , $ this ->metadata , $ this ->propertyPath );
185
186
}
186
187
187
- protected function setProperty ($ object , $ property )
188
+ protected function setProperty (mixed $ object , string $ property )
188
189
{
189
190
$ this ->object = $ object ;
190
191
$ this ->metadata = \is_object ($ object )
@@ -194,20 +195,20 @@ protected function setProperty($object, $property)
194
195
$ this ->context ->setNode ($ this ->value , $ this ->object , $ this ->metadata , $ this ->propertyPath );
195
196
}
196
197
197
- protected function setValue ($ value )
198
+ protected function setValue (mixed $ value )
198
199
{
199
200
$ this ->value = $ value ;
200
201
$ this ->context ->setNode ($ this ->value , $ this ->object , $ this ->metadata , $ this ->propertyPath );
201
202
}
202
203
203
- protected function setRoot ($ root )
204
+ protected function setRoot (mixed $ root )
204
205
{
205
206
$ this ->root = $ root ;
206
207
$ this ->context = $ this ->createContext ();
207
208
$ this ->validator ->initialize ($ this -&g
10000
t;context );
208
209
}
209
210
210
- protected function setPropertyPath ($ propertyPath )
211
+ protected function setPropertyPath (string $ propertyPath )
211
212
{
212
213
$ this ->propertyPath = $ propertyPath ;
213
214
$ this ->context ->setNode ($ this ->value , $ this ->object , $ this ->metadata , $ this ->propertyPath );
@@ -219,7 +220,7 @@ protected function expectNoValidate()
219
220
$ validator ->expectNoValidate ();
220
221
}
221
222
222
- protected function expectValidateAt ($ i , $ propertyPath , $ value , $ group )
223
+ protected function expectValidateAt (int $ i , string $ propertyPath , mixed $ value , string | GroupSequence | array | null $ group )
223
224
{
224
225
$ validator = $ this ->context ->getValidator ()->inContext ($ this ->context );
225
226
$ validator ->expectValidation ($ i , $ propertyPath , $ value , $ group , function ($ passedConstraints ) {
@@ -230,7 +231,7 @@ protected function expectValidateAt($i, $propertyPath, $value, $group)
230
231
});
231
232
}
232
233
233
- protected function expectValidateValue (int $ i , $ value , array $ constraints = [], $ group = null )
234
+ protected function expectValidateValue (int $ i , mixed $ value , Constraint | array $ constraints = [], string | GroupSequence | array | null $ group = null )
234
235
{
235
236
$ contextualValidator = $ this ->context ->getValidator ()->inContext ($ this ->context );
236
237
$ contextualValidator ->expectValidation ($ i , '' , $ value , $ group , function ($ passedConstraints ) use ($ constraints ) {
@@ -242,7 +243,7 @@ protected function expectValidateValue(int $i, $value, array $constraints = [],
242
243
});
243
244
}
244
245
245
- protected function expectFailingValueValidation (int $ i , $ value , array $ constraints , $ group , ConstraintViolationInterface $ violation )
246
+ protected function expectFailingValueValidation (int $ i , mixed $ value , Constraint | array $ constraints , string | GroupSequence | array | null $ group , ConstraintViolationInterface $ violation )
246
247
{
247
248
$ contextualValidator = $ this ->context ->getValidator ()->inContext ($ this ->context );
248
249
$ contextualValidator ->expectValidation ($ i , '' , $ value , $ group , function ($ passedConstraints ) use ($ constraints ) {
@@ -254,15 +255,15 @@ protected function expectFailingValueValidation(int $i, $value, array $constrain
254
255
}, $ violation );
255
256
}
256
257
257
- protected function expectValidateValueAt ($ i , $ propertyPath , $ value , $ constraints , $ group = null )
258
+ protected function expectValidateValueAt (int $ i , string $ propertyPath , mixed $ value , Constraint | array $ constraints , string | GroupSequence | array | null $ group = null )
258
259
{
259
260
$ contextualValidator = $ this ->context ->getValidator ()->inContext ($ this ->context );
260
261
$ contextualValidator ->expectValidation ($ i , $ propertyPath , $ value , $ group , function ($ passedConstraints ) use ($ constraints ) {
261
262
Assert::assertEquals ($ constraints , $ passedConstraints );
262
263
});
263
264
}
264
265
265
- protected function expectViolationsAt ($ i , $ value , Constraint $ constraint )
266
+ protected function expectViolationsAt (int $ i , mixed $ value , Constraint $ constraint )
266
267
{
267
268
$ context = $ this ->createContext ();
268
269
@@ -283,11 +284,9 @@ protected function assertNoViolation()
283
284
}
284
285
285
286
/**
286
- * @param $message
287
- *
288
287
* @return ConstraintViolationAssertion
289
288
*/
290
- protected function buildViolation ($ message )
289
+ protected function buildViolation (string | \ Stringable $ message )
291
290
{
292
291
return new ConstraintViolationAssertion ($ this ->context , $ message , $ this ->constraint );
293
292
}
@@ -334,7 +333,7 @@ public function atPath(string $path)
334
333
return $ this ;
335
334
}
336
335
337
- public function setParameter (string $ key , $ value )
336
+ public function setParameter (string $ key , string $ value )
338
337
{
339
338
$ this ->parameters [$ key ] = $ value ;
340
339
@@ -348,14 +347,14 @@ public function setParameters(array $parameters)
348
347
return $ this ;
349
348
}
350
349
351
- public function setTranslationDomain ($ translationDomain )
350
+ public function setTranslationDomain (? string $ translationDomain )
352
351
{
353
352
// no-op for BC
354
353
355
354
return $ this ;
356
355
}
357
356
358
- public function setInvalidValue ($ invalidValue )
357
+ public function setInvalidValue (mixed $ invalidValue )
359
358
{
<
F438
code>360 359
$ this ->invalidValue = $ invalidValue ;
361
360
@@ -376,7 +375,7 @@ public function setCode(string $code)
376
375
return $ this ;
377
376
}
378
377
379
- public function setCause ($ cause )
378
+ public function setCause (mixed $ cause )
380
379
{
381
380
$ this ->cause = $ cause ;
382
381
@@ -445,11 +444,11 @@ public function __construct(ExecutionContextInterface $context)
445
444
$ this ->context = $ context ;
446
445
}
447
446
448
- public function atPath ($ path )
447
+ public function atPath (string $ path )
449
448
{
450
449
}
451
450
452
- public function doAtPath ($ path )
451
+ public function doAtPath (string $ path )
453
452
{
454
453
Assert::assertFalse ($ this ->expectNoValidate , 'No validation calls have been expected. ' );
455
454
@@ -462,11 +461,11 @@ public function doAtPath($path)
462
461
return $ this ;
463
462
}
464
463
465
- public function validate ($ value , $ constraints = null , $ groups = null )
464
+ public function validate (mixed $ value , Constraint | array | null $ constraints = null , string | GroupSequence | array | null $ groups = null )
466
465
{
467
466
}
468
467
469
- public function doValidate ($ value , $ constraints = null , $ groups = null )
468
+ public function doValidate (mixed $ value , Constraint | array | null $ constraints = null , string | GroupSequence | array | null $ groups = null )
470
469
{
471
470
Assert::assertFalse ($ this ->expectNoValidate , 'No validation calls have been expected. ' );
472
471
@@ -487,20 +486,20 @@ public function doValidate($value, $constraints = null, $groups = null)
487
486
return $ this ;
488
487
}
489
488
490
- public function validateProperty ($ object , $ propertyName , $ groups = null )
489
+ public function validateProperty (object $ object , string $ propertyName , string | GroupSequence | array | null $ groups = null )
491
490
{
492
491
}
493
492
494
- public function doValidateProperty ($ object , $ propertyName , $ groups = null )
493
+ public function doValidateProperty (object $ object , string $ propertyName , string | GroupSequence | array | null $ groups = null )
495
494
{
496
495
return $ this ;
497
496
}
498
497
499
- public function validatePropertyValue ($ objectOrClass , $ propertyName , $ value , $ groups = null )
498
+ public function validatePropertyValue (object | string $ objectOrClass , string $ propertyName , mixed $ value , string | GroupSequence | array | null $ groups = null )
500
499
{
501
500
}
502
501
503
- public function doValidatePropertyValue ($ objectOrClass , $ propertyName , $ value , $ groups = null )
502
+ public function doValidatePropertyValue (object | string $ objectOrClass , string $ propertyName , mixed $ value , string | GroupSequence | array | null $ groups = null )
504
503
{
505
504
return $ this ;
506
505
}
@@ -519,7 +518,7 @@ public function expectNoValidate()
519
518
$ this ->expectNoValidate = true ;
520
519
}
521
520
522
- public function expectValidation ($ call , $ propertyPath , $ value , $ group , $ constraints , ConstraintViolationInterface $ violation = null )
521
+ public function expectValidation (string $ call , string $ propertyPath , mixed $ value , string | GroupSequence | array | null $ group , callable $ constraints , ConstraintViolationInterface $ violation = null )
523
522
{
524
523
$ this ->expectedAtPath [$ call ] = $ propertyPath ;
525
524
$ this ->expectedValidate [$ call ] = [$ value , $ group , $ constraints , $ violation ];
0 commit comments