From 0c69f6927f9f2cb66a74f9e96eb95789344439af Mon Sep 17 00:00:00 2001 From: sarah khalil Date: Mon, 19 Jan 2015 18:16:09 +0100 Subject: [PATCH 1/3] Removed 2.5 bc layer --- .../FrameworkExtensionTest.php | 4 +- .../Validator/Tests/ValidatorBuilderTest.php | 4 +- .../Validator/Validator/LegacyValidator.php | 28 +------------- .../Validator/RecursiveValidator.php | 37 +++++++++++++++++++ .../Component/Validator/ValidatorBuilder.php | 12 +----- 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e2d8e2a23eb4..54d2b19ac769 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -306,14 +306,14 @@ public function testLegacyFullyConfiguredValidationService() $container = $this->createContainerFromFile('full'); - $this->assertInstanceOf('Symfony\Component\Validator\ValidatorInterface', $container->get('validator')); + $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); } public function testValidationService() { $container = $this->createContainerFromFile('validation_annotations'); - $this->assertInstanceOf('Symfony\Component\Validator\ValidatorInterface', $container->get('validator')); + $this->assertInstanceOf('Symfony\Component\Validator\Validator\ValidatorInterface', $container->get('validator')); } public function testAnnotations() diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index af20f9cd7aff..cbfd8fea2410 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -118,7 +118,7 @@ public function testLegacyDefaultApiVersion() $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); // Legacy compatible implementation - $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); + $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); } public function testSetApiVersion25() @@ -135,6 +135,6 @@ public function testLegacySetApiVersion24And25() $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC)); - $this->assertInstanceOf('Symfony\Component\Validator\Validator\LegacyValidator', $this->builder->getValidator()); + $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); } } diff --git a/src/Symfony/Component/Validator/Validator/LegacyValidator.php b/src/Symfony/Component/Validator/Validator/LegacyValidator.php index 8995f2cfdd59..f73a79ef0e26 100644 --- a/src/Symfony/Component/Validator/Validator/LegacyValidator.php +++ b/src/Symfony/Component/Validator/Validator/LegacyValidator.php @@ -11,9 +11,6 @@ namespace Symfony\Component\Validator\Validator; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\GroupSequence; -use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; /** @@ -31,22 +28,9 @@ class LegacyValidator extends RecursiveValidator implements LegacyValidatorInter { public function validate($value, $groups = null, $traverse = false, $deep = false) { - $numArgs = func_num_args(); - - // Use new signature if constraints are given in the second argument - if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) { - // Rename to avoid total confusion ;) - $constraints = $groups; - $groups = $traverse; - - return parent::validate($value, $constraints, $groups); - } - trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); - $constraint = new Valid(array('traverse' => $traverse, 'deep' => $deep)); - - return parent::validate($value, $constraint, $groups); + return parent::validate($value, false, $groups, $traverse, $deep); } public function validateValue($value, $constraints, $groups = null) @@ -62,14 +46,4 @@ public function getMetadataFactory() return $this->metadataFactory; } - - private static function testConstraints($constraints) - { - return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); - } - - private static function testGroups($groups) - { - return null === $groups || is_string($groups) || $groups instanceof GroupSequence || (is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence)); - } } diff --git a/src/Symfony/Component/Validator/Validator/RecursiveValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveValidator.php index ddf0850c1cf2..7cfbc27fbf0d 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveValidator.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Validator\Validator; +use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; +use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -112,6 +115,22 @@ public function hasMetadataFor($object) */ public function validate($value, $constraints = null, $groups = null) { + // The following code must be removed in 3.0 + $numArgs = func_num_args(); + if ($numArgs > 3) { + trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); + $traverse = func_get_arg(3); + $deep = func_get_arg(4); + $constraints = new Valid(array('traverse' => $traverse, 'deep' => $deep)); + + if (self::testConstraints($groups)) { + if ((!$traverse && !$deep) || self::testGroups($traverse)) { + $constraints = $groups; + $groups = $traverse; + } + } + } + return $this->startContext($value) ->validate($value, $constraints, $groups) ->getViolations(); @@ -137,4 +156,22 @@ public function validatePropertyValue($objectOrClass, $propertyName, $value, $gr ->validatePropertyValue($objectOrClass, $propertyName, $value, $groups) ->getViolations(); } + + /** + * @internal + * @deprecated since version 2.5, to be removed in 3.0. + */ + private static function testConstraints($constraints) + { + return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); + } + + /** + * @internal + * @deprecated since version 2.5, to be removed in 3.0. + */ + private static function testGroups($groups) + { + return null === $groups || is_string($groups) || $groups instanceof GroupSequence || (is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence)); + } } diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php index e47d1f42a682..6b85b956e075 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilder.php +++ b/src/Symfony/Component/Validator/ValidatorBuilder.php @@ -19,7 +19,6 @@ use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Context\ExecutionContextFactory; -use Symfony\Component\Validator\Context\LegacyExecutionContextFactory; use Symfony\Component\Validator\Exception\InvalidArgumentException; use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; @@ -31,7 +30,6 @@ use Symfony\Component\Validator\Mapping\Loader\XmlFilesLoader; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; use Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader; -use Symfony\Component\Validator\Validator\LegacyValidator; use Symfony\Component\Validator\Validator\RecursiveValidator; /** @@ -393,14 +391,8 @@ public function getValidator() $translator->setLocale('en'); } - if (Validation::API_VERSION_2_5 === $apiVersion) { - $contextFactory = new ExecutionContextFactory($translator, $this->translationDomain); + $contextFactory = new ExecutionContextFactory($translator, $this->translationDomain); - return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers); - } - - $contextFactory = new LegacyExecutionContextFactory($metadataFactory, $translator, $this->translationDomain); - - return new LegacyValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers); + return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers); } } From 75088c0adc8abb9492e3591782e9ab5c8232b51d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 25 Jan 2015 06:54:05 +0100 Subject: [PATCH 2/3] [Validator] deprecated API version --- .../DependencyInjection/Configuration.php | 22 +++++++--------- .../FrameworkExtension.php | 14 ++--------- .../Validator/Tests/ValidatorBuilderTest.php | 25 +------------------ .../Component/Validator/ValidatorBuilder.php | 21 ++++------------ .../Validator/ValidatorBuilderInterface.php | 2 ++ 5 files changed, 19 insertions(+), 65 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 5e6c9a4176aa..82cde1c31972 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -112,6 +112,14 @@ public function getConfigTreeBuilder() return $v; }) ->end() + ->beforeNormalization() + ->ifTrue(function ($v) { return isset($v['validation']['api']); }) + ->then(function ($v) { + trigger_error('The validation.api configuration key is deprecated since version 2.7 and will be removed in 3.0', E_USER_DEPRECATED); + + return $v; + }) + ->end() ->children() ->scalarNode('secret')->end() ->scalarNode('http_method_override') @@ -610,6 +618,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->scalarNode('translation_domain')->defaultValue('validators')->end() ->booleanNode('strict_email')->defaultFalse()->end() ->enumNode('api') + ->info('Deprecated since version 2.7, to be removed in 3.0') ->values(array('2.4', '2.5', '2.5-bc', 'auto')) ->beforeNormalization() // XML/YAML parse as numbers, not as strings @@ -620,19 +629,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->end() ->end() ->end() - ->validate() - ->ifTrue(function ($v) { return !isset($v['validation']['api']) || 'auto' === $v['validation']['api']; }) - ->then(function ($v) { - // This condition is duplicated in ValidatorBuilder. This - // duplication is necessary in order to know the desired - // API version already during container configuration - // (to adjust service classes etc.) - // See https://github.com/symfony/symfony/issues/11580 - $v['validation']['api'] = '2.5-bc'; - - return $v; - }) - ->end() ; } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 51ff11ed4a36..ca18f332b3dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -761,20 +761,10 @@ private function registerValidationConfiguration(array $config, ContainerBuilder $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache']))); } - if ('2.5' === $config['api']) { - $api = Validation::API_VERSION_2_5; - } else { - // 2.4 is now the same as 2.5 BC - $api = Validation::API_VERSION_2_5_BC; - // the validation class needs to be changed for BC - $container->setParameter('validator.class', 'Symfony\Component\Validator\ValidatorInterface'); - } - - $validatorBuilder->addMethodCall('setApiVersion', array($api)); - // You can use this parameter to check the API version in your own // bundle extension classes - $container->setParameter('validator.api', $api); + // @deprecated since version 2.7, to be removed in 3.0 + $container->setParameter('validator.api', $config['api']); } private function getValidatorMappingFiles(ContainerBuilder $container) diff --git a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php index cbfd8fea2410..88e8b3b82689 100644 --- a/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php @@ -110,31 +110,8 @@ public function testSetTranslationDomain() $this->assertSame($this->builder, $this->builder->setTranslationDomain('TRANS_DOMAIN')); } - /** - * @group legacy - */ - public function testLegacyDefaultApiVersion() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - // Legacy compatible implementation - $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); - } - - public function testSetApiVersion25() + public function testGetValidator() { - $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5)); - $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); - } - - /** - * @group legacy - */ - public function testLegacySetApiVersion24And25() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->assertSame($this->builder, $this->builder->setApiVersion(Validation::API_VERSION_2_5_BC)); $this->assertInstanceOf('Symfony\Component\Validator\Validator\RecursiveValidator', $this->builder->getValidator()); } } diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php index 6b85b956e075..dd772cf38325 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilder.php +++ b/src/Symfony/Component/Validator/ValidatorBuilder.php @@ -94,11 +94,6 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ private $propertyAccessor; - /** - * @var int|null - */ - private $apiVersion; - /** * {@inheritdoc} */ @@ -318,18 +313,17 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) /** * {@inheritdoc} + * + * @deprecated since version 2.7, to be removed in 3.0. */ public function setApiVersion($apiVersion) { + trigger_error('The '.__METHOD__.' method is deprecated in version 2.7 and will be removed in version 3.0.', E_USER_DEPRECATED); + if (!in_array($apiVersion, array(Validation::API_VERSION_2_4, Validation::API_VERSION_2_5, Validation::API_VERSION_2_5_BC))) { - throw new InvalidArgumentException(sprintf( - 'The requested API version is invalid: "%s"', - $apiVersion - )); + throw new InvalidArgumentException(sprintf('The requested API version is invalid: "%s"', $apiVersion)); } - $this->apiVersion = $apiVersion; - return $this; } @@ -339,11 +333,6 @@ public function setApiVersion($apiVersion) public function getValidator() { $metadataFactory = $this->metadataFactory; - $apiVersion = $this->apiVersion; - - if (null === $apiVersion) { - $apiVersion = Validation::API_VERSION_2_5_BC; - } if (!$metadataFactory) { $loaders = array(); diff --git a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php index 6e2dd96a2dfc..cc0007770578 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -180,6 +180,8 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) * * @see Validation::API_VERSION_2_5 * @see Validation::API_VERSION_2_5_BC + * + * @deprecated since version 2.7, to be removed in 3.0. */ public function setApiVersion($apiVersion); From 9438206c2541e91b089b8e3581aa1102c2104913 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sun, 22 Mar 2015 16:12:19 +0100 Subject: [PATCH 3/3] Complete the removal of API versions in the validator component Thanks to the PHP version requirement bump to 5.3.9+, the BC layer can be available all the time. --- .../FrameworkExtension.php | 3 +- .../DependencyInjection/ConfigurationTest.php | 1 - .../Fixtures/php/validation_2_5_api.php | 9 -- .../Fixtures/php/validation_2_5_bc_api.php | 9 -- .../Fixtures/php/validation_auto_api.php | 9 -- .../Fixtures/php/validation_implicit_api.php | 8 -- .../Fixtures/xml/validation_2_5_api.xml | 12 -- .../Fixtures/xml/validation_2_5_bc_api.xml | 12 -- .../Fixtures/xml/validation_auto_api.xml | 12 -- .../Fixtures/xml/validation_implicit_api.xml | 12 -- .../Fixtures/yml/validation_2_5_api.yml | 5 - .../Fixtures/yml/validation_2_5_bc_api.yml | 5 - .../Fixtures/yml/validation_auto_api.yml | 5 - .../Fixtures/yml/validation_implicit_api.yml | 4 - .../FrameworkExtensionTest.php | 78 +----------- .../Validator/Context/ExecutionContext.php | 105 ++++++++++++---- .../Context/LegacyExecutionContext.php | 113 +----------------- .../Context/LegacyExecutionContextFactory.php | 2 + .../AbstractConstraintValidatorTest.php | 6 +- .../LegacyAllValidatorLegacyApiTest.php | 27 ----- .../LegacyBlankValidatorLegacyApiTest.php | 27 ----- .../LegacyCallbackValidatorLegacyApiTest.php | 27 ----- ...LegacyCardSchemeValidatorLegacyApiTest.php | 27 ----- .../LegacyChoiceValidatorLegacyApiTest.php | 27 ----- ...yCollectionValidatorArrayLegacyApiTest.php | 25 ---- ...ctionValidatorArrayObjectLegacyApiTest.php | 25 ---- ...alidatorCustomArrayObjectLegacyApiTest.php | 25 ---- ...LegacyCountValidatorArrayLegacyApiTest.php | 27 ----- ...cyCountValidatorCountableLegacyApiTest.php | 27 ----- .../LegacyCurrencyValidatorLegacyApiTest.php | 27 ----- .../LegacyDateTimeValidatorLegacyApiTest.php | 27 ----- .../LegacyDateValidatorLegacyApiTest.php | 27 ----- .../LegacyEmailValidatorLegacyApiTest.php | 27 ----- .../LegacyEqualToValidatorLegacyApiTest.php | 27 ----- ...LegacyExpressionValidatorLegacyApiTest.php | 27 ----- .../LegacyFalseValidatorLegacyApiTest.php | 27 ----- ...LegacyFileValidatorObjectLegacyApiTest.php | 27 ----- .../LegacyFileValidatorPathLegacyApiTest.php | 27 ----- ...eaterThanOrEqualValidatorLegacyApiTest.php | 27 ----- ...egacyGreaterThanValidatorLegacyApiTest.php | 27 ----- .../LegacyIbanValidatorLegacyApiTest.php | 27 ----- ...egacyIdenticalToValidatorLegacyApiTest.php | 27 ----- .../LegacyImageValidatorLegacyApiTest.php | 27 ----- .../LegacyIpValidatorLegacyApiTest.php | 27 ----- .../LegacyIsbnValidatorLegacyApiTest.php | 27 ----- .../LegacyIssnValidatorLegacyApiTest.php | 27 ----- .../LegacyLanguageValidatorLegacyApiTest.php | 27 ----- .../LegacyLengthValidatorLegacyApiTest.php | 27 ----- ...yLessThanOrEqualValidatorLegacyApiTest.php | 27 ----- .../LegacyLessThanValidatorLegacyApiTest.php | 27 ----- .../LegacyLocaleValidatorLegacyApiTest.php | 27 ----- .../LegacyLuhnValidatorLegacyApiTest.php | 27 ----- .../LegacyNotBlankValidatorLegacyApiTest.php | 27 ----- ...LegacyNotEqualToValidatorLegacyApiTest.php | 27 ----- ...cyNotIdenticalToValidatorLegacyApiTest.php | 27 ----- .../LegacyNotNullValidatorLegacyApiTest.php | 27 ----- .../LegacyNullValidatorLegacyApiTest.php | 27 ----- .../LegacyRangeValidatorLegacyApiTest.php | 27 ----- .../LegacyRegexValidatorLegacyApiTest.php | 27 ----- .../LegacyTimeValidatorLegacyApiTest.php | 27 ----- .../LegacyTrueValidatorLegacyApiTest.php | 27 ----- .../LegacyTypeValidatorLegacyApiTest.php | 29 ----- .../LegacyUrlValidatorLegacyApiTest.php | 27 ----- .../LegacyUuidValidatorLegacyApiTest.php | 27 ----- .../Validator/Validator/LegacyValidator.php | 24 +--- .../Validator/RecursiveValidator.php | 50 ++++---- 66 files changed, 128 insertions(+), 1567 deletions(-) delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_api.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_bc_api.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_api.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_implicit_api.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_api.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_bc_api.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_api.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_implicit_api.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_api.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_bc_api.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_api.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_implicit_api.yml delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index ca18f332b3dd..8236d581c2e5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -763,8 +763,9 @@ private function registerValidationConfiguration(array $config, ContainerBuilder // You can use this parameter to check the API version in your own // bundle extension classes + // This is set to 2.5-bc for compatibility with Symfony 2.5 and 2.6. // @deprecated since version 2.7, to be removed in 3.0 - $container->setParameter('validator.api', $config['api']); + $container->setParameter('validator.api', '2.5-bc'); } private function getValidatorMappingFiles(ContainerBuilder $container) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 557c9be37d01..617be624fdb9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -153,7 +153,6 @@ protected static function getBundleDefaultConfig() 'static_method' => array('loadValidatorMetadata'), 'translation_domain' => 'validators', 'strict_email' => false, - 'api' => '2.5-bc', ), 'annotations' => array( 'cache' => 'file', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_api.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_api.php deleted file mode 100644 index 9fa01821b8db..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_api.php +++ /dev/null @@ -1,9 +0,0 @@ -loadFromExtension('framework', array( - 'secret' => 's3cr3t', - 'validation' => array( - 'enabled' => true, - 'api' => '2.5', - ), -)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_bc_api.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_bc_api.php deleted file mode 100644 index e975ee3cdd0f..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_2_5_bc_api.php +++ /dev/null @@ -1,9 +0,0 @@ -loadFromExtension('framework', array( - 'secret' => 's3cr3t', - 'validation' => array( - 'enabled' => true, - 'api' => '2.5-bc', - ), -)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_api.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_api.php deleted file mode 100644 index 4133928ff44c..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_auto_api.php +++ /dev/null @@ -1,9 +0,0 @@ -loadFromExtension('framework', array( - 'secret' => 's3cr3t', - 'validation' => array( - 'enabled' => true, - 'api' => 'auto', - ), -)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_implicit_api.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_implicit_api.php deleted file mode 100644 index 9eae9998cc93..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/validation_implicit_api.php +++ /dev/null @@ -1,8 +0,0 @@ -loadFromExtension('framework', array( - 'secret' => 's3cr3t', - 'validation' => array( - 'enabled' => true, - ), -)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_api.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_api.xml deleted file mode 100644 index 213d281f4b1a..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_api.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_bc_api.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_bc_api.xml deleted file mode 100644 index 38eff2fddd06..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_2_5_bc_api.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_api.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_api.xml deleted file mode 100644 index 2be409bfb666..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_auto_api.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_implicit_api.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_implicit_api.xml deleted file mode 100644 index a41c8f23c9c6..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/validation_implicit_api.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_api.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_api.yml deleted file mode 100644 index d1af6c4e27c6..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_api.yml +++ /dev/null @@ -1,5 +0,0 @@ -framework: - secret: s3cr3t - validation: - enabled: true - api: 2.5 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_bc_api.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_bc_api.yml deleted file mode 100644 index ebf12e06f843..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_2_5_bc_api.yml +++ /dev/null @@ -1,5 +0,0 @@ -framework: - secret: s3cr3t - validation: - enabled: true - api: 2.5-bc diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_api.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_api.yml deleted file mode 100644 index 27619e63ed7a..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_auto_api.yml +++ /dev/null @@ -1,5 +0,0 @@ -framework: - secret: s3cr3t - validation: - enabled: true - api: auto diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_implicit_api.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_implicit_api.yml deleted file mode 100644 index 9b3aa6301053..000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/validation_implicit_api.yml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - secret: s3cr3t - validation: - enabled: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 54d2b19ac769..f23c1b6bd447 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -276,7 +276,7 @@ public function testValidation() $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - $this->assertCount(7, $calls); + $this->assertCount(6, $calls); $this->assertSame('setConstraintValidatorFactory', $calls[0][0]); $this->assertEquals(array(new Reference('validator.validator_factory')), $calls[0][1]); $this->assertSame('setTranslator', $calls[1][0]); @@ -289,8 +289,6 @@ public function testValidation() $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); $this->assertSame('setMetadataCache', $calls[5][0]); $this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]); - $this->assertSame('setApiVersion', $calls[6][0]); - $this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]); } /** @@ -337,7 +335,7 @@ public function testValidationAnnotations() $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - $this->assertCount(7, $calls); + $this->assertCount(6, $calls); $this->assertSame('enableAnnotationMapping', $calls[4][0]); $this->assertEquals(array(new Reference('annotation_reader')), $calls[4][1]); $this->assertSame('addMethodMapping', $calls[5][0]); @@ -355,7 +353,7 @@ public function testValidationPaths() $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - $this->assertCount(8, $calls); + $this->assertCount(7, $calls); $this->assertSame('addXmlMappings', $calls[3][0]); $this->assertSame('addYamlMappings', $calls[4][0]); $this->assertSame('enableAnnotationMapping', $calls[5][0]); @@ -378,79 +376,11 @@ public function testValidationNoStaticMethod() $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - $this->assertCount(5, $calls); + $this->assertCount(4, $calls); $this->assertSame('addXmlMappings', $calls[3][0]); // no cache, no annotations, no static methods } - public function testValidation2Dot5Api() - { - $container = $this->createContainerFromFile('validation_2_5_api'); - - $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - - $this->assertCount(6, $calls); - $this->assertSame('addXmlMappings', $calls[3][0]); - $this->assertSame('addMethodMapping', $calls[4][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); - $this->assertSame('setApiVersion', $calls[5][0]); - $this->assertSame(array(Validation::API_VERSION_2_5), $calls[5][1]); - $this->assertSame('Symfony\Component\Validator\Validator\ValidatorInterface', $container->getParameter('validator.class')); - // no cache, no annotations - } - - public function testValidation2Dot5BcApi() - { - $container = $this->createContainerFromFile('validation_2_5_bc_api'); - - $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - - $this->assertCount(6, $calls); - $this->assertSame('addXmlMappings', $calls[3][0]); - $this->assertSame('addMethodMapping', $calls[4][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); - $this->assertSame('setApiVersion', $calls[5][0]); - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - $this->assertSame('Symfony\Component\Validator\ValidatorInterface', $container->getParameter('validator.class')); - // no cache, no annotations - } - - public function testValidationImplicitApi() - { - $container = $this->createContainerFromFile('validation_implicit_api'); - - $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - - $this->assertCount(6, $calls); - $this->assertSame('addXmlMappings', $calls[3][0]); - $this->assertSame('addMethodMapping', $calls[4][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); - $this->assertSame('setApiVersion', $calls[5][0]); - // no cache, no annotations - - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - } - - /** - * This feature is equivalent to the implicit api, only that the "api" - * key is explicitly set to "auto". - */ - public function testValidationAutoApi() - { - $container = $this->createContainerFromFile('validation_auto_api'); - - $calls = $container->getDefinition('validator.builder')->getMethodCalls(); - - $this->assertCount(6, $calls); - $this->assertSame('addXmlMappings', $calls[3][0]); - $this->assertSame('addMethodMapping', $calls[4][0]); - $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); - $this->assertSame('setApiVersion', $calls[5][0]); - // no cache, no annotations - - $this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]); - } - public function testFormsCanBeEnabledWithoutCsrfProtection() { $container = $this->createContainerFromFile('form_no_csrf'); diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index 0079d23272bb..39f7d1506d64 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -14,13 +14,14 @@ use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\ClassBasedInterface; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; -use Symfony\Component\Validator\Exception\BadMethodCallException; use Symfony\Component\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; use Symfony\Component\Validator\Util\PropertyPath; use Symfony\Component\Validator\Validator\ValidatorInterface; +use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; use Symfony\Component\Validator\Violation\ConstraintViolationBuilder; /** @@ -187,11 +188,17 @@ public function addViolation($message, array $parameters = array(), $invalidValu // API, as they are not present in the new interface anymore. // You should use buildViolation() instead. if (func_num_args() > 2) { - throw new BadMethodCallException( - 'The parameters $invalidValue, $plural and $code are '. - 'not supported anymore as of Symfony 2.5. Please use '. - 'buildViolation() instead or enable the legacy mode.' - ); + trigger_error('The parameters $invalidValue, $plural and $code in method '.__METHOD__.' are deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED); + + $this + ->buildViolation($message, $parameters) + ->setInvalidValue($invalidValue) + ->setPlural($plural) + ->setCode($code) + ->addViolation() + ; + + return; } $this->violations->add(new ConstraintViolation( @@ -310,10 +317,26 @@ public function getPropertyPath($subPath = '') */ public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) { - throw new BadMethodCallException( - 'addViolationAt() is not supported anymore as of Symfony 2.5. '. - 'Please use buildViolation() instead or enable the legacy mode.' - ); + trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED); + + if (func_num_args() > 2) { + $this + ->buildViolation($message, $parameters) + ->atPath($subPath) + ->setInvalidValue($invalidValue) + ->setPlural($plural) + ->setCode($code) + ->addViolation() + ; + + return; + } + + $this + ->buildViolation($message, $parameters) + ->atPath($subPath) + ->addViolation() + ; } /** @@ -321,10 +344,37 @@ public function addViolationAt($subPath, $message, array $parameters = array(), */ public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false) { - throw new BadMethodCallException( - 'validate() is not supported anymore as of Symfony 2.5. '. - 'Please use getValidator() instead or enable the legacy mode.' - ); + trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator() method instead.', E_USER_DEPRECATED); + + if (is_array($value)) { + // The $traverse flag is ignored for arrays + $constraint = new Valid(array('traverse' => true, 'deep' => $deep)); + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, $constraint, $groups) + ; + } + + if ($traverse && $value instanceof \Traversable) { + $constraint = new Valid(array('traverse' => true, 'deep' => $deep)); + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, $constraint, $groups) + ; + } + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, null, $groups) + ; } /** @@ -332,10 +382,14 @@ public function validate($value, $subPath = '', $groups = null, $traverse = fals */ public function validateValue($value, $constraints, $subPath = '', $groups = null) { - throw new BadMethodCallException( - 'validateValue() is not supported anymore as of Symfony 2.5. '. - 'Please use getValidator() instead or enable the legacy mode.' - ); + trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator() method instead.', E_USER_DEPRECATED); + + return $this + ->getValidator() + ->inContext($this) + ->atPath($subPath) + ->validate($value, $constraints, $groups) + ; } /** @@ -343,11 +397,16 @@ public function validateValue($value, $constraints, $subPath = '', $groups = nul */ public function getMetadataFactory() { - throw new BadMethodCallException( - 'getMetadataFactory() is not supported anymore as of Symfony 2.5. '. - 'Please use getValidator() in combination with getMetadataFor() '. - 'or hasMetadataFor() instead or enable the legacy mode.' - ); + trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the new Symfony\Component\Validator\Context\ExecutionContext::getValidator method in combination with Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED); + + $validator = $this->getValidator(); + + if ($validator instanceof LegacyValidatorInterface) { + return $validator->getMetadataFactory(); + } + + // The ValidatorInterface extends from the deprecated MetadataFactoryInterface, so return it when we don't have the factory instance itself + return $validator; } /** diff --git a/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php b/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php index 8ce6bdb304b4..5ee7a228c47d 100644 --- a/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php @@ -11,8 +11,9 @@ namespace Symfony\Component\Validator\Context; +trigger_error('The '.__NAMESPACE__.'\LegacyExecutionContext class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); + use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\MetadataFactoryInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -50,114 +51,4 @@ public function __construct(ValidatorInterface $validator, $root, MetadataFactor $this->metadataFactory = $metadataFactory; } - - /** - * {@inheritdoc} - */ - public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) - { - if (func_num_args() > 2) { - trigger_error('The parameters $invalidValue, $plural and $code in method '.__METHOD__.' are deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED); - - $this - ->buildViolation($message, $parameters) - ->setInvalidValue($invalidValue) - ->setPlural($plural) - ->setCode($code) - ->addViolation() - ; - - return; - } - - parent::addViolation($message, $parameters); - } - - /** - * {@inheritdoc} - */ - public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED); - - if (func_num_args() > 2) { - $this - ->buildViolation($message, $parameters) - ->atPath($subPath) - ->setInvalidValue($invalidValue) - ->setPlural($plural) - ->setCode($code) - ->addViolation() - ; - - return; - } - - $this - ->buildViolation($message, $parameters) - ->atPath($subPath) - ->addViolation() - ; - } - - /** - * {@inheritdoc} - */ - public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false) - { - if (is_array($value)) { - // The $traverse flag is ignored for arrays - $constraint = new Valid(array('traverse' => true, 'deep' => $deep)); - - return $this - ->getValidator() - ->inContext($this) - ->atPath($subPath) - ->validate($value, $constraint, $groups) - ; - } - - if ($traverse && $value instanceof \Traversable) { - $constraint = new Valid(array('traverse' => true, 'deep' => $deep)); - - return $this - ->getValidator() - ->inContext($this) - ->atPath($subPath) - ->validate($value, $constraint, $groups) - ; - } - - return $this - ->getValidator() - ->inContext($this) - ->atPath($subPath) - ->validate($value, null, $groups) - ; - } - - /** - * {@inheritdoc} - */ - public function validateValue($value, $constraints, $subPath = '', $groups = null) - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::validate method instead.', E_USER_DEPRECATED); - - return $this - ->getValidator() - ->inContext($this) - ->atPath($subPath) - ->validate($value, $constraints, $groups) - ; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFactory() - { - trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the new Symfony\Component\Validator\Context\ExecutionContext::getValidator method in combination with Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED); - - return $this->metadataFactory; - } } diff --git a/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php b/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php index c24c1fad3d6e..31fb4cbdde0e 100644 --- a/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php +++ b/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator\Context; +trigger_error('The '.__NAMESPACE__.'\LegacyExecutionContextFactory class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); + use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\MetadataFactoryInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php index bc081289139b..140f8e49b4e3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -21,7 +21,6 @@ use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\PropertyMetadata; -use Symfony\Component\Validator\Tests\Fixtures\StubGlobalExecutionContext; use Symfony\Component\Validator\Validation; /** @@ -303,7 +302,10 @@ protected function buildViolation($message) return new ConstraintViolationAssertion($this->context, $message, $this->constraint); } - abstract protected function getApiVersion(); + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } abstract protected function createValidator(); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php deleted file mode 100644 index 649bfe1c72e7..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyAllValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyAllValidatorLegacyApiTest extends AllValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php deleted file mode 100644 index 00b8a7ae6d1a..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyBlankValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyBlankValidatorLegacyApiTest extends BlankValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php deleted file mode 100644 index 8f3ea2b87cc6..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCallbackValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyCallbackValidatorLegacyApiTest extends CallbackValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php deleted file mode 100644 index e4b41846dda4..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCardSchemeValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyCardSchemeValidatorLegacyApiTest extends CardSchemeValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php deleted file mode 100644 index 9237df55138f..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyChoiceValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyChoiceValidatorLegacyApiTest extends ChoiceValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php deleted file mode 100644 index 45ca1df38555..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayLegacyApiTest.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @group legacy - */ -class LegacyCollectionValidatorArrayLegacyApiTest extends CollectionValidatorArrayTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php deleted file mode 100644 index f28aed3b1247..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorArrayObjectLegacyApiTest.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @group legacy - */ -class LegacyCollectionValidatorArrayObjectLegacyApiTest extends CollectionValidatorArrayObjectTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php deleted file mode 100644 index b04053f24682..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCollectionValidatorCustomArrayObjectLegacyApiTest.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @group legacy - */ -class LegacyCollectionValidatorCustomArrayObjectLegacyApiTest extends CollectionValidatorCustomArrayObjectTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php deleted file mode 100644 index d36298811c85..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorArrayLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyCountValidatorArrayLegacyApiTest extends CountValidatorArrayTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php deleted file mode 100644 index 33b87957bff2..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCountValidatorCountableLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyCountValidatorCountableLegacyApiTest extends CountValidatorCountableTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php deleted file mode 100644 index 85cd5d0a6aaa..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyCurrencyValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyCurrencyValidatorLegacyApiTest extends CurrencyValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php deleted file mode 100644 index be19302fcf35..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyDateTimeValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyDateTimeValidatorLegacyApiTest extends DateTimeValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php deleted file mode 100644 index 3235f42312e4..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyDateValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyDateValidatorLegacyApiTest extends DateValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php deleted file mode 100644 index e5f101961ee9..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyEmailValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyEmailValidatorLegacyApiTest extends EmailValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php deleted file mode 100644 index 3a72cfbf5030..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyEqualToValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyEqualToValidatorLegacyApiTest extends EqualToValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php deleted file mode 100644 index 374bba085071..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyExpressionValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyExpressionValidatorLegacyApiTest extends ExpressionValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php deleted file mode 100644 index 5f7cb12bdb15..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyFalseValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyFalseValidatorLegacyApiTest extends FalseValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php deleted file mode 100644 index 97d5f5969003..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorObjectLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyFileValidatorObjectLegacyApiTest extends FileValidatorObjectTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php deleted file mode 100644 index 2c298dffcfe0..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyFileValidatorPathLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyFileValidatorPathLegacyApiTest extends FileValidatorPathTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php deleted file mode 100644 index 08822a53bdea..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanOrEqualValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyGreaterThanOrEqualValidatorLegacyApiTest extends GreaterThanOrEqualValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php deleted file mode 100644 index 0808e9bd15a6..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyGreaterThanValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyGreaterThanValidatorLegacyApiTest extends GreaterThanValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php deleted file mode 100644 index 0ffc4b150658..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIbanValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyIbanValidatorLegacyApiTest extends IbanValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php deleted file mode 100644 index aade84f65c22..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIdenticalToValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyIdenticalToValidatorLegacyApiTest extends IdenticalToValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php deleted file mode 100644 index d36c1752f3e8..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyImageValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyImageValidatorLegacyApiTest extends ImageValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php deleted file mode 100644 index 315f2f9ccf81..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIpValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyIpValidatorLegacyApiTest extends IpValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php deleted file mode 100644 index 156827090bc0..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIsbnValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyIsbnValidatorLegacyApiTest extends IsbnValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php deleted file mode 100644 index 2ff310416d2a..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyIssnValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyIssnValidatorLegacyApiTest extends IssnValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php deleted file mode 100644 index a6471b3d3bdc..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLanguageValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyLanguageValidatorLegacyApiTest extends LanguageValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php deleted file mode 100644 index 655f3d6adb30..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLengthValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyLengthValidatorLegacyApiTest extends LengthValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php deleted file mode 100644 index 2e07ab02cac0..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanOrEqualValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyLessThanOrEqualValidatorLegacyApiTest extends LessThanOrEqualValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php deleted file mode 100644 index 27592b0afc0b..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLessThanValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyLessThanValidatorLegacyApiTest extends LessThanValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php deleted file mode 100644 index f55d42205fc2..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLocaleValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyLocaleValidatorLegacyApiTest extends LocaleValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php deleted file mode 100644 index 58555266e9eb..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyLuhnValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyLuhnValidatorLegacyApiTest extends LuhnValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php deleted file mode 100644 index 0aaaa77c442e..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotBlankValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyNotBlankValidatorLegacyApiTest extends NotBlankValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php deleted file mode 100644 index df88f96b5405..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotEqualToValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyNotEqualToValidatorLegacyApiTest extends NotEqualToValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php deleted file mode 100644 index 25819a622fcb..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotIdenticalToValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyNotIdenticalToValidatorLegacyApiTest extends NotIdenticalToValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php deleted file mode 100644 index 41a9e5407c00..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNotNullValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyNotNullValidatorLegacyApiTest extends NotNullValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php deleted file mode 100644 index 79536ced6ba1..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyNullValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyNullValidatorLegacyApiTest extends NullValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php deleted file mode 100644 index 866a59adfeb0..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyRangeValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyRangeValidatorLegacyApiTest extends RangeValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php deleted file mode 100644 index ed1a4648c21d..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyRegexValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyRegexValidatorLegacyApiTest extends RegexValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php deleted file mode 100644 index 2458d873ac80..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyTimeValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyTimeValidatorLegacyApiTest extends TimeValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php deleted file mode 100644 index 706c08373ce1..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyTrueValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyTrueValidatorLegacyApiTest extends TrueValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php deleted file mode 100644 index 26eb39ffb126..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyTypeValidatorLegacyApiTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyTypeValidatorLegacyApiTest extends TypeValidatorTest -{ - protected static $file; - - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php deleted file mode 100644 index 0830ddb40fa6..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyUrlValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyUrlValidatorLegacyApiTest extends UrlValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php deleted file mode 100644 index 4a4e36298b7b..000000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LegacyUuidValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyUuidValidatorLegacyApiTest extends UuidValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/src/Symfony/Component/Validator/Validator/LegacyValidator.php b/src/Symfony/Component/Validator/Validator/LegacyValidator.php index f73a79ef0e26..6c5a10c35559 100644 --- a/src/Symfony/Component/Validator/Validator/LegacyValidator.php +++ b/src/Symfony/Component/Validator/Validator/LegacyValidator.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Validator\Validator; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; +trigger_error('The '.__NAMESPACE__.'\LegacyValidator class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); /** * A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+. @@ -24,26 +24,6 @@ * * @deprecated since version 2.5, to be removed in 3.0. */ -class LegacyValidator extends RecursiveValidator implements LegacyValidatorInterface +class LegacyValidator extends RecursiveValidator { - public function validate($value, $groups = null, $traverse = false, $deep = false) - { - trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); - - return parent::validate($value, false, $groups, $traverse, $deep); - } - - public function validateValue($value, $constraints, $groups = null) - { - trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); - - return parent::validate($value, $constraints, $groups); - } - - public function getMetadataFactory() - { - trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED); - - return $this->metadataFactory; - } } diff --git a/src/Symfony/Component/Validator/Validator/RecursiveValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveValidator.php index 7cfbc27fbf0d..c825bfa6f48b 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveValidator.php @@ -19,6 +19,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\MetadataFactoryInterface; use Symfony\Component\Validator\ObjectInitializerInterface; +use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; /** * Recursive implementation of {@link ValidatorInterface}. @@ -26,7 +27,7 @@ * @since 2.5 * @author Bernhard Schussek */ -class RecursiveValidator implements ValidatorInterface +class RecursiveValidator implements ValidatorInterface, LegacyValidatorInterface { /** * @var ExecutionContextFactoryInterface @@ -113,22 +114,19 @@ public function hasMetadataFor($object) /** * {@inheritdoc} */ - public function validate($value, $constraints = null, $groups = null) + public function validate($value, $groups = null, $traverse = false, $deep = false) { - // The following code must be removed in 3.0 $numArgs = func_num_args(); - if ($numArgs > 3) { - trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); - $traverse = func_get_arg(3); - $deep = func_get_arg(4); - $constraints = new Valid(array('traverse' => $traverse, 'deep' => $deep)); - if (self::testConstraints($groups)) { - if ((!$traverse && !$deep) || self::testGroups($traverse)) { - $constraints = $groups; - $groups = $traverse; - } - } + // Use new signature if constraints are given in the second argument + if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) { + // Rename to avoid total confusion ;) + $constraints = $groups; + $groups = $traverse; + } else { + trigger_error('The Symfony\Component\Validator\ValidatorInterface::validate method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); + + $constraints = new Valid(array('traverse' => $traverse, 'deep' => $deep)); } return $this->startContext($value) @@ -158,18 +156,30 @@ public function validatePropertyValue($objectOrClass, $propertyName, $value, $gr } /** - * @internal - * @deprecated since version 2.5, to be removed in 3.0. + * {@inheritdoc} */ - private static function testConstraints($constraints) + public function validateValue($value, $constraints, $groups = null) { - return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); + trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::validate method instead.', E_USER_DEPRECATED); + + return $this->validate($value, $constraints, $groups); } /** - * @internal - * @deprecated since version 2.5, to be removed in 3.0. + * {@inheritdoc} */ + public function getMetadataFactory() + { + trigger_error('The '.__METHOD__.' method is deprecated in version 2.5 and will be removed in version 3.0. Use the Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED); + + return $this->metadataFactory; + } + + private static function testConstraints($constraints) + { + return null === $constraints || $constraints instanceof Constraint || (is_array($constraints) && current($constraints) instanceof Constraint); + } + private static function testGroups($groups) { return null === $groups || is_string($groups) || $groups instanceof GroupSequence || (is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence));