[Validator] adds more deprecation notices.

This commit is contained in:
Hugo Hamon 2014-12-30 12:10:06 +01:00
parent a7f841e854
commit cd9617a6a4
14 changed files with 99 additions and 46 deletions

View File

@ -61,7 +61,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
*
* @return ConstraintViolationBuilderInterface The violation builder
*
* @deprecated This method will be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
*/
protected function buildViolation($message, array $parameters = array())
{
@ -84,7 +84,7 @@ abstract class ConstraintValidator implements ConstraintValidatorInterface
*
* @return ConstraintViolationBuilderInterface The violation builder
*
* @deprecated This method will be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
*/
protected function buildViolationInContext(ExecutionContextInterface $context, $message, array $parameters = array())
{

View File

@ -97,12 +97,13 @@ class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Returns an iterator for this group.
*
* Implemented for backwards compatibility with Symfony < 2.5.
*
* @return \Traversable The iterator
*
* @see \IteratorAggregate::getIterator()
*
* @deprecated Implemented for backwards compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in Symfony 3.0.
*/
public function getIterator()
{
@ -114,12 +115,13 @@ class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Returns whether the given offset exists in the sequence.
*
* Implemented for backwards compatibility with Symfony < 2.5.
*
* @param int $offset The offset
*
* @return bool Whether the offset exists
*
* @deprecated Implemented for backwards compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in Symfony 3.0.
*/
public function offsetExists($offset)
{
@ -131,14 +133,15 @@ class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Returns the group at the given offset.
*
* Implemented for backwards compatibility with Symfony < 2.5.
*
* @param int $offset The offset
*
* @return string The group a the given offset
*
* @throws OutOfBoundsException If the object does not exist
*
* @deprecated Implemented for backwards compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in Symfony 3.0.
*/
public function offsetGet($offset)
{
@ -157,11 +160,12 @@ class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Sets the group at the given offset.
*
* Implemented for backwards compatibility with Symfony < 2.5.
*
* @param int $offset The offset
* @param string $value The group name
*
* @deprecated Implemented for backwards compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in Symfony 3.0.
*/
public function offsetSet($offset, $value)
{
@ -179,10 +183,11 @@ class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Removes the group at the given offset.
*
* Implemented for backwards compatibility with Symfony < 2.5.
*
* @param int $offset The offset
*
* @deprecated Implemented for backwards compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in Symfony 3.0.
*/
public function offsetUnset($offset)
{
@ -194,10 +199,11 @@ class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Returns the number of groups in the sequence.
*
* Implemented for backwards compatibility with Symfony < 2.5.
*
* @return int The number of groups
*
* @deprecated Implemented for backwards compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in Symfony 3.0.
*/
public function count()
{

View File

@ -187,8 +187,10 @@ class ExecutionContext implements ExecutionContextInterface
// API, as they are not present in the new interface anymore.
// You should use buildViolation() instead.
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);
throw new BadMethodCallException(
'The parameters $invalidValue, $pluralization and $code are '.
'The parameters $invalidValue, $plural and $code are '.
'not supported anymore as of Symfony 2.5. Please use '.
'buildViolation() instead or enable the legacy mode.'
);
@ -286,7 +288,13 @@ class ExecutionContext implements ExecutionContextInterface
*/
public function getClassName()
{
return $this->metadata instanceof ClassBasedInterface ? $this->metadata->getClassName() : null;
if ($this->metadata instanceof ClassBasedInterface) {
trigger_error('The Symfony\Component\Validator\ClassBasedInterface interface is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
return $this->metadata->getClassName();
}
return null;
}
/**
@ -310,6 +318,8 @@ class ExecutionContext implements ExecutionContextInterface
*/
public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null)
{
trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::buildViolation method instead.', E_USER_DEPRECATED);
throw new BadMethodCallException(
'addViolationAt() is not supported anymore as of Symfony 2.5. '.
'Please use buildViolation() instead or enable the legacy mode.'
@ -321,7 +331,7 @@ class ExecutionContext implements ExecutionContextInterface
*/
public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false)
{
trigger_error('ExecutionContext::validate() is deprecated since version 2.5 and will be removed in 3.0. Use ExecutionContext::getValidator() together with inContext() instead.', E_USER_DEPRECATED);
trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator method together with Symfony\Component\Validator\Validator\ValidatorInterface::inContext method instead.', E_USER_DEPRECATED);
throw new BadMethodCallException(
'validate() is not supported anymore as of Symfony 2.5. '.
@ -334,7 +344,7 @@ class ExecutionContext implements ExecutionContextInterface
*/
public function validateValue($value, $constraints, $subPath = '', $groups = null)
{
trigger_error('ExecutionContext::validateValue() is deprecated since version 2.5 and will be removed in 3.0. Use ExecutionContext::getValidator() together with inContext() instead.', E_USER_DEPRECATED);
trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator method together with Symfony\Component\Validator\Validator\ValidatorInterface::inContext method instead.', E_USER_DEPRECATED);
throw new BadMethodCallException(
'validateValue() is not supported anymore as of Symfony 2.5. '.
@ -347,6 +357,8 @@ class ExecutionContext implements ExecutionContextInterface
*/
public function getMetadataFactory()
{
trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0. Use the '.__CLASS__.'::getValidator method together with Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFor or Symfony\Component\Validator\Validator\ValidatorInterface::hasMetadataFor method instead.', E_USER_DEPRECATED);
throw new BadMethodCallException(
'getMetadataFactory() is not supported anymore as of Symfony 2.5. '.
'Please use getValidator() in combination with getMetadataFor() '.

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Validator\Context;
trigger_error('The '.__NAMESPACE__.'\LegacyExecutionContext class is deprecated since version 2.5 and will be removed in 3.0. Use the new Symfony\Component\Validator\Context\ExecutionContext class instead.', E_USER_DEPRECATED);
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\MetadataFactoryInterface;
@ -24,8 +22,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
* @since 2.5
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Implemented for backward compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
*/
class LegacyExecutionContext extends ExecutionContext
{
@ -44,6 +41,8 @@ class LegacyExecutionContext extends ExecutionContext
*/
public function __construct(ValidatorInterface $validator, $root, MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null)
{
trigger_error('The '.__CLASS__.' class is deprecated since version 2.5 and will be removed in 3.0. Use the new Symfony\Component\Validator\Context\ExecutionContext class instead.', E_USER_DEPRECATED);
parent::__construct(
$validator,
$root,
@ -60,6 +59,8 @@ class LegacyExecutionContext extends ExecutionContext
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)
@ -79,6 +80,8 @@ class LegacyExecutionContext extends ExecutionContext
*/
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)
@ -140,6 +143,8 @@ class LegacyExecutionContext extends ExecutionContext
*/
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)
@ -153,6 +158,8 @@ class LegacyExecutionContext extends ExecutionContext
*/
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;
}
}

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Validator\Context;
trigger_error('The '.__NAMESPACE__.'\LegacyExecutionContextFactory is deprecated since version 2.5 and will be removed in 3.0.');
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\MetadataFactoryInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
@ -18,11 +20,12 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Creates new {@link LegacyExecutionContext} instances.
*
* Implemented for backward compatibility with Symfony < 2.5.
*
* @since 2.5
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated Implemented for backward compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
*/
class LegacyExecutionContextFactory implements ExecutionContextFactoryInterface
{

View File

@ -99,9 +99,9 @@ interface ExecutionContextInterface
*
* @api
*
* @deprecated The parameters $invalidValue, $pluralization and $code are
* deprecated since version 2.5 and will be removed in
* Symfony 3.0.
* @deprecated since version 2.5.
* The parameters $invalidValue, $plural and $code will be removed
* in 3.0.
*/
public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null);

View File

@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Mapping\Deprecated;
trigger_error('Constants STOP_RECURSION in class Symfony\Component\Validator\Mapping\TraversalStrategy is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
/**
* @deprecated since version 2.7, to be removed in 3.0.
* @internal
*/
final class TraversalStrategy
{
const STOP_RECURSION = 8;
private function __construct()
{
}
}

View File

@ -231,10 +231,11 @@ class GenericMetadata implements MetadataInterface
*
* Should not be used.
*
* Implemented for backward compatibility with Symfony < 2.5.
*
* @throws BadMethodCallException
*
* @deprecated Implemented for backward compatibility with Symfony < 2.5.
* Will be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
*/
public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath)
{

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Mapping\Deprecated\TraversalStrategy as Deprecated;
/**
* Specifies whether and how a traversable object should be traversed.
*
@ -51,10 +53,11 @@ class TraversalStrategy
* Specifies that nested instances of {@link \Traversable} should never be
* iterated. Can be combined with {@link IMPLICIT} or {@link TRAVERSE}.
*
* @deprecated This constant was added for backward compatibility only.
* It will be removed in Symfony 3.0.
* This constant was added for backward compatibility only.
*
* @deprecated since version 2.5, to be removed in 3.0.
*/
const STOP_RECURSION = 8;
const STOP_RECURSION = Deprecated::STOP_RECURSION;
/**
* Not instantiable.

View File

@ -81,8 +81,6 @@ class ValidationVisitor implements ValidationVisitorInterface, GlobalExecutionCo
*/
public function __construct($root, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, TranslatorInterface $translator, $translationDomain = null, array $objectInitializers = array())
{
trigger_error('Symfony\Component\Validator\ValidationVisitor was deprecated in version 2.5 and will be removed in version 3.0.', E_USER_DEPRECATED);
foreach ($objectInitializers as $initializer) {
if (!$initializer instanceof ObjectInitializerInterface) {
throw new UnexpectedTypeException($initializer, 'Symfony\Component\Validator\ObjectInitializerInterface');

View File

@ -64,8 +64,6 @@ interface ValidationVisitorInterface
*
* @throws Exception\NoSuchMetadataException If no metadata can be found for
* the given value.
*
* @deprecated since version 2.5, to be removed in 3.0.
*/
public function validate($value, $group, $propertyPath, $traverse = false, $deep = false);
@ -79,8 +77,6 @@ interface ValidationVisitorInterface
* @param mixed $value The value to validate.
* @param string $group The validation group to validate.
* @param string $propertyPath The current property path in the validation graph.
*
* @deprecated since version 2.5, to be removed in 3.0.
*/
public function visit(MetadataInterface $metadata, $value, $group, $propertyPath);
}

View File

@ -34,8 +34,7 @@ use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
* @see \Symfony\Component\Validator\ValidatorInterface
* @see \Symfony\Component\Validator\Validator\ValidatorInterface
*
* @deprecated Implemented for backward compatibility with Symfony < 2.5.
* To be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
*/
class LegacyValidator extends RecursiveValidator implements LegacyValidatorInterface
{
@ -52,7 +51,7 @@ class LegacyValidator extends RecursiveValidator implements LegacyValidatorInter
return parent::validate($value, $constraints, $groups);
}
trigger_error('The Symfony\Component\Validator\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);
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));
@ -61,14 +60,14 @@ class LegacyValidator extends RecursiveValidator implements LegacyValidatorInter
public function validateValue($value, $constraints, $groups = null)
{
trigger_error('The Symfony\Component\Validator\Validator\ValidatorInterface::validateValue 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);
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 Symfony\Component\Validator\Validator\ValidatorInterface::getMetadataFactory 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);
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;
}

View File

@ -93,8 +93,9 @@ interface ValidatorInterface
*
* @api
*
* @deprecated Renamed to {@link Validator\ValidatorInterface::validate()}
* in Symfony 2.5. Will be removed in Symfony 3.0.
* @deprecated since version 2.5, to be removed in 3.0.
* Renamed to {@link Validator\ValidatorInterface::validate()}
* in Symfony 2.5.
*/
public function validateValue($value, $constraints, $groups = null);

View File

@ -23,7 +23,7 @@ use Symfony\Component\Validator\ExecutionContextInterface;
* @internal You should not instantiate or use this class. Code against
* {@link ConstraintViolationBuilderInterface} instead.
*
* @deprecated This class will be removed in Symfony 3.0.
* @deprecated since version 2.5.5, to be removed in 3.0.
*/
class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInterface
{