Skip to content

Commit 3c016e0

Browse files
stofnicolas-grekas
authored andcommitted
[Validator] Add the type for ConstraintValidatorTestCase::createValidator
1 parent 8deb30f commit 3c016e0

File tree

55 files changed

+115
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+115
-54
lines changed

Test/ConstraintValidatorTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ protected function buildViolation(string|\Stringable $message): ConstraintViolat
295295
return new ConstraintViolationAssertion($this->context, $message, $this->constraint);
296296
}
297297

298+
/**
299+
* @return ConstraintValidatorInterface
300+
*
301+
* @psalm-return T
302+
*/
298303
abstract protected function createValidator();
299304
}
300305

Tests/Constraints/AllValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
use Symfony\Component\Validator\Constraints\AllValidator;
1616
use Symfony\Component\Validator\Constraints\NotNull;
1717
use Symfony\Component\Validator\Constraints\Range;
18+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1819
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1920
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2021

2122
class AllValidatorTest extends ConstraintValidatorTestCase
2223
{
23-
protected function createValidator()
24+
protected function createValidator(): ConstraintValidatorInterface
2425
{
2526
return new AllValidator();
2627
}

Tests/Constraints/AtLeastOneOfValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Symfony\Component\Validator\Constraints\Regex;
3232
use Symfony\Component\Validator\Constraints\Unique;
3333
use Symfony\Component\Validator\Constraints\Valid;
34+
use Symfony\Component\Validator\ConstraintValidatorInterface;
3435
use Symfony\Component\Validator\ConstraintViolation;
3536
use Symfony\Component\Validator\Mapping\ClassMetadata;
3637
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
@@ -43,7 +44,7 @@
4344
*/
4445
class AtLeastOneOfValidatorTest extends ConstraintValidatorTestCase
4546
{
46-
protected function createValidator()
47+
protected function createValidator(): ConstraintValidatorInterface
4748
{
4849
return new AtLeastOneOfValidator();
4950
}

Tests/Constraints/BicValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraints\Bic;
1515
use Symfony\Component\Validator\Constraints\BicValidator;
16+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1617
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -21,7 +22,7 @@
2122

2223
class BicValidatorTest extends ConstraintValidatorTestCase
2324
{
24-
protected function createValidator()
25+
protected function createValidator(): ConstraintValidatorInterface
2526
{
2627
return new BicValidator();
2728
}

Tests/Constraints/BlankValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313

1414
use Symfony\Component\Validator\Constraints\Blank;
1515
use Symfony\Component\Validator\Constraints\BlankValidator;
16+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1617
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1718

1819
class BlankValidatorTest extends ConstraintValidatorTestCase
1920
{
20-
protected function createValidator()
21+
protected function createValidator(): ConstraintValidatorInterface
2122
{
2223
return new BlankValidator();
2324
}

Tests/Constraints/CallbackValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\Callback;
1616
use Symfony\Component\Validator\Constraints\CallbackValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Context\ExecutionContextInterface;
1819
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1920
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -47,7 +48,7 @@ public static function validateStatic($object, ExecutionContextInterface $contex
4748

4849
class CallbackValidatorTest extends ConstraintValidatorTestCase
4950
{
50-
protected function createValidator()
51+
protected function createValidator(): ConstraintValidatorInterface
5152
{
5253
return new CallbackValidator();
5354
}

Tests/Constraints/CardSchemeValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313

1414
use Symfony\Component\Validator\Constraints\CardScheme;
1515
use Symfony\Component\Validator\Constraints\CardSchemeValidator;
16+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1617
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1718

1819
class CardSchemeValidatorTest extends ConstraintValidatorTestCase
1920
{
20-
protected function createValidator()
21+
protected function createValidator(): ConstraintValidatorInterface
2122
{
2223
return new CardSchemeValidator();
2324
}

Tests/Constraints/ChoiceValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraints\Choice;
1515
use Symfony\Component\Validator\Constraints\ChoiceValidator;
16+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1617
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -24,7 +25,7 @@ function choice_callback()
2425

2526
class ChoiceValidatorTest extends ConstraintValidatorTestCase
2627
{
27-
protected function createValidator()
28+
protected function createValidator(): ConstraintValidatorInterface
2829
{
2930
return new ChoiceValidator();
3031
}

Tests/Constraints/CollectionValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
use Symfony\Component\Validator\Constraints\Optional;
1818
use Symfony\Component\Validator\Constraints\Range;
1919
use Symfony\Component\Validator\Constraints\Required;
20+
use Symfony\Component\Validator\ConstraintValidatorInterface;
2021
use Symfony\Component\Validator\Exception\UnexpectedValueException;
2122
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2223

2324
abstract class CollectionValidatorTest extends ConstraintValidatorTestCase
2425
{
25-
protected function createValidator()
26+
protected function createValidator(): ConstraintValidatorInterface
2627
{
2728
return new CollectionValidator();
2829
}

Tests/Constraints/CompoundValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
use Symfony\Component\Validator\Constraints\CompoundValidator;
1616
use Symfony\Component\Validator\Constraints\Length;
1717
use Symfony\Component\Validator\Constraints\NotBlank;
18+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1819
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1920

2021
class CompoundValidatorTest extends ConstraintValidatorTestCase
2122
{
22-
protected function createValidator()
23+
protected function createValidator(): ConstraintValidatorInterface
2324
{
2425
return new CompoundValidator();
2526
}

0 commit comments

Comments
 (0)