8000 [Validator] Add the type for ConstraintValidatorTestCase::createValid… · symfony/symfony@894a449 · GitHub
[go: up one dir, main page]

Skip to content

Commit 894a449

Browse files
stofnicolas-grekas
authored andcommi 8000 tted
[Validator] Add the type for ConstraintValidatorTestCase::createValidator
1 parent f3a180b commit 894a449

File tree

59 files changed

+134
-60
lines changed

Some content is hidden

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

59 files changed

+134
-60
lines changed

.github/expected-missing-return-types.diff

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,17 +468,17 @@ index da401930d7..15d6219259 100644
468468
{
469469
return FormType::class;
470470
diff --git a/src/Symfony/Component/Form/DataTransformerInterface.php b/src/Symfony/Component/Form/DataTransformerInterface.php
471-
index edb3f83c0b..c54659f95e 100644
471+
index 85fb99d218..6cc654f681 100644
472472
--- a/src/Symfony/Component/Form/DataTransformerInterface.php
473473
+++ b/src/Symfony/Component/Form/DataTransformerInterface.php
474-
@@ -63,5 +63,5 @@ interface DataTransformerInterface
474+
@@ -65,5 +65,5 @@ interface DataTransformerInterface
475475
* @throws TransformationFailedException when the transformation fails
476476
*/
477477
- public function transform(mixed $value);
478478
+ public function transform(mixed $value): mixed;
479479

480480
/**
481-
@@ -92,4 +92,4 @@ interface DataTransformerInterface
481+
@@ -96,4 +96,4 @@ interface DataTransformerInterface
482482
* @throws TransformationFailedException when the transformation fails
483483
*/
484484
- public function reverseTransform(mixed $value);
@@ -1078,6 +1078,17 @@ index ee1d68c78f..9baaabb04c 100644
10781078
+ public function getTargets(): string|array
10791079
{
10801080
return self::PROPERTY_CONSTRAINT;
1081+
diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
1082+
index d9bb9bd390..b981038042 100644
1083+
--- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
1084+
+++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
1085+
@@ -301,5 +301,5 @@ abstract class ConstraintValidatorTestCase extends TestCase
1086+
* @psalm-return T
1087+
*/
1088+
- abstract protected function createValidator();
1089+
+ abstract protected function createValidator(): ConstraintValidatorInterface;
1090+
}
1091+
10811092
diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php
10821093
index 57c229eb14..b9aa92fcb7 100644
10831094
--- a/src/Symfony/Component/VarExporter/Internal/Exporter.php

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected function createEntityManagerMock($repositoryMock)
131131
return $em;
132132
}
133133

134-
protected function createValidator()
134+
protected function createValidator(): UniqueEntityValidator
135135
{
136136
return new UniqueEntityValidator($this->registry);
137137
}

src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Symfony\Component\Validator\Constraints\NotBlank;
3131
use Symfony\Component\Validator\Constraints\NotNull;
3232
use Symfony\Component\Validator\Constraints\Valid;
33+
use Symfony\Component\Validator\ConstraintValidatorInterface;
3334
use Symfony\Component\Validator\Context\ExecutionContext;
3435
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
3536
use Symfony\Component\Validator\Validation;
@@ -714,7 +715,7 @@ public function testCauseForNotAllowedExtraFieldsIsTheFormConstraint()
714715
$this->assertSame($constraint, $context->getViolations()->get(0)->getConstraint());
715716
}
716717

717-
protected function createValidator()
718+
protected function createValidator(): ConstraintValidatorInterface
718719
{
719720
return new FormValidator();
720721
}

src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Security\Core\User\UserInterface;
1919
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
2020
use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator;
21+
use Symfony\Component\Validator\ConstraintValidatorInterface;
2122
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
2223
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2324

@@ -44,7 +45,7 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase
4445
*/
4546
protected $hasherFactory;
4647

47-
protected function createValidator()
48+
protected function createValidator(): ConstraintValidatorInterface
4849
{
4950
return new UserPasswordValidator($this->tokenStorage, $this->hasherFactory);
5051
}

src/Symfony/Component/Validator/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

src/Symfony/Component/Validator/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
}

src/Symfony/Component/Validator/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
}

src/Symfony/Component/Validator/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
}

src/Symfony/Component/Validator/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
}

src/Symfony/Component/Validator/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
}

0 commit comments

Comments
 (0)
0