8000 [Validator] Add the type for ConstraintValidatorTestCase::createValidator by stof · Pull Request #48012 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Add the type for ConstraintValidatorTestCase::createValidator #48012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Validator] Add the type for ConstraintValidatorTestCase::createValid…
…ator
  • Loading branch information
stof authored and nicolas-grekas committed Nov 9, 2022
commit 894a44918e88e22d71333409524a785a20f05c19
17 changes: 14 additions & 3 deletions .github/expected-missing-return-types.diff
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,17 @@ index da401930d7..15d6219259 100644
{
return FormType::class;
diff --git a/src/Symfony/Component/Form/DataTransformerInterface.php b/src/Symfony/Component/Form/DataTransformerInterface.php
index edb3f83c0b..c54659f95e 100644
index 85fb99d218..6cc654f681 100644
--- a/src/Symfony/Component/Form/DataTransformerInterface.php
+++ b/src/Symfony/Component/Form/DataTransformerInterface.php
@@ -63,5 +63,5 @@ interface DataTransformerInterface
@@ -65,5 +65,5 @@ interface DataTransformerInterface
* @throws TransformationFailedException when the transformation fails
*/
- public function transform(mixed $value);
+ public function transform(mixed $value): mixed;

/**
@@ -92,4 +92,4 @@ interface DataTransformerInterface
@@ -96,4 +96,4 @@ interface DataTransformerInterface
* @throws TransformationFailedException when the transformation fails
*/
- public function reverseTransform(mixed $value);
Expand Down Expand Up @@ -1078,6 +1078,17 @@ index ee1d68c78f..9baaabb04c 100644
+ public function getTargets(): string|array
{
return self::PROPERTY_CONSTRAINT;
diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
index d9bb9bd390..b981038042 100644
--- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php
+++ b/src/Symfony/Component/Validator/Test/Constra 57AE intValidatorTestCase.php
@@ -301,5 +301,5 @@ abstract class ConstraintValidatorTestCase extends TestCase
* @psalm-return T
*/
- abstract protected function createValidator();
+ abstract protected function createValidator(): ConstraintValidatorInterface;
}

diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php
index 57c229eb14..b9aa92fcb7 100644
--- a/src/Symfony/Component/VarExporter/Internal/Exporter.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function createEntityManagerMock($repositoryMock)
return $em;
}

protected function createValidator()
protected function createValidator(): UniqueEntityValidator
{
return new UniqueEntityValidator($this->registry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Context\ExecutionContext;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
use Symfony\Component\Validator\Validation;
Expand Down Expand Up @@ -714,7 +715,7 @@ public function testCauseForNotAllowedExtraFieldsIsTheFormConstraint()
$this->assertSame($constraint, $context->getViolations()->get(0)->getConstraint());
}

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new FormValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

Expand All @@ -44,7 +45,7 @@ abstract class UserPasswordValidatorTest extends ConstraintValidatorTestCase
*/
protected $hasherFactory;

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new UserPasswordValidator($this->tokenStorage, $this->hasherFactory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ protected function buildViolation(string|\Stringable $message): ConstraintViolat
return new ConstraintViolationAssertion($this->context, $message, $this->constraint);
}

/**
* @return ConstraintValidatorInterface
*
* @psalm-return T
*/
abstract protected function createValidator();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
use Symfony\Component\Validator\Constraints\AllValidator;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class AllValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new AllValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Component\Validator\Constraints\Unique;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
Expand All @@ -43,7 +44,7 @@
*/
class AtLeastOneOfValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new AtLeastOneOfValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Validator\Constraints\Bic;
use Symfony\Component\Validator\Constraints\BicValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Mapping\ClassMetadata;
Expand All @@ -21,7 +22,7 @@

class BicValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new BicValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

use Symfony\Component\Validator\Constraints\Blank;
use Symfony\Component\Validator\Constraints\BlankValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class BlankValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new BlankValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\CallbackValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
Expand Down Expand Up @@ -47,7 +48,7 @@ public static function validateStatic($object, ExecutionContextI 2851 nterface $contex

class CallbackValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CallbackValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

use Symfony\Component\Validator\Constraints\CardScheme;
use Symfony\Component\Validator\Constraints\CardSchemeValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class CardSchemeValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CardSchemeValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\ChoiceValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
Expand All @@ -24,7 +25,7 @@ function choice_callback()

class ChoiceValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new ChoiceValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
use Symfony\Component\Validator\Constraints\Optional;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Constraints\Required;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

abstract class CollectionValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CollectionValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
use Symfony\Component\Validator\Constraints\CompoundValidator;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class CompoundValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CompoundValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Validator\Constraints\Count;
use Symfony\Component\Validator\Constraints\CountValidator;
use Symfony\Component\Validator\Constraints\DivisibleBy;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

Expand All @@ -22,7 +23,7 @@
*/
abstract class CountValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CountValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraints\Country;
use Symfony\Component\Validator\Constraints\CountryValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

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

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CountryValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Validator\Constraints\Currency;
use Symfony\Component\Validator\Constraints\CurrencyValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

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

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new CurrencyValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Validator\Constraints\DateTimeValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class DateTimeValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new DateTimeValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\DateValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class DateValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new DateValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\DivisibleBy;
use Symfony\Component\Validator\Constraints\DivisibleByValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;

/**
* @author Colin O'Dell <colinodell@gmail.com>
*/
class DivisibleByValidatorTest extends AbstractComparisonValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new DivisibleByValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\EmailValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

Expand All @@ -24,7 +25,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase
{
use ExpectDeprecationTrait;

protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new EmailValidator(Email::VALIDATION_MODE_HTML5);
}
Expand Down Expand Up @@ -84,6 +85,7 @@ public function getValidEmails()

/**
* @group legacy
*
* @dataProvider getValidEmails
* @dataProvider getEmailsOnlyValidInLooseMode
*/
Expand Down Expand Up @@ -125,6 +127,7 @@ public function getValidEmailsWithWhitespaces()

/**
* @group legacy
*
* @dataProvider getValidEmailsWithWhitespaces
* @dataProvider getEmailsWithWhitespacesOnlyValidInLooseMode
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\EqualTo;
use Symfony\Component\Validator\Constraints\EqualToValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;

/**
* @author Daniel Holmes <daniel@danielholmes.org>
*/
class EqualToValidatorTest extends AbstractComparisonValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new EqualToValidator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntax;
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

/**
* @group legacy
*/
class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new ExpressionLanguageSyntaxValidator(new ExpressionLanguage());
}
Expand Down
Loading
0