8000 minor #48012 [Validator] Add the type for ConstraintValidatorTestCase… · jschaedl/symfony@36e240c · GitHub
[go: up one dir, main page]

Skip to content

Commit 36e240c

Browse files
minor symfony#48012 [Validator] Add the type for ConstraintValidatorTestCase::createValidator (stof)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- [Validator] Add the type for ConstraintValidatorTestCase::createValidator | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a Commits ------- 894a449 [Validator] Add the type for ConstraintValidatorTestCase::createValidator
2 parents adbf678 + 894a449 commit 36e240c
10000

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
}

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

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

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

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

src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Validator\Constraints\Count;
1515
use Symfony\Component\Validator\Constraints\CountValidator;
1616
use Symfony\Component\Validator\Constraints\DivisibleBy;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1920

@@ -22,7 +23,7 @@
2223
*/
2324
abstract class CountValidatorTest extends ConstraintValidatorTestCase
2425
{
25-
protected function createValidator()
26+
protected function createValidator(): ConstraintValidatorInterface
2627
{
2728
return new CountValidator();
2829
}

src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Intl\Util\IntlTestHelper;
1515
use Symfony\Component\Validator\Constraints\Country;
1616
use Symfony\Component\Validator\Constraints\CountryValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1920

@@ -35,7 +36,7 @@ protected function tearDown(): void
3536
\Locale::setDefault($this->defaultLocale);
3637
}
3738

38-
protected function createValidator()
39+
protected function createValidator(): ConstraintValidatorInterface
3940
{
4041
return new CountryValidator();
4142
}

src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Intl\Util\IntlTestHelper;
1515
use Symfony\Component\Validator\Constraints\Currency;
1616
use Symfony\Component\Validator\Constraints\CurrencyValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1920

@@ -35,7 +36,7 @@ protected function tearDown(): void
3536
\Locale::setDefault($this->defaultLocale);
3637
}
3738

38-
protected function createValidator()
39+
protected function createValidator(): ConstraintValidatorInterface
3940
{
4041
return new CurrencyValidator();
4142
}

src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php

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

1414
use Symfony\Component\Validator\Constraints\DateTime;
1515
use Symfony\Component\Validator\Constraints\DateTimeValidator;
16+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1617
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1819

1920
class DateTimeValidatorTest extends ConstraintValidatorTestCase
2021
{
21-
protected function createValidator()
22+
protected function createValidator(): ConstraintValidatorInterface
2223
{
2324
return new DateTimeValidator();
2425
}

src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php

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

1414
use Symfony\Component\Validator\Constraints\Date;
1515
use Symfony\Component\Validator\Constraints\DateValidator;
16+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1617
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1819

1920
class DateValidatorTest extends ConstraintValidatorTestCase
2021
{
21-
protected function createValidator()
22+
protected function createValidator(): ConstraintValidatorInterface
2223
{
2324
return new DateValidator();
2425
}

src/Symfony/Component/Validator/Tests/Constraints/DivisibleByValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\DivisibleBy;
1616
use Symfony\Component\Validator\Constraints\DivisibleByValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819

1920
/**
2021
* @author Colin O'Dell <colinodell@gmail.com>
2122
*/
2223
class DivisibleByValidatorTest extends AbstractComparisonValidatorTestCase
2324
{
24-
protected function createValidator()
25+
protected function createValidator(): ConstraintValidatorInterface
2526
{
2627
return new DivisibleByValidator();
2728
}

src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1515
use Symfony\Component\Validator\Constraints\Email;
1616
use Symfony\Component\Validator\Constraints\EmailValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1819
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1920

@@ -24,7 +25,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
2425
{
2526
use ExpectDeprecationTrait;
2627

27-
protected function createValidator()
28+
protected function createValidator(): ConstraintValidatorInterface
2829
{
2930
return new EmailValidator(Email::VALIDATION_MODE_HTML5);
3031
}
@@ -84,6 +85,7 @@ public function getValidEmails()
8485

8586
/**
8687
* @group legacy
88+
*
8789
* @dataProvider getValidEmails
8890
* @dataProvider getEmailsOnlyValidInLooseMode
8991
*/
@@ -125,6 +127,7 @@ public function getValidEmailsWithWhitespaces()
125127

126128
/**
127129
* @group legacy
130+
*
128131
* @dataProvider getValidEmailsWithWhitespaces
129132
* @dataProvider getEmailsWithWhitespacesOnlyValidInLooseMode
130133
*/

src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\EqualTo;
1616
use Symfony\Component\Validator\Constraints\EqualToValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718

1819
/**
1920
* @author Daniel Holmes <daniel@danielholmes.org>
2021
*/
2122
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
2223
{
23-
protected function createValidator()
24+
protected function createValidator(): ConstraintValidatorInterface
2425
{
2526
return new EqualToValidator();
2627
}

src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1515
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntax;
1616
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator;
17+
use Symfony\Component\Validator\ConstraintValidatorInterface;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1819

1920
/**
2021
* @group legacy
2122
*/
2223
class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
2324
{
24-
protected function createValidator()
25+
protected function createValidator(): ConstraintValidatorInterface
2526
{
2627
return new ExpressionLanguageSyntaxValidator(new ExpressionLanguage());
2728
}

0 commit comments

Comments
 (0)
0