diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index cf58c70f25..6fbd2a5abc 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -58,6 +58,8 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface */ public function getMessageTemplate() { + trigger_error('getMessageTemplate() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + return $this->messageTemplate; } @@ -68,6 +70,8 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface */ public function getMessageParameters() { + trigger_error('getMessageParameters() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + return $this->messageParameters; } @@ -78,6 +82,8 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface */ protected function setMessage($template, array $parameters = array()) { + trigger_error('setMessage() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + $this->messageTemplate = $template; $this->messageParameters = $parameters; @@ -107,5 +113,6 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface */ protected function isValid($value, Constraint $constraint) { + trigger_error('isValid() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); } } diff --git a/src/Symfony/Component/Validator/Constraints/Max.php b/src/Symfony/Component/Validator/Constraints/Max.php index 814fc1f339..9ca13704e0 100644 --- a/src/Symfony/Component/Validator/Constraints/Max.php +++ b/src/Symfony/Component/Validator/Constraints/Max.php @@ -26,6 +26,13 @@ class Max extends Constraint public $invalidMessage = 'This value should be a valid number.'; public $limit; + public function __construct($options = null) + { + trigger_error('Max is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + + parent::__construct($options); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/MaxLength.php b/src/Symfony/Component/Validator/Constraints/MaxLength.php index 765d548060..57b9bff7db 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxLength.php +++ b/src/Symfony/Component/Validator/Constraints/MaxLength.php @@ -26,6 +26,13 @@ class MaxLength extends Constraint public $limit; public $charset = 'UTF-8'; + public function __construct($options = null) + { + trigger_error('MaxLength is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + + parent::__construct($options); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php b/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php index 9b9e9b9f36..77ed383e66 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MaxLengthValidator.php @@ -24,6 +24,11 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; */ class MaxLengthValidator extends ConstraintValidator { + public function __construct($options = null) + { + trigger_error('MaxLengthValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/MaxValidator.php b/src/Symfony/Component/Validator/Constraints/MaxValidator.php index 2019d6994b..a35ae6b3aa 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MaxValidator.php @@ -23,6 +23,11 @@ use Symfony\Component\Validator\ConstraintValidator; */ class MaxValidator extends ConstraintValidator { + public function __construct($options = null) + { + trigger_error('MaxValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/Min.php b/src/Symfony/Component/Validator/Constraints/Min.php index 6e8b3649b7..2d8bf0f680 100644 --- a/src/Symfony/Component/Validator/Constraints/Min.php +++ b/src/Symfony/Component/Validator/Constraints/Min.php @@ -26,6 +26,13 @@ class Min extends Constraint public $invalidMessage = 'This value should be a valid number.'; public $limit; + public function __construct($options = null) + { + trigger_error('Min is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + + parent::__construct($options); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/MinLength.php b/src/Symfony/Component/Validator/Constraints/MinLength.php index 4457f6c160..78c5d2c99b 100644 --- a/src/Symfony/Component/Validator/Constraints/MinLength.php +++ b/src/Symfony/Component/Validator/Constraints/MinLength.php @@ -26,6 +26,13 @@ class MinLength extends Constraint public $limit; public $charset = 'UTF-8'; + public function __construct($options = null) + { + trigger_error('MinLength is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + + parent::__construct($options); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php b/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php index 80fcac417e..9b7038e4db 100644 --- a/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MinLengthValidator.php @@ -24,6 +24,11 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; */ class MinLengthValidator extends ConstraintValidator { + public function __construct($options = null) + { + trigger_error('MinLengthValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/MinValidator.php b/src/Symfony/Component/Validator/Constraints/MinValidator.php index c907793c62..117342ae00 100644 --- a/src/Symfony/Component/Validator/Constraints/MinValidator.php +++ b/src/Symfony/Component/Validator/Constraints/MinValidator.php @@ -23,6 +23,11 @@ use Symfony\Component\Validator\ConstraintValidator; */ class MinValidator extends ConstraintValidator { + public function __construct($options = null) + { + trigger_error('MinValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + } + /** * Checks if the passed value is valid. * diff --git a/src/Symfony/Component/Validator/ExecutionContext.php b/src/Symfony/Component/Validator/ExecutionContext.php index 9c2576d1e8..9f23082485 100644 --- a/src/Symfony/Component/Validator/ExecutionContext.php +++ b/src/Symfony/Component/Validator/ExecutionContext.php @@ -100,6 +100,8 @@ class ExecutionContext implements ExecutionContextInterface */ public function addViolationAtPath($propertyPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null) { + trigger_error('addViolationAtPath() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + $this->globalContext->getViolations()->add(new ConstraintViolation( $message, $params, @@ -124,10 +126,12 @@ class ExecutionContext implements ExecutionContextInterface * @param integer|null $code The violation code. * * @deprecated Deprecated since version 2.2, to be removed in 2.3. Use the - * method {@link atViolationAt} instead. + * method {@link addViolationAt} instead. */ public function addViolationAtSubPath($subPath, $message, array $params = array(), $invalidValue = null, $pluralization = null, $code = null) { + trigger_error('addViolationAtSubPath() is deprecated since version 2.2 and will be removed in 2.3. Use addViolationAt() instead.', E_USER_DEPRECATED); + if (func_num_args() >= 4) { $this->addViolationAt($subPath, $message, $params, $invalidValue, $pluralization, $code); } else { @@ -288,6 +292,8 @@ class ExecutionContext implements ExecutionContextInterface */ public function getCurrentClass() { + trigger_error('getCurrentClass() is deprecated since version 2.2 and will be removed in 2.3. Use getClassName() instead', E_USER_DEPRECATED); + return $this->getClassName(); } @@ -304,6 +310,8 @@ class ExecutionContext implements ExecutionContextInterface */ public function getCurrentProperty() { + trigger_error('getCurrentProperty() is deprecated since version 2.2 and will be removed in 2.3. Use getClassName() instead', E_USER_DEPRECATED); + return $this->getPropertyName(); } @@ -319,6 +327,8 @@ class ExecutionContext implements ExecutionContextInterface */ public function getCurrentValue() { + trigger_error('getCurrentValue() is deprecated since version 2.2 and will be removed in 2.3. Use getValue() instead', E_USER_DEPRECATED); + return $this->value; } @@ -332,6 +342,8 @@ class ExecutionContext implements ExecutionContextInterface */ public function getGraphWalker() { + trigger_error('getGraphWalker() is deprecated since version 2.2 and will be removed in 2.3. Use validate() and validateValue() instead', E_USER_DEPRECATED); + return $this->globalContext->getVisitor()->getGraphWalker(); } diff --git a/src/Symfony/Component/Validator/GraphWalker.php b/src/Symfony/Component/Validator/GraphWalker.php index 26177b0929..8af1a56153 100644 --- a/src/Symfony/Component/Validator/GraphWalker.php +++ b/src/Symfony/Component/Validator/GraphWalker.php @@ -55,6 +55,8 @@ class GraphWalker */ public function __construct(ValidationVisitor $visitor, MetadataFactoryInterface $metadataFactory, array &$validatedObjects = array()) { + trigger_error('GraphWalker is deprecated since version 2.2 and will be removed in 2.3. This class has been replaced by ValidationVisitorInterface and MetadataInterface.', E_USER_DEPRECATED); + $this->visitor = $visitor; $this->metadataFactory = $metadataFactory; $this->validatedObjects = &$validatedObjects; @@ -67,6 +69,8 @@ class GraphWalker */ public function getViolations() { + trigger_error('getViolations() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + return $this->visitor->getViolations(); } @@ -83,6 +87,8 @@ class GraphWalker */ public function walkObject(ClassMetadata $metadata, $object, $group, $propertyPath) { + trigger_error('walkObject() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + $hash = spl_object_hash($object); // Exit, if the object is already validated for the current group @@ -118,6 +124,8 @@ class GraphWalker */ public function walkProperty(ClassMetadata $metadata, $property, $object, $group, $propertyPath, $propagatedGroup = null) { + trigger_error('walkProperty() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + if (!is_object($object)) { throw new UnexpectedTypeException($object, 'object'); } @@ -140,6 +148,8 @@ class GraphWalker */ public function walkPropertyValue(ClassMetadata $metadata, $property, $value, $group, $propertyPath) { + trigger_error('walkPropertyValue() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + foreach ($metadata->getMemberMetadatas($property) as $member) { $member->accept($this->visitor, $value, $group, $propertyPath); } @@ -163,6 +173,8 @@ class GraphWalker */ public function walkReference($value, $group, $propertyPath, $traverse, $deep = false) { + trigger_error('walkReference() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + $this->visitor->validate($value, $group, $propertyPath, $traverse, $deep); } @@ -180,6 +192,8 @@ class GraphWalker */ public function walkConstraint(Constraint $constraint, $value, $group, $propertyPath, $currentClass = null, $currentProperty = null) { + trigger_error('walkConstraint() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + $metadata = null; // BC code to make getCurrentClass() and getCurrentProperty() work when diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php index 279d833455..ef6d617ff6 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php @@ -118,6 +118,8 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface, MetadataFac */ public function getClassMetadata($class) { + trigger_error('getClassMetadata() is deprecated since version 2.2 and will be removed in 2.3. Use getMetadataFor() instead.', E_USER_DEPRECATED); + return $this->getMetadataFor($class); } } diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index 7db22a84de..ee9c6839ec 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -194,6 +194,8 @@ abstract class MemberMetadata extends ElementMetadata implements PropertyMetadat */ public function getValue($object) { + trigger_error('getValue() is deprecated since version 2.2 and will be removed in 2.3. Use getPropertyValue() instead.', E_USER_DEPRECATED); + return $this->getPropertyValue($object); } diff --git a/src/Symfony/Component/Validator/ValidationVisitor.php b/src/Symfony/Component/Validator/ValidationVisitor.php index c8268304cd..fb5200919e 100644 --- a/src/Symfony/Component/Validator/ValidationVisitor.php +++ b/src/Symfony/Component/Validator/ValidationVisitor.php @@ -155,6 +155,8 @@ class ValidationVisitor implements ValidationVisitorInterface, GlobalExecutionCo */ public function getGraphWalker() { + trigger_error('getGraphWalker() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED); + if (null === $this->graphWalker) { $this->graphWalker = new GraphWalker($this, $this->metadataFactory, $this->validatedObjects); } diff --git a/src/Symfony/Component/Validator/ValidatorContext.php b/src/Symfony/Component/Validator/ValidatorContext.php index c2f6880a35..9c8ec3d043 100644 --- a/src/Symfony/Component/Validator/ValidatorContext.php +++ b/src/Symfony/Component/Validator/ValidatorContext.php @@ -49,6 +49,8 @@ class ValidatorContext implements ValidatorContextInterface */ public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory) { + trigger_error('setClassMetadataFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); + if ($classMetadataFactory instanceof MetadataFactoryInterface) { $this->metadataFactory = $classMetadataFactory; } else { @@ -68,6 +70,8 @@ class ValidatorContext implements ValidatorContextInterface */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory) { + trigger_error('setConstraintValidatorFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); + $this->constraintValidatorFactory = $constraintValidatorFactory; return $this; @@ -81,6 +85,8 @@ class ValidatorContext implements ValidatorContextInterface */ public function getValidator() { + trigger_error('getValidator() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidator() instead.', E_USER_DEPRECATED); + return new Validator( $this->metadataFactory, $this->constraintValidatorFactory @@ -96,6 +102,8 @@ class ValidatorContext implements ValidatorContextInterface */ public function getClassMetadataFactory() { + trigger_error('getClassMetadataFactory() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + return $this->classMetadataFactory; } @@ -108,6 +116,8 @@ class ValidatorContext implements ValidatorContextInterface */ public function getConstraintValidatorFactory() { + trigger_error('getConstraintValidatorFactory() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED); + return $this->constraintValidatorFactory; } } diff --git a/src/Symfony/Component/Validator/ValidatorFactory.php b/src/Symfony/Component/Validator/ValidatorFactory.php index 5e16b2e318..85522cd13e 100644 --- a/src/Symfony/Component/Validator/ValidatorFactory.php +++ b/src/Symfony/Component/Validator/ValidatorFactory.php @@ -109,6 +109,8 @@ class ValidatorFactory implements ValidatorContextInterface */ public static function buildDefault(array $mappingFiles = array(), $annotations = false, $staticMethod = null) { + trigger_error('buildDefault() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); + $xmlMappingFiles = array(); $yamlMappingFiles = array(); $loaders = array(); @@ -170,6 +172,8 @@ class ValidatorFactory implements ValidatorContextInterface */ public function __construct(ValidatorContextInterface $defaultContext = null) { + trigger_error('ValidatorFactory is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); + $this->defaultContext = null === $defaultContext ? new ValidatorContext() : $defaultContext; } @@ -186,6 +190,8 @@ class ValidatorFactory implements ValidatorContextInterface */ public function setClassMetadataFactory(ClassMetadataFactoryInterface $metadataFactory) { + trigger_error('setClassMetadataFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); + $context = clone $this->defaultContext; return $context->setClassMetadataFactory($metadataFactory); @@ -204,6 +210,8 @@ class ValidatorFactory implements ValidatorContextInterface */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory) { + trigger_error('setConstraintValidatorFactory() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidatorBuilder() instead.', E_USER_DEPRECATED); + $context = clone $this->defaultContext; return $context->setConstraintValidatorFactory($validatorFactory); @@ -219,6 +227,8 @@ class ValidatorFactory implements ValidatorContextInterface */ public function getValidator() { + trigger_error('getValidator() is deprecated since version 2.1 and will be removed in 2.3. Use Validation::createValidator() instead.', E_USER_DEPRECATED); + return $this->defaultContext->getValidator(); } }