diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index 6efeebc451818..8cf6ec0c8d1f7 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -22,7 +22,6 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator; use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; -use Symfony\Component\Validator\Validation; use Doctrine\ORM\Tools\SchemaTool; /** @@ -47,11 +46,6 @@ class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest */ protected $repository; - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function setUp() { $this->em = DoctrineTestHelper::createTestEntityManager(); diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 055ba7e55fe26..4cb6f30025fa1 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -13,7 +13,7 @@ use Symfony\Bridge\Twig\TokenParser\FormThemeTokenParser; use Symfony\Bridge\Twig\Form\TwigRendererInterface; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; +use Symfony\Component\Form\ChoiceList\View\ChoiceView; /** * FormExtension extends Twig with form capabilities. diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php index 2233a83a416bd..59710ca226522 100644 --- a/src/Symfony/Component/Form/AbstractExtension.php +++ b/src/Symfony/Component/Form/AbstractExtension.php @@ -156,15 +156,7 @@ private function initTypes() throw new UnexpectedTypeException($type, 'Symfony\Component\Form\FormTypeInterface'); } - // Since Symfony 3.0 types are identified by their FQCN - $fqcn = get_class($type); - $legacyName = $type->getName(); - - $this->types[$fqcn] = $type; - - if ($legacyName) { - $this->types[$legacyName] = $type; - } + $this->types[get_class($type)] = $type; } } diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component/Form/AbstractType.php index 709efa34f5661..9be91dfcede86 100644 --- a/src/Symfony/Component/Form/AbstractType.php +++ b/src/Symfony/Component/Form/AbstractType.php @@ -47,15 +47,6 @@ public function configureOptions(OptionsResolver $resolver) { } - /** - * {@inheritdoc} - */ - public function getName() - { - // As of Symfony 2.8, the name defaults to the fully-qualified class name - return get_class($this); - } - /** * Returns the prefix of the template block name for this type. * @@ -66,11 +57,7 @@ public function getName() */ public function getBlockPrefix() { - $fqcn = get_class($this); - $name = $this->getName(); - - // For BC: Use the name as block prefix if one is set - return $name !== $fqcn ? $name : StringUtil::fqcnToBlockPrefix($fqcn); + return StringUtil::fqcnToBlockPrefix(get_class($this)); } /** diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index b34b4bb863506..7ac93d94e099f 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -378,23 +378,6 @@ public function setByReference($byReference) throw new BadMethodCallException('Buttons do not support data mapping.'); } - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $virtual - * - * @throws BadMethodCallException - * - * @deprecated since version 2.3, to be removed in 3.0. Use - * {@link setInheritData()} instead. - */ - public function setVirtual($virtual) - { - throw new BadMethodCallException('Buttons cannot be virtual.'); - } - /** * Unsupported method. * @@ -587,21 +570,6 @@ public function getByReference() return false; } - /** - * Unsupported method. - * - * @return bool Always returns false. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link getInheritData()} instead. - */ - public function getVirtual() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\FormConfigBuilder::getInheritData method instead.', E_USER_DEPRECATED); - - return false; - } - /** * Unsupported method. * diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index ef93ffdd76336..f49be10c36392 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -15,12 +15,10 @@ use Symfony\Component\Form\ChoiceList\ArrayChoiceList; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\LazyChoiceList; -use Symfony\Component\Form\ChoiceList\LegacyChoiceListAdapter; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceListView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; -use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView; /** * Default implementation of {@link ChoiceListFactoryInterface}. @@ -65,23 +63,6 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul */ public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null) { - // Backwards compatibility - if ($list instanceof LegacyChoiceListAdapter && empty($preferredChoices) - && null === $label && null === $index && null === $groupBy && null === $attr) { - $mapToNonLegacyChoiceView = function (LegacyChoiceView &$choiceView) { - $choiceView = new ChoiceView($choiceView->data, $choiceView->value, $choiceView->label); - }; - - $adaptedList = $list->getAdaptedList(); - - $remainingViews = $adaptedList->getRemainingViews(); - $preferredViews = $adaptedList->getPreferredViews(); - array_walk_recursive($remainingViews, $mapToNonLegacyChoiceView); - array_walk_recursive($preferredViews, $mapToNonLegacyChoiceView); - - return new ChoiceListView($remainingViews, $preferredViews); - } - $preferredViews = array(); $otherViews = array(); $choices = $list->getChoices(); diff --git a/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php b/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php deleted file mode 100644 index 929ef8c290ded..0000000000000 --- a/src/Symfony/Component/Form/ChoiceList/LegacyChoiceListAdapter.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\ChoiceList; - -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface as LegacyChoiceListInterface; - -/** - * Adapts a legacy choice list implementation to {@link ChoiceListInterface}. - * - * @author Bernhard Schussek - * - * @deprecated Added for backwards compatibility in Symfony 2.7, to be - * removed in Symfony 3.0. - */ -class LegacyChoiceListAdapter implements ChoiceListInterface -{ - /** - * @var LegacyChoiceListInterface - */ - private $adaptedList; - - /** - * @var array|null - */ - private $choices; - - /** - * @var array|null - */ - private $values; - - /** - * @var array|null - */ - private $structuredValues; - - /** - * Adapts a legacy choice list to {@link ChoiceListInterface}. - * - * @param LegacyChoiceListInterface $adaptedList The adapted list - */ - public function __construct(LegacyChoiceListInterface $adaptedList) - { - $this->adaptedList = $adaptedList; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - if (!$this->choices) { - $this->initialize(); - } - - return $this->choices; - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - if (!$this->values) { - $this->initialize(); - } - - return $this->values; - } - - /** - * {@inheritdoc} - */ - public function getStructuredValues() - { - if (!$this->structuredValues) { - $this->initialize(); - } - - return $this->structuredValues; - } - - /** - * {@inheritdoc} - */ - public function getOriginalKeys() - { - if (!$this->structuredValues) { - $this->initialize(); - } - - return array_flip($this->structuredValues); - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - return $this->adaptedList->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - return $this->adaptedList->getValuesForChoices($choices); - } - - /** - * Returns the adapted choice list. - * - * @return LegacyChoiceListInterface The adapted list - */ - public function getAdaptedList() - { - return $this->adaptedList; - } - - private function initialize() - { - $this->choices = array(); - $this->values = array(); - $this->structuredValues = $this->adaptedList->getValues(); - - $innerChoices = $this->adaptedList->getChoices(); - - foreach ($innerChoices as $index => $choice) { - $value = $this->structuredValues[$index]; - $this->values[] = $value; - $this->choices[$value] = $choice; - } - } -} diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php index 6e79d413cc019..6009597c044d8 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceView.php @@ -9,15 +9,12 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Form\Extension\Core\View; +namespace Symfony\Component\Form\ChoiceList\View; /** * Represents a choice in templates. * * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead. */ class ChoiceView { @@ -42,32 +39,6 @@ class ChoiceView */ public $data; - /** - * Creates a new ChoiceView. - * - * @param mixed $data The original choice. - * @param string $value The view representation of the choice. - * @param string $label The label displayed to humans. - */ - public function __construct($data, $value, $label) - { - $this->data = $data; - $this->value = $value; - $this->label = $label; - } -} - -namespace Symfony\Component\Form\ChoiceList\View; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView as LegacyChoiceView; - -/** - * Represents a choice in templates. - * - * @author Bernhard Schussek - */ -class ChoiceView extends LegacyChoiceView -{ /** * Additional attributes for the HTML tag. * @@ -85,8 +56,9 @@ class ChoiceView extends LegacyChoiceView */ public function __construct($data, $value, $label, array $attr = array()) { - parent::__construct($data, $value, $label); - + $this->data = $data; + $this->value = $value; + $this->label = $label; $this->attr = $attr; } } diff --git a/src/Symfony/Component/Form/Exception/AlreadyBoundException.php b/src/Symfony/Component/Form/Exception/AlreadyBoundException.php deleted file mode 100644 index 854ea1b2a8493..0000000000000 --- a/src/Symfony/Component/Form/Exception/AlreadyBoundException.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Alias of {@link AlreadySubmittedException}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link AlreadySubmittedException} instead. - */ -class AlreadyBoundException extends LogicException -{ - public function __construct($message = '', $code = 0, \Exception $previous = null) - { - if (__CLASS__ === get_class($this)) { - @trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Exception\AlreadySubmittedException class instead.', E_USER_DEPRECATED); - } - - parent::__construct($message, $code, $previous); - } -} diff --git a/src/Symfony/Component/Form/Exception/AlreadySubmittedException.php b/src/Symfony/Component/Form/Exception/AlreadySubmittedException.php index 7be212494a380..5e8c3052626fd 100644 --- a/src/Symfony/Component/Form/Exception/AlreadySubmittedException.php +++ b/src/Symfony/Component/Form/Exception/AlreadySubmittedException.php @@ -17,6 +17,6 @@ * * @author Bernhard Schussek */ -class AlreadySubmittedException extends AlreadyBoundException +class AlreadySubmittedException extends LogicException { } diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php deleted file mode 100644 index b77f4d4e75495..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ /dev/null @@ -1,523 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -@trigger_error('The '.__NAMESPACE__.'\ChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Exception\InvalidConfigurationException; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -/** - * A choice list for choices of arbitrary data types. - * - * Choices and labels are passed in two arrays. The indices of the choices - * and the labels should match. Choices may also be given as hierarchy of - * unlimited depth by creating nested arrays. The title of the sub-hierarchy - * can be stored in the array key pointing to the nested array. The topmost - * level of the hierarchy may also be a \Traversable. - * - * - * $choices = array(true, false); - * $labels = array('Agree', 'Disagree'); - * $choiceList = new ArrayChoiceList($choices, $labels); - * - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead. - */ -class ChoiceList implements ChoiceListInterface -{ - /** - * The choices with their indices as keys. - * - * @var array - */ - protected $choices = array(); - - /** - * The choice values with the indices of the matching choices as keys. - * - * @var array - */ - protected $values = array(); - - /** - * The preferred view objects as hierarchy containing also the choice groups - * with the indices of the matching choices as bottom-level keys. - * - * @var array - */ - private $preferredViews = array(); - - /** - * The non-preferred view objects as hierarchy containing also the choice - * groups with the indices of the matching choices as bottom-level keys. - * - * @var array - */ - private $remainingViews = array(); - - /** - * Creates a new choice list. - * - * @param array|\Traversable $choices The array of choices. Choices may also be given - * as hierarchy of unlimited depth. Hierarchies are - * created by creating nested arrays. The title of - * the sub-hierarchy can be stored in the array - * key pointing to the nested array. The topmost - * level of the hierarchy may also be a \Traversable. - * @param array $labels The array of labels. The structure of this array - * should match the structure of $choices. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. - * - * @throws UnexpectedTypeException If the choices are not an array or \Traversable. - */ - public function __construct($choices, array $labels, array $preferredChoices = array()) - { - if (!is_array($choices) && !$choices instanceof \Traversable) { - throw new UnexpectedTypeException($choices, 'array or \Traversable'); - } - - $this->initialize($choices, $labels, $preferredChoices); - } - - /** - * Initializes the list with choices. - * - * Safe to be called multiple times. The list is cleared on every call. - * - * @param array|\Traversable $choices The choices to write into the list. - * @param array $labels The labels belonging to the choices. - * @param array $preferredChoices The choices to display with priority. - */ - protected function initialize($choices, array $labels, array $preferredChoices) - { - $this->choices = array(); - $this->values = array(); - $this->preferredViews = array(); - $this->remainingViews = array(); - - $this->addChoices( - $this->preferredViews, - $this->remainingViews, - $choices, - $labels, - $preferredChoices - ); - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return $this->choices; - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - return $this->values; - } - - /** - * {@inheritdoc} - */ - public function getPreferredViews() - { - return $this->preferredViews; - } - - /** - * {@inheritdoc} - */ - public function getRemainingViews() - { - return $this->remainingViews; - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - $values = $this->fixValues($values); - $choices = array(); - - foreach ($values as $i => $givenValue) { - foreach ($this->values as $j => $value) { - if ($value === $givenValue) { - $choices[$i] = $this->choices[$j]; - unset($values[$i]); - - if (0 === count($values)) { - break 2; - } - } - } - } - - return $choices; - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - $choices = $this->fixChoices($choices); - $values = array(); - - foreach ($choices as $i => $givenChoice) { - foreach ($this->choices as $j => $choice) { - if ($choice === $givenChoice) { - $values[$i] = $this->values[$j]; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $values; - } - - /** - * {@inheritdoc} - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); - - $choices = $this->fixChoices($choices); - $indices = array(); - - foreach ($choices as $i => $givenChoice) { - foreach ($this->choices as $j => $choice) { - if ($choice === $givenChoice) { - $indices[$i] = $j; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $indices; - } - - /** - * {@inheritdoc} - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForValues(array $values) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); - - $values = $this->fixValues($values); - $indices = array(); - - foreach ($values as $i => $givenValue) { - foreach ($this->values as $j => $value) { - if ($value === $givenValue) { - $indices[$i] = $j; - unset($values[$i]); - - if (0 === count($values)) { - break 2; - } - } - } - } - - return $indices; - } - - /** - * Recursively adds the given choices to the list. - * - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param array|\Traversable $choices The list of choices. - * @param array $labels The labels corresponding to the choices. - * @param array $preferredChoices The preferred choices. - * - * @throws InvalidArgumentException If the structures of the choices and labels array do not match. - * @throws InvalidConfigurationException If no valid value or index could be created for a choice. - */ - protected function addChoices(array &$bucketForPreferred, array &$bucketForRemaining, $choices, array $labels, array $preferredChoices) - { - // Add choices to the nested buckets - foreach ($choices as $group => $choice) { - if (!array_key_exists($group, $labels)) { - throw new InvalidArgumentException('The structures of the choices and labels array do not match.'); - } - - if (is_array($choice)) { - // Don't do the work if the array is empty - if (count($choice) > 0) { - $this->addChoiceGroup( - $group, - $bucketForPreferred, - $bucketForRemaining, - $choice, - $labels[$group], - $preferredChoices - ); - } - } else { - $this->addChoice( - $bucketForPreferred, - $bucketForRemaining, - $choice, - $labels[$group], - $preferredChoices - ); - } - } - } - - /** - * Recursively adds a choice group. - * - * @param string $group The name of the group. - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param array $choices The list of choices in the group. - * @param array $labels The labels corresponding to the choices in the group. - * @param array $preferredChoices The preferred choices. - * - * @throws InvalidConfigurationException If no valid value or index could be created for a choice. - */ - protected function addChoiceGroup($group, array &$bucketForPreferred, array &$bucketForRemaining, array $choices, array $labels, array $preferredChoices) - { - // If this is a choice group, create a new level in the choice - // key hierarchy - $bucketForPreferred[$group] = array(); - $bucketForRemaining[$group] = array(); - - $this->addChoices( - $bucketForPreferred[$group], - $bucketForRemaining[$group], - $choices, - $labels, - $preferredChoices - ); - - // Remove child levels if empty - if (empty($bucketForPreferred[$group])) { - unset($bucketForPreferred[$group]); - } - if (empty($bucketForRemaining[$group])) { - unset($bucketForRemaining[$group]); - } - } - - /** - * Adds a new choice. - * - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param mixed $choice The choice to add. - * @param string $label The label for the choice. - * @param array $preferredChoices The preferred choices. - * - * @throws InvalidConfigurationException If no valid value or index could be created. - */ - protected function addChoice(array &$bucketForPreferred, array &$bucketForRemaining, $choice, $label, array $preferredChoices) - { - $index = $this->createIndex($choice); - - if ('' === $index || null === $index || !FormConfigBuilder::isValidName((string) $index)) { - throw new InvalidConfigurationException(sprintf('The index "%s" created by the choice list is invalid. It should be a valid, non-empty Form name.', $index)); - } - - $value = $this->createValue($choice); - - if (!is_string($value)) { - throw new InvalidConfigurationException(sprintf('The value created by the choice list is of type "%s", but should be a string.', gettype($value))); - } - - $view = new ChoiceView($choice, $value, $label); - - $this->choices[$index] = $this->fixChoice($choice); - $this->values[$index] = $value; - - if ($this->isPreferred($choice, $preferredChoices)) { - $bucketForPreferred[$index] = $view; - } else { - $bucketForRemaining[$index] = $view; - } - } - - /** - * Returns whether the given choice should be preferred judging by the - * given array of preferred choices. - * - * Extension point to optimize performance by changing the structure of the - * $preferredChoices array. - * - * @param mixed $choice The choice to test. - * @param array $preferredChoices An array of preferred choices. - * - * @return bool Whether the choice is preferred. - */ - protected function isPreferred($choice, array $preferredChoices) - { - return in_array($choice, $preferredChoices, true); - } - - /** - * Creates a new unique index for this choice. - * - * Extension point to change the indexing strategy. - * - * @param mixed $choice The choice to create an index for - * - * @return int|string A unique index containing only ASCII letters, - * digits and underscores. - */ - protected function createIndex($choice) - { - return count($this->choices); - } - - /** - * Creates a new unique value for this choice. - * - * By default, an integer is generated since it cannot be guaranteed that - * all values in the list are convertible to (unique) strings. Subclasses - * can override this behaviour if they can guarantee this property. - * - * @param mixed $choice The choice to create a value for - * - * @return string A unique string. - */ - protected function createValue($choice) - { - return (string) count($this->values); - } - - /** - * Fixes the data type of the given choice value to avoid comparison - * problems. - * - * @param mixed $value The choice value. - * - * @return string The value as string. - */ - protected function fixValue($value) - { - return (string) $value; - } - - /** - * Fixes the data types of the given choice values to avoid comparison - * problems. - * - * @param array $values The choice values. - * - * @return array The values as strings. - */ - protected function fixValues(array $values) - { - foreach ($values as $i => $value) { - $values[$i] = $this->fixValue($value); - } - - return $values; - } - - /** - * Fixes the data type of the given choice index to avoid comparison - * problems. - * - * @param mixed $index The choice index. - * - * @return int|string The index as PHP array key. - */ - protected function fixIndex($index) - { - if (is_bool($index) || (string) (int) $index === (string) $index) { - return (int) $index; - } - - return (string) $index; - } - - /** - * Fixes the data types of the given choice indices to avoid comparison - * problems. - * - * @param array $indices The choice indices. - * - * @return array The indices as strings. - */ - protected function fixIndices(array $indices) - { - foreach ($indices as $i => $index) { - $indices[$i] = $this->fixIndex($index); - } - - return $indices; - } - - /** - * Fixes the data type of the given choice to avoid comparison problems. - * - * Extension point. In this implementation, choices are guaranteed to - * always maintain their type and thus can be typesafely compared. - * - * @param mixed $choice The choice - * - * @return mixed The fixed choice - */ - protected function fixChoice($choice) - { - return $choice; - } - - /** - * Fixes the data type of the given choices to avoid comparison problems. - * - * @param array $choices The choices. - * - * @return array The fixed choices. - * - * @see fixChoice() - */ - protected function fixChoices(array $choices) - { - return $choices; - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php deleted file mode 100644 index f7f8acdfead14..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php +++ /dev/null @@ -1,168 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -/** - * Contains choices that can be selected in a form field. - * - * Each choice has three different properties: - * - * - Choice: The choice that should be returned to the application by the - * choice field. Can be any scalar value or an object, but no - * array. - * - Label: A text representing the choice that is displayed to the user. - * - Value: A uniquely identifying value that can contain arbitrary - * characters, but no arrays or objects. This value is displayed - * in the HTML "value" attribute. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\ChoiceListInterface} instead. - */ -interface ChoiceListInterface -{ - /** - * Returns the list of choices. - * - * @return array The choices with their indices as keys - */ - public function getChoices(); - - /** - * Returns the values for the choices. - * - * @return array The values with the corresponding choice indices as keys - */ - public function getValues(); - - /** - * Returns the choice views of the preferred choices as nested array with - * the choice groups as top-level keys. - * - * Example: - * - * - * array( - * 'Group 1' => array( - * 10 => ChoiceView object, - * 20 => ChoiceView object, - * ), - * 'Group 2' => array( - * 30 => ChoiceView object, - * ), - * ) - * - * - * @return array A nested array containing the views with the corresponding - * choice indices as keys on the lowest levels and the choice - * group names in the keys of the higher levels - */ - public function getPreferredViews(); - - /** - * Returns the choice views of the choices that are not preferred as nested - * array with the choice groups as top-level keys. - * - * Example: - * - * - * array( - * 'Group 1' => array( - * 10 => ChoiceView object, - * 20 => ChoiceView object, - * ), - * 'Group 2' => array( - * 30 => ChoiceView object, - * ), - * ) - * - * - * @return array A nested array containing the views with the corresponding - * choice indices as keys on the lowest levels and the choice - * group names in the keys of the higher levels - * - * @see getPreferredValues() - */ - public function getRemainingViews(); - - /** - * Returns the choices corresponding to the given values. - * - * The choices can have any data type. - * - * The choices must be returned with the same keys and in the same order - * as the corresponding values in the given array. - * - * @param array $values An array of choice values. Not existing values in - * this array are ignored - * - * @return array An array of choices with ascending, 0-based numeric keys - */ - public function getChoicesForValues(array $values); - - /** - * Returns the values corresponding to the given choices. - * - * The values must be strings. - * - * The values must be returned with the same keys and in the same order - * as the corresponding choices in the given array. - * - * @param array $choices An array of choices. Not existing choices in this - * array are ignored - * - * @return array An array of choice values with ascending, 0-based numeric - * keys - */ - public function getValuesForChoices(array $choices); - - /** - * Returns the indices corresponding to the given choices. - * - * The indices must be positive integers or strings accepted by - * {@link \Symfony\Component\Form\FormConfigBuilder::validateName()}. - * - * The index "placeholder" is internally reserved. - * - * The indices must be returned with the same keys and in the same order - * as the corresponding choices in the given array. - * - * @param array $choices An array of choices. Not existing choices in this - * array are ignored - * - * @return array An array of indices with ascending, 0-based numeric keys - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices); - - /** - * Returns the indices corresponding to the given values. - * - * The indices must be positive integers or strings accepted by - * {@link \Symfony\Component\Form\FormConfigBuilder::validateName()}. - * - * The index "placeholder" is internally reserved. - * - * The indices must be returned with the same keys and in the same order - * as the corresponding values in the given array. - * - * @param array $values An array of choice values. Not existing values in - * this array are ignored - * - * @return array An array of indices with ascending, 0-based numeric keys - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForValues(array $values); -} diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php deleted file mode 100644 index 7a313cbfbdcd6..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php +++ /dev/null @@ -1,162 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -@trigger_error('The '.__NAMESPACE__.'\LazyChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * A choice list that is loaded lazily. - * - * This list loads itself as soon as any of the getters is accessed for the - * first time. You should implement loadChoiceList() in your child classes, - * which should return a ChoiceListInterface instance. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead. - */ -abstract class LazyChoiceList implements ChoiceListInterface -{ - /** - * The loaded choice list. - * - * @var ChoiceListInterface - */ - private $choiceList; - - /** - * {@inheritdoc} - */ - public function getChoices() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getChoices(); - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getValues(); - } - - /** - * {@inheritdoc} - */ - public function getPreferredViews() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getPreferredViews(); - } - - /** - * {@inheritdoc} - */ - public function getRemainingViews() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getRemainingViews(); - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getValuesForChoices($choices); - } - - /** - * {@inheritdoc} - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getIndicesForChoices($choices); - } - - /** - * {@inheritdoc} - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForValues(array $values) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getIndicesForValues($values); - } - - /** - * Loads the choice list. - * - * Should be implemented by child classes. - * - * @return ChoiceListInterface The loaded choice list - */ - abstract protected function loadChoiceList(); - - private function load() - { - $choiceList = $this->loadChoiceList(); - - if (!$choiceList instanceof ChoiceListInterface) { - throw new InvalidArgumentException(sprintf('loadChoiceList() should return a ChoiceListInterface instance. Got %s', gettype($choiceList))); - } - - $this->choiceList = $choiceList; - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php deleted file mode 100644 index 65742c45bce50..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php +++ /dev/null @@ -1,267 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -@trigger_error('The '.__NAMESPACE__.'\ObjectChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\Exception\StringCastException; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; - -/** - * A choice list for object choices. - * - * Supports generation of choice labels, choice groups and choice values - * by calling getters of the object (or associated objects). - * - * - * $choices = array($user1, $user2); - * - * // call getName() to determine the choice labels - * $choiceList = new ObjectChoiceList($choices, 'name'); - * - * - * @author Bernhard Schussek - * - * @deprecated since Symfony 2.7, to be removed in version 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead. - */ -class ObjectChoiceList extends ChoiceList -{ - /** - * @var PropertyAccessorInterface - */ - private $propertyAccessor; - - /** - * The property path used to obtain the choice label. - * - * @var PropertyPath - */ - private $labelPath; - - /** - * The property path used for object grouping. - * - * @var PropertyPath - */ - private $groupPath; - - /** - * The property path used to obtain the choice value. - * - * @var PropertyPath - */ - private $valuePath; - - /** - * Creates a new object choice list. - * - * @param array|\Traversable $choices The array of choices. Choices may also be given - * as hierarchy of unlimited depth by creating nested - * arrays. The title of the sub-hierarchy can be - * stored in the array key pointing to the nested - * array. The topmost level of the hierarchy may also - * be a \Traversable. - * @param string $labelPath A property path pointing to the property used - * for the choice labels. The value is obtained - * by calling the getter on the object. If the - * path is NULL, the object's __toString() method - * is used instead. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. - * @param string $groupPath A property path pointing to the property used - * to group the choices. Only allowed if - * the choices are given as flat array. - * @param string $valuePath A property path pointing to the property used - * for the choice values. If not given, integers - * are generated instead. - * @param PropertyAccessorInterface $propertyAccessor The reflection graph for reading property paths. - */ - public function __construct($choices, $labelPath = null, array $preferredChoices = array(), $groupPath = null, $valuePath = null, PropertyAccessorInterface $propertyAccessor = null) - { - $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); - $this->labelPath = null !== $labelPath ? new PropertyPath($labelPath) : null; - $this->groupPath = null !== $groupPath ? new PropertyPath($groupPath) : null; - $this->valuePath = null !== $valuePath ? new PropertyPath($valuePath) : null; - - parent::__construct($choices, array(), $preferredChoices); - } - - /** - * Initializes the list with choices. - * - * Safe to be called multiple times. The list is cleared on every call. - * - * @param array|\Traversable $choices The choices to write into the list. - * @param array $labels Ignored. - * @param array $preferredChoices The choices to display with priority. - * - * @throws InvalidArgumentException When passing a hierarchy of choices and using - * the "groupPath" option at the same time. - */ - protected function initialize($choices, array $labels, array $preferredChoices) - { - if (null !== $this->groupPath) { - $groupedChoices = array(); - - foreach ($choices as $i => $choice) { - if (is_array($choice)) { - throw new InvalidArgumentException('You should pass a plain object array (without groups) when using the "groupPath" option.'); - } - - try { - $group = $this->propertyAccessor->getValue($choice, $this->groupPath); - } catch (NoSuchPropertyException $e) { - // Don't group items whose group property does not exist - // see https://github.com/symfony/symfony/commit/d9b7abb7c7a0f28e0ce970afc5e305dce5dccddf - $group = null; - } - - if (null === $group) { - $groupedChoices[$i] = $choice; - } else { - $groupName = (string) $group; - - if (!isset($groupedChoices[$groupName])) { - $groupedChoices[$groupName] = array(); - } - - $groupedChoices[$groupName][$i] = $choice; - } - } - - $choices = $groupedChoices; - } - - $labels = array(); - - $this->extractLabels($choices, $labels); - - parent::initialize($choices, $labels, $preferredChoices); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - if (!$this->valuePath) { - return parent::getValuesForChoices($choices); - } - - // Use the value path to compare the choices - $choices = $this->fixChoices($choices); - $values = array(); - - foreach ($choices as $i => $givenChoice) { - // Ignore non-readable choices - if (!is_object($givenChoice) && !is_array($givenChoice)) { - continue; - } - - $givenValue = (string) $this->propertyAccessor->getValue($givenChoice, $this->valuePath); - - foreach ($this->values as $value) { - if ($value === $givenValue) { - $values[$i] = $value; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $values; - } - - /** - * {@inheritdoc} - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (!$this->valuePath) { - return parent::getIndicesForChoices($choices); - } - - // Use the value path to compare the choices - $choices = $this->fixChoices($choices); - $indices = array(); - - foreach ($choices as $i => $givenChoice) { - // Ignore non-readable choices - if (!is_object($givenChoice) && !is_array($givenChoice)) { - continue; - } - - $givenValue = (string) $this->propertyAccessor->getValue($givenChoice, $this->valuePath); - - foreach ($this->values as $j => $value) { - if ($value === $givenValue) { - $indices[$i] = $j; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $indices; - } - - /** - * Creates a new unique value for this choice. - * - * If a property path for the value was given at object creation, - * the getter behind that path is now called to obtain a new value. - * Otherwise a new integer is generated. - * - * @param mixed $choice The choice to create a value for - * - * @return int|string A unique value without character limitations. - */ - protected function createValue($choice) - { - if ($this->valuePath) { - return (string) $this->propertyAccessor->getValue($choice, $this->valuePath); - } - - return parent::createValue($choice); - } - - private function extractLabels($choices, array &$labels) - { - foreach ($choices as $i => $choice) { - if (is_array($choice)) { - $labels[$i] = array(); - $this->extractLabels($choice, $labels[$i]); - } elseif ($this->labelPath) { - $labels[$i] = $this->propertyAccessor->getValue($choice, $this->labelPath); - } elseif (method_exists($choice, '__toString')) { - $labels[$i] = (string) $choice; - } else { - throw new StringCastException(sprintf('A "__toString()" method was not found on the objects of type "%s" passed to the choice field. To read a custom getter instead, set the argument $labelPath to the desired property path.', get_class($choice))); - } - } - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php deleted file mode 100644 index 90cc4ac0236e1..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -@trigger_error('The '.__NAMESPACE__.'\SimpleChoiceList class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\ArrayChoiceList instead.', E_USER_DEPRECATED); - -/** - * A choice list for choices of type string or integer. - * - * Choices and their associated labels can be passed in a single array. Since - * choices are passed as array keys, only strings or integer choices are - * allowed. Choices may also be given as hierarchy of unlimited depth by - * creating nested arrays. The title of the sub-hierarchy can be stored in the - * array key pointing to the nested array. - * - * - * $choiceList = new SimpleChoiceList(array( - * 'creditcard' => 'Credit card payment', - * 'cash' => 'Cash payment', - * )); - * - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\ArrayChoiceList} instead. - */ -class SimpleChoiceList extends ChoiceList -{ - /** - * Creates a new simple choice list. - * - * @param array $choices The array of choices with the choices as keys and - * the labels as values. Choices may also be given - * as hierarchy of unlimited depth by creating nested - * arrays. The title of the sub-hierarchy is stored - * in the array key pointing to the nested array. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. - */ - public function __construct(array $choices, array $preferredChoices = array()) - { - // Flip preferred choices to speed up lookup - parent::__construct($choices, $choices, array_flip($preferredChoices)); - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - $values = $this->fixValues($values); - - // The values are identical to the choices, so we can just return them - // to improve performance a little bit - return $this->fixChoices(array_intersect($values, $this->getValues())); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - $choices = $this->fixChoices($choices); - - // The choices are identical to the values, so we can just return them - // to improve performance a little bit - return $this->fixValues(array_intersect($choices, $this->getValues())); - } - - /** - * Recursively adds the given choices to the list. - * - * Takes care of splitting the single $choices array passed in the - * constructor into choices and labels. - * - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param array|\Traversable $choices The list of choices. - * @param array $labels Ignored. - * @param array $preferredChoices The preferred choices. - */ - protected function addChoices(array &$bucketForPreferred, array &$bucketForRemaining, $choices, array $labels, array $preferredChoices) - { - // Add choices to the nested buckets - foreach ($choices as $choice => $label) { - if (is_array($label)) { - // Don't do the work if the array is empty - if (count($label) > 0) { - $this->addChoiceGroup( - $choice, - $bucketForPreferred, - $bucketForRemaining, - $label, - $label, - $preferredChoices - ); - } - } else { - $this->addChoice( - $bucketForPreferred, - $bucketForRemaining, - $choice, - $label, - $preferredChoices - ); - } - } - } - - /** - * Returns whether the given choice should be preferred judging by the - * given array of preferred choices. - * - * Optimized for performance by treating the preferred choices as array - * where choices are stored in the keys. - * - * @param mixed $choice The choice to test. - * @param array $preferredChoices An array of preferred choices. - * - * @return bool Whether the choice is preferred. - */ - protected function isPreferred($choice, array $preferredChoices) - { - // Optimize performance over the default implementation - return isset($preferredChoices[$choice]); - } - - /** - * Converts the choice to a valid PHP array key. - * - * @param mixed $choice The choice - * - * @return string|int A valid PHP array key - */ - protected function fixChoice($choice) - { - return $this->fixIndex($choice); - } - - /** - * {@inheritdoc} - */ - protected function fixChoices(array $choices) - { - return $this->fixIndices($choices); - } - - /** - * {@inheritdoc} - */ - protected function createValue($choice) - { - // Choices are guaranteed to be unique and scalar, so we can simply - // convert them to strings - return (string) $choice; - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php deleted file mode 100644 index 50ee4b693e485..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -@trigger_error('The class '.__NAMESPACE__.'\ChoiceToBooleanArrayTransformer is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead. - */ -class ChoiceToBooleanArrayTransformer implements DataTransformerInterface -{ - private $choiceList; - - private $placeholderPresent; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - * @param bool $placeholderPresent - */ - public function __construct(ChoiceListInterface $choiceList, $placeholderPresent) - { - $this->choiceList = $choiceList; - $this->placeholderPresent = $placeholderPresent; - } - - /** - * Transforms a single choice to a format appropriate for the nested - * checkboxes/radio buttons. - * - * The result is an array with the options as keys and true/false as values, - * depending on whether a given option is selected. If this field is rendered - * as select tag, the value is not modified. - * - * @param mixed $choice An array if "multiple" is set to true, a scalar - * value otherwise. - * - * @return mixed An array - * - * @throws TransformationFailedException If the given value is not scalar or - * if the choices can not be retrieved. - */ - public function transform($choice) - { - try { - $values = $this->choiceList->getValues(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - $valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice))); - - foreach ($values as $i => $value) { - $values[$i] = isset($valueMap[$value]); - } - - if ($this->placeholderPresent) { - $values['placeholder'] = 0 === count($valueMap); - } - - return $values; - } - - /** - * Transforms a checkbox/radio button array to a single choice. - * - * The input value is an array with the choices as keys and true/false as - * values, depending on whether a given choice is selected. The output - * is the selected choice. - * - * @param array $values An array of values - * - * @return mixed A scalar value - * - * @throws TransformationFailedException If the given value is not an array, - * if the recuperation of the choices - * fails or if some choice can't be - * found. - */ - public function reverseTransform($values) - { - if (!is_array($values)) { - throw new TransformationFailedException('Expected an array.'); - } - - try { - $choices = $this->choiceList->getChoices(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - foreach ($values as $i => $selected) { - if ($selected) { - if (isset($choices[$i])) { - return $choices[$i] === '' ? null : $choices[$i]; - } elseif ($this->placeholderPresent && 'placeholder' === $i) { - return; - } else { - throw new TransformationFailedException(sprintf('The choice "%s" does not exist', $i)); - } - } - } - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php deleted file mode 100644 index 26c6781403227..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -@trigger_error('The class '.__NAMESPACE__.'\ChoicesToBooleanArrayTransformer is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead. - */ -class ChoicesToBooleanArrayTransformer implements DataTransformerInterface -{ - private $choiceList; - - public function __construct(ChoiceListInterface $choiceList) - { - $this->choiceList = $choiceList; - } - - /** - * Transforms an array of choices to a format appropriate for the nested - * checkboxes/radio buttons. - * - * The result is an array with the options as keys and true/false as values, - * depending on whether a given option is selected. If this field is rendered - * as select tag, the value is not modified. - * - * @param mixed $array An array - * - * @return mixed An array - * - * @throws TransformationFailedException If the given value is not an array - * or if the choices can not be retrieved. - */ - public function transform($array) - { - if (null === $array) { - return array(); - } - - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - try { - $values = $this->choiceList->getValues(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - $valueMap = array_flip($this->choiceList->getValuesForChoices($array)); - - foreach ($values as $i => $value) { - $values[$i] = isset($valueMap[$value]); - } - - return $values; - } - - /** - * Transforms a checkbox/radio button array to an array of choices. - * - * The input value is an array with the choices as keys and true/false as - * values, depending on whether a given choice is selected. The output - * is an array with the selected choices. - * - * @param mixed $values An array - * - * @return mixed An array - * - * @throws TransformationFailedException If the given value is not an array, - * if the recuperation of the choices - * fails or if some choice can't be - * found. - */ - public function reverseTransform($values) - { - if (!is_array($values)) { - throw new TransformationFailedException('Expected an array.'); - } - - try { - $choices = $this->choiceList->getChoices(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - $result = array(); - $unknown = array(); - - foreach ($values as $i => $selected) { - if ($selected) { - if (isset($choices[$i])) { - $result[] = $choices[$i]; - } else { - $unknown[] = $i; - } - } - } - - if (count($unknown) > 0) { - throw new TransformationFailedException(sprintf('The choices "%s" were not found', implode('", "', $unknown))); - } - - return $result; - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 8aef383fe4705..9c5f9c1fec2cf 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -72,27 +72,6 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface */ const ROUND_HALF_DOWN = \NumberFormatter::ROUND_HALFDOWN; - /** - * Alias for {@link self::ROUND_HALF_EVEN}. - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - const ROUND_HALFEVEN = \NumberFormatter::ROUND_HALFEVEN; - - /** - * Alias for {@link self::ROUND_HALF_UP}. - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - const ROUND_HALFUP = \NumberFormatter::ROUND_HALFUP; - - /** - * Alias for {@link self::ROUND_HALF_DOWN}. - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - const ROUND_HALFDOWN = \NumberFormatter::ROUND_HALFDOWN; - /** * @deprecated since version 2.7, will be replaced by a $scale private property in 3.0. */ diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php deleted file mode 100644 index 68aacd4c56b9e..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -@trigger_error('The class '.__NAMESPACE__.'\FixCheckboxInputListener is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper instead.', E_USER_DEPRECATED); - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; - -/** - * Takes care of converting the input from a list of checkboxes to a correctly - * indexed array. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\CheckboxListMapper} instead. - */ -class FixCheckboxInputListener implements EventSubscriberInterface -{ - private $choiceList; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - */ - public function __construct(ChoiceListInterface $choiceList) - { - $this->choiceList = $choiceList; - } - - public function preSubmit(FormEvent $event) - { - $data = $event->getData(); - - if (is_array($data)) { - // Flip the submitted values for faster lookup - // It's better to flip this array than $existingValues because - // $submittedValues is generally smaller. - $submittedValues = array_flip($data); - - // Since expanded choice fields are completely loaded anyway, we - // can just as well get the values again without losing performance. - $existingValues = $this->choiceList->getValues(); - - // Clear the data array and fill it with correct indices - $data = array(); - - foreach ($existingValues as $index => $value) { - if (isset($submittedValues[$value])) { - // Value was submitted - $data[$index] = $value; - unset($submittedValues[$value]); - } - } - - if (count($submittedValues) > 0) { - throw new TransformationFailedException(sprintf( - 'The following choices were not found: "%s"', - implode('", "', array_keys($submittedValues)) - )); - } - } elseif ('' === $data || null === $data) { - // Empty values are always accepted. - $data = array(); - } - - // Else leave the data unchanged to provoke an error during submission - - $event->setData($data); - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the preSubmit() method instead.', E_USER_DEPRECATED); - - $this->preSubmit($event); - } - - public static function getSubscribedEvents() - { - return array(FormEvents::PRE_SUBMIT => 'preSubmit'); - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php deleted file mode 100644 index 9855b374df643..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -@trigger_error('The class '.__NAMESPACE__.'\FixRadioInputListener is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper instead.', E_USER_DEPRECATED); - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; - -/** - * Takes care of converting the input from a single radio button - * to an array. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper} instead. - */ -class FixRadioInputListener implements EventSubscriberInterface -{ - private $choiceList; - - private $placeholderPresent; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - * @param bool $placeholderPresent - */ - public function __construct(ChoiceListInterface $choiceList, $placeholderPresent) - { - $this->choiceList = $choiceList; - $this->placeholderPresent = $placeholderPresent; - } - - public function preSubmit(FormEvent $event) - { - $data = $event->getData(); - - // Since expanded choice fields are completely loaded anyway, we - // can just as well get the values again without losing performance. - $existingValues = $this->choiceList->getValues(); - - if (false !== ($index = array_search($data, $existingValues, true))) { - $data = array($index => $data); - } elseif ('' === $data || null === $data) { - // Empty values are always accepted. - $data = $this->placeholderPresent ? array('placeholder' => '') : array(); - } - - // Else leave the data unchanged to provoke an error during submission - - $event->setData($data); - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the preSubmit() method instead.', E_USER_DEPRECATED); - - $this->preSubmit($event); - } - - public static function getSubscribedEvents() - { - return array(FormEvents::PRE_SUBMIT => 'preSubmit'); - } -} diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php index a08337ec51908..b3ab37f3985cb 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php @@ -43,19 +43,6 @@ public function onSubmit(FormEvent $event) } } - /** - * Alias of {@link onSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link onSubmit()} instead. - */ - public function onBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the onSubmit() method instead.', E_USER_DEPRECATED); - - $this->onSubmit($event); - } - public static function getSubscribedEvents() { return array(FormEvents::SUBMIT => 'onSubmit'); diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php index a65116fd5c8ce..40dcb539fdfff 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php @@ -125,17 +125,4 @@ public function onSubmit(FormEvent $event) $event->setData($dataToMergeInto); } - - /** - * Alias of {@link onSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link onSubmit()} instead. - */ - public function onBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the onSubmit() method instead.', E_USER_DEPRECATED); - - $this->onSubmit($event); - } } diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php index f18370fde6f8d..197f556308f25 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php @@ -180,30 +180,4 @@ public function onSubmit(FormEvent $event) $event->setData($data); } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the preSubmit() method instead.', E_USER_DEPRECATED); - - $this->preSubmit($event); - } - - /** - * Alias of {@link onSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link onSubmit()} instead. - */ - public function onBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the onSubmit() method instead.', E_USER_DEPRECATED); - - $this->onSubmit($event); - } } diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php index 260e2699f56f8..96a1b2dcd6d2f 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php @@ -34,19 +34,6 @@ public function preSubmit(FormEvent $event) $event->setData(StringUtil::trim($data)); } - /** - * Alias of {@link preSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the preSubmit() method instead.', E_USER_DEPRECATED); - - $this->preSubmit($event); - } - public static function getSubscribedEvents() { return array(FormEvents::PRE_SUBMIT => 'preSubmit'); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php b/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php index b36a67f36b0f7..d68337e3bc8c1 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/BaseType.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Util\StringUtil; use Symfony\Component\OptionsResolver\OptionsResolver; /** @@ -78,17 +77,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) $blockPrefixes = array(); for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) { - if (method_exists($type, 'getBlockPrefix')) { - array_unshift($blockPrefixes, $type->getBlockPrefix()); - } else { - @trigger_error(get_class($type).': The ResolvedFormTypeInterface::getBlockPrefix() method will be added in version 3.0. You should add it to your implementation.', E_USER_DEPRECATED); - - $fqcn = get_class($type->getInnerType()); - $name = $type->getName(); - $hasCustomName = $name !== $fqcn; - - array_unshift($blockPrefixes, $hasCustomName ? $name : StringUtil::fqcnToBlockPrefix($fqcn)); - } + array_unshift($blockPrefixes, $type->getBlockPrefix()); } $blockPrefixes[] = $uniqueBlockPrefix; @@ -111,7 +100,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) // collection form have different types (dynamically), they should // be rendered differently. // https://github.com/symfony/symfony/issues/5038 - 'cache_key' => $uniqueBlockPrefix.'_'.$form->getConfig()->getType()->getName(), + 'cache_key' => $uniqueBlockPrefix.'_'.$form->getConfig()->getType()->getBlockPrefix(), )); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php index 3548a609fea46..841bd0d85f32f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php @@ -34,14 +34,6 @@ public function getParent() return __NAMESPACE__.'\DateType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php b/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php index 9e58b80245615..3a62eb8a471a2 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ButtonType.php @@ -28,14 +28,6 @@ public function getParent() { } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php b/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php index ddf7a5e5fcdbd..90646e8712a23 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php @@ -62,14 +62,6 @@ public function configureOptions(OptionsResolver $resolver) )); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 5a85a76c3bd0e..709fc037629c3 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -13,7 +13,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator; -use Symfony\Component\Form\ChoiceList\LegacyChoiceListAdapter; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory; @@ -28,7 +27,6 @@ use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface as LegacyChoiceListInterface; use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener; use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToValueTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer; @@ -202,7 +200,6 @@ public function buildView(FormView $view, FormInterface $form, array $options) } // BC - $view->vars['empty_value'] = $view->vars['placeholder']; $view->vars['empty_value_in_choices'] = $view->vars['placeholder_in_choices']; if ($options['multiple'] && !$options['expanded']) { @@ -248,23 +245,14 @@ public function configureOptions(OptionsResolver $resolver) return ''; }; - $emptyValue = function (Options $options) { - return $options['required'] ? null : ''; - }; - - // for BC with the "empty_value" option $placeholder = function (Options $options) { - return $options['empty_value']; + return $options['required'] ? null : ''; }; $choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory) { if ($choiceList) { @trigger_error('The "choice_list" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', E_USER_DEPRECATED); - if ($choiceList instanceof LegacyChoiceListInterface) { - return new LegacyChoiceListAdapter($choiceList); - } - return $choiceList; } @@ -328,7 +316,6 @@ public function configureOptions(OptionsResolver $resolver) 'preferred_choices' => array(), 'group_by' => null, 'empty_data' => $emptyData, - 'empty_value' => $emptyValue, // deprecated 'placeholder' => $placeholder, 'error_bubbling' => false, 'compound' => $compound, @@ -340,7 +327,6 @@ public function configureOptions(OptionsResolver $resolver) )); $resolver->setNormalizer('choice_list', $choiceListNormalizer); - $resolver->setNormalizer('empty_value', $placeholderNormalizer); $resolver->setNormalizer('placeholder', $placeholderNormalizer); $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); @@ -357,14 +343,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('group_by', array('null', 'array', '\Traversable', 'string', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php index 508013b312ed3..366bb895e9e09 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php @@ -96,14 +96,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setNormalizer('options', $optionsNormalizer); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php index 45da8d509a56a..aff38d9dae2a9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php @@ -36,14 +36,6 @@ public function getParent() return __NAMESPACE__.'\ChoiceType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php index 7a26316e01a47..8acf5994b7ff9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php @@ -36,14 +36,6 @@ public function getParent() return __NAMESPACE__.'\ChoiceType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index ef4d1ad2608cc..8eabc9b224f55 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -114,7 +114,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'years', 'months', 'days', - 'empty_value', 'placeholder', 'choice_translation_domain', 'required', @@ -130,7 +129,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'seconds', 'with_minutes', 'with_seconds', - 'empty_value', 'placeholder', 'choice_translation_domain', 'required', @@ -245,7 +243,6 @@ public function configureOptions(OptionsResolver $resolver) // Don't add some defaults in order to preserve the defaults // set in DateType and TimeType $resolver->setDefined(array( - 'empty_value', // deprecated 'placeholder', 'choice_translation_domain', 'years', @@ -283,14 +280,6 @@ public function configureOptions(OptionsResolver $resolver) )); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index f6d5a523469f6..6c22265d0a663 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -183,14 +183,10 @@ public function configureOptions(OptionsResolver $resolver) return $options['widget'] !== 'single_text'; }; - $emptyValue = $placeholderDefault = function (Options $options) { + $placeholderDefault = function (Options $options) { return $options['required'] ? null : ''; }; - $placeholder = function (Options $options) { - return $options['empty_value']; - }; - $placeholderNormalizer = function (Options $options, $placeholder) use ($placeholderDefault) { if (is_array($placeholder)) { $default = $placeholderDefault($options); @@ -238,8 +234,7 @@ public function configureOptions(OptionsResolver $resolver) 'format' => $format, 'model_timezone' => null, 'view_timezone' => null, - 'empty_value' => $emptyValue, // deprecated - 'placeholder' => $placeholder, + 'placeholder' => $placeholderDefault, 'html5' => true, // Don't modify \DateTime classes by reference, we treat // them like immutable value objects @@ -254,7 +249,6 @@ public function configureOptions(OptionsResolver $resolver) 'choice_translation_domain' => false, )); - $resolver->setNormalizer('empty_value', $placeholderNormalizer); $resolver->setNormalizer('placeholder', $placeholderNormalizer); $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); @@ -276,14 +270,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('days', 'array'); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php b/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php index 019a09e0e1c3e..2434778c760c4 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/EmailType.php @@ -23,14 +23,6 @@ public function getParent() return __NAMESPACE__.'\TextType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php index 6c67b8dc4b595..a89120a84f594 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php @@ -57,14 +57,6 @@ public function configureOptions(OptionsResolver $resolver) )); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php index 734c56b0eb1d8..a0f19616197d0 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/FormType.php @@ -84,14 +84,11 @@ public function buildView(FormView $view, FormInterface $form, array $options) } $view->vars = array_replace($view->vars, array( - 'read_only' => isset($view->vars['attr']['readonly']) && false !== $view->vars['attr']['readonly'], // deprecated 'errors' => $form->getErrors(), 'valid' => $form->isSubmitted() ? $form->isValid() : true, 'value' => $form->getViewData(), 'data' => $form->getNormData(), 'required' => $form->isRequired(), - 'max_length' => isset($options['attr']['maxlength']) ? $options['attr']['maxlength'] : null, // Deprecated - 'pattern' => isset($options['attr']['pattern']) ? $options['attr']['pattern'] : null, // Deprecated 'size' => null, 'label_attr' => $options['label_attr'], 'compound' => $form->getConfig()->getCompound(), @@ -151,64 +148,17 @@ public function configureOptions(OptionsResolver $resolver) return $options['compound']; }; - // BC with old "virtual" option - $inheritData = function (Options $options) { - if (null !== $options['virtual']) { - @trigger_error('The form option "virtual" is deprecated since version 2.3 and will be removed in 3.0. Use "inherit_data" instead.', E_USER_DEPRECATED); - - return $options['virtual']; - } - - return false; - }; - // If data is given, the form is locked to that data // (independent of its value) $resolver->setDefined(array( 'data', )); - // BC clause for the "max_length" and "pattern" option - // Add these values to the "attr" option instead - $defaultAttr = function (Options $options) { - $attributes = array(); - - if (null !== $options['max_length']) { - $attributes['maxlength'] = $options['max_length']; - } - - if (null !== $options['pattern']) { - $attributes['pattern'] = $options['pattern']; - } - - return $attributes; - }; - - // BC for "read_only" option - $attrNormalizer = function (Options $options, array $attr) { - if (!isset($attr['readonly']) && $options['read_only']) { - $attr['readonly'] = true; - } - - return $attr; - }; - - $readOnlyNormalizer = function (Options $options, $readOnly) { - if (null !== $readOnly) { - @trigger_error('The form option "read_only" is deprecated since version 2.8 and will be removed in 3.0. Use "attr[\'readonly\']" instead.', E_USER_DEPRECATED); - - return $readOnly; - } - - return false; - }; - $resolver->setDefaults(array( 'data_class' => $dataClass, 'empty_data' => $emptyData, 'trim' => true, 'required' => true, - 'read_only' => null, // deprecated 'max_length' => null, 'pattern' => null, 'property_path' => null, @@ -216,20 +166,16 @@ public function configureOptions(OptionsResolver $resolver) 'by_reference' => true, 'error_bubbling' => $errorBubbling, 'label_attr' => array(), - 'virtual' => null, - 'inherit_data' => $inheritData, + 'inherit_data' => false, 'compound' => true, 'method' => 'POST', // According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) // section 4.2., empty URIs are considered same-document references 'action' => '', - 'attr' => $defaultAttr, + 'attr' => array(), 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', )); - $resolver->setNormalizer('attr', $attrNormalizer); - $resolver->setNormalizer('read_only', $readOnlyNormalizer); - $resolver->setAllowedTypes('label_attr', 'array'); } @@ -240,14 +186,6 @@ public function getParent() { } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php b/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php index 5287bb7c1db0f..10377501fda83 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/HiddenType.php @@ -30,14 +30,6 @@ public function configureOptions(OptionsResolver $resolver) )); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php b/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php index 8e790793b96ed..b91df89370398 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php @@ -37,19 +37,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $scale = function (Options $options) { - if (null !== $options['precision']) { - @trigger_error('The form option "precision" is deprecated since version 2.7 and will be removed in 3.0. Use "scale" instead.', E_USER_DEPRECATED); - } - - return $options['precision']; - }; - $resolver->setDefaults(array( - // deprecated as of Symfony 2.7, to be removed in Symfony 3.0. - 'precision' => null, // default scale is locale specific (usually around 3) - 'scale' => $scale, + 'scale' => null, 'grouping' => false, // Integer cast rounds towards 0, so do the same when displaying fractions 'rounding_mode' => IntegerToLocalizedStringTransformer::ROUND_DOWN, @@ -69,14 +59,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('scale', array('null', 'int')); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php index 6fc6031af11c2..cd09542245f74 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php @@ -36,14 +36,6 @@ public function getParent() return __NAMESPACE__.'\ChoiceType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php index a6d42f8c917ee..27d698543ef86 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php @@ -36,14 +36,6 @@ public function getParent() return __NAMESPACE__.'\ChoiceType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php b/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php index 788f9460f5c36..ab8d00487e3d9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php @@ -51,20 +51,8 @@ public function buildView(FormView $view, FormInterface $form, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $scale = function (Options $options) { - if (null !== $options['precision']) { - @trigger_error('The form option "precision" is deprecated since version 2.7 and will be removed in 3.0. Use "scale" instead.', E_USER_DEPRECATED); - - return $options['precision']; - } - - return 2; - }; - $resolver->setDefaults(array( - // deprecated as of Symfony 2.7, to be removed in Symfony 3.0 - 'precision' => null, - 'scale' => $scale, + 'scale' => 2, 'grouping' => false, 'divisor' => 1, 'currency' => 'EUR', @@ -74,14 +62,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('scale', 'int'); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php b/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php index 7794349ae2adb..61ab9c1443672 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/NumberType.php @@ -36,19 +36,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $scale = function (Options $options) { - if (null !== $options['precision']) { - @trigger_error('The form option "precision" is deprecated since version 2.7 and will be removed in 3.0. Use "scale" instead.', E_USER_DEPRECATED); - } - - return $options['precision']; - }; - $resolver->setDefaults(array( - // deprecated as of Symfony 2.7, to be removed in Symfony 3.0 - 'precision' => null, // default scale is locale specific (usually around 3) - 'scale' => $scale, + 'scale' => null, 'grouping' => false, 'rounding_mode' => NumberToLocalizedStringTransformer::ROUND_HALF_UP, 'compound' => false, @@ -67,14 +57,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('scale', array('null', 'int')); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php b/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php index 2aa1808972b5a..e651ee8df5787 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/PasswordType.php @@ -47,14 +47,6 @@ public function getParent() return __NAMESPACE__.'\TextType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php b/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php index 1fbad1aaa0d35..b330e3283fc6e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/PercentType.php @@ -32,20 +32,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $scale = function (Options $options) { - if (null !== $options['precision']) { - @trigger_error('The form option "precision" is deprecated since version 2.7 and will be removed in 3.0. Use "scale" instead.', E_USER_DEPRECATED); - - return $options['precision']; - } - - return 0; - }; - $resolver->setDefaults(array( - // deprecated as of Symfony 2.7, to be removed in Symfony 3.0. - 'precision' => null, - 'scale' => $scale, + 'scale' => 0, 'type' => 'fractional', 'compound' => false, )); @@ -58,14 +46,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('scale', 'int'); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php b/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php index 43110d99697e0..7c0e8608478bc 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/RadioType.php @@ -23,14 +23,6 @@ public function getParent() return __NAMESPACE__.'\CheckboxType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php b/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php index b70926f354edc..a69633c540407 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php @@ -23,14 +23,6 @@ public function getParent() return __NAMESPACE__.'\TextType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php b/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php index f46dba7f7af32..941f61b3c825e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php @@ -61,14 +61,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('second_options', 'array'); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php b/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php index 6d8421355d52f..16978ec5f1433 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ResetType.php @@ -29,14 +29,6 @@ public function getParent() return __NAMESPACE__.'\ButtonType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php b/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php index a5148740ce84f..4766ad094cd8f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/SearchType.php @@ -23,14 +23,6 @@ public function getParent() return __NAMESPACE__.'\TextType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php b/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php index d102fc9579114..38666325f374a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/SubmitType.php @@ -36,14 +36,6 @@ public function getParent() return __NAMESPACE__.'\ButtonType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextType.php index 86df235385435..81504f9079378 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TextType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TextType.php @@ -26,14 +26,6 @@ public function configureOptions(OptionsResolver $resolver) )); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php index 9bbd9b5671c39..ddfe994d6e406 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php @@ -33,14 +33,6 @@ public function getParent() return __NAMESPACE__.'\TextType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index 516403f907eeb..760a772031315 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -171,15 +171,10 @@ public function configureOptions(OptionsResolver $resolver) return $options['widget'] !== 'single_text'; }; - $emptyValue = $placeholderDefault = function (Options $options) { + $placeholder = $placeholderDefault = function (Options $options) { return $options['required'] ? null : ''; }; - // for BC with the "empty_value" option - $placeholder = function (Options $options) { - return $options['empty_value']; - }; - $placeholderNormalizer = function (Options $options, $placeholder) use ($placeholderDefault) { if (is_array($placeholder)) { $default = $placeholderDefault($options); @@ -224,7 +219,6 @@ public function configureOptions(OptionsResolver $resolver) 'with_seconds' => false, 'model_timezone' => null, 'view_timezone' => null, - 'empty_value' => $emptyValue, // deprecated 'placeholder' => $placeholder, 'html5' => true, // Don't modify \DateTime classes by reference, we treat @@ -240,7 +234,6 @@ public function configureOptions(OptionsResolver $resolver) 'choice_translation_domain' => false, )); - $resolver->setNormalizer('empty_value', $placeholderNormalizer); $resolver->setNormalizer('placeholder', $placeholderNormalizer); $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); @@ -261,14 +254,6 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('seconds', 'array'); } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index 3277a1838636c..30c8784afe47a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -42,14 +42,6 @@ public function getParent() return __NAMESPACE__.'\ChoiceType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php b/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php index a723a90a27b67..4994835ccf802 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/UrlType.php @@ -46,14 +46,6 @@ public function getParent() return __NAMESPACE__.'\TextType'; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->getBlockPrefix(); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php b/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php deleted file mode 100644 index 576d9eba2cbce..0000000000000 --- a/src/Symfony/Component/Form/Extension/Core/View/ChoiceView.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\View; - -@trigger_error('The '.__NAMESPACE__.'\ChoiceView class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Form\ChoiceList\View\ChoiceView instead.', E_USER_DEPRECATED); - -/* - * Represents a choice in templates. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\ChoiceList\View\ChoiceView} instead. - */ -class_exists('Symfony\Component\Form\ChoiceList\View\ChoiceView'); diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php deleted file mode 100644 index 2a55069692f8a..0000000000000 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -@trigger_error('The '.__NAMESPACE__.'\CsrfProviderAdapter class is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\Exception\BadMethodCallException; -use Symfony\Component\Security\Csrf\CsrfToken; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; - -/** - * Adapter for using old CSRF providers where the new {@link CsrfTokenManagerInterface} - * is expected. - * - * @since 2.4 - * - * @author Bernhard Schussek - * - * @deprecated since version 2.4, to be removed in 3.0. - */ -class CsrfProviderAdapter implements CsrfTokenManagerInterface -{ - /** - * @var CsrfProviderInterface - */ - private $csrfProvider; - - public function __construct(CsrfProviderInterface $csrfProvider) - { - $this->csrfProvider = $csrfProvider; - } - - public function getCsrfProvider() - { - return $this->csrfProvider; - } - - /** - * {@inheritdoc} - */ - public function getToken($tokenId) - { - return new CsrfToken($tokenId, $this->csrfProvider->generateCsrfToken($tokenId)); - } - - /** - * {@inheritdoc} - */ - public function refreshToken($tokenId) - { - throw new BadMethodCallException('Not supported'); - } - - /** - * {@inheritdoc} - */ - public function removeToken($tokenId) - { - throw new BadMethodCallException('Not supported'); - } - - /** - * {@inheritdoc} - */ - public function isTokenValid(CsrfToken $token) - { - return $this->csrfProvider->isCsrfTokenValid($token->getId(), $token->getValue()); - } -} diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.php deleted file mode 100644 index dd5b1fce1f41b..0000000000000 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -/** - * Marks classes able to provide CSRF protection. - * - * You can generate a CSRF token by using the method generateCsrfToken(). To - * this method you should pass a value that is unique to the page that should - * be secured against CSRF attacks. This value doesn't necessarily have to be - * secret. Implementations of this interface are responsible for adding more - * secret information. - * - * If you want to secure a form submission against CSRF attacks, you could - * supply an "intention" string. This way you make sure that the form can only - * be submitted to pages that are designed to handle the form, that is, that use - * the same intention string to validate the CSRF token with isCsrfTokenValid(). - * - * @author Bernhard Schussek - * - * @deprecated since version 2.4, to be removed in 3.0. - * Use {@link \Symfony\Component\Security\Csrf\CsrfTokenManagerInterface} instead. - */ -interface CsrfProviderInterface -{ - /** - * Generates a CSRF token for a page of your application. - * - * @param string $intention Some value that identifies the action intention - * (i.e. "authenticate"). Doesn't have to be a secret value. - * - * @return string The generated token - */ - public function generateCsrfToken($intention); - - /** - * Validates a CSRF token. - * - * @param string $intention The intention used when generating the CSRF token - * @param string $token The token supplied by the browser - * - * @return bool Whether the token supplied by the browser is correct - */ - public function isCsrfTokenValid($intention, $token); -} diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php deleted file mode 100644 index b246a616b03ed..0000000000000 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -use Symfony\Component\Security\Csrf\CsrfToken; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; - -/** - * Adapter for using the new token generator with the old interface. - * - * @since 2.4 - * - * @author Bernhard Schussek - * - * @deprecated since version 2.4, to be removed in 3.0. - */ -class CsrfTokenManagerAdapter implements CsrfProviderInterface -{ - /** - * @var CsrfTokenManagerInterface - */ - private $tokenManager; - - public function __construct(CsrfTokenManagerInterface $tokenManager) - { - $this->tokenManager = $tokenManager; - } - - public function getTokenManager($triggerDeprecationError = true) - { - if ($triggerDeprecationError) { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED); - } - - return $this->tokenManager; - } - - /** - * {@inheritdoc} - */ - public function generateCsrfToken($intention) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED); - - return $this->tokenManager->getToken($intention)->getValue(); - } - - /** - * {@inheritdoc} - */ - public function isCsrfTokenValid($intention, $token) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED); - - return $this->tokenManager->isTokenValid(new CsrfToken($intention, $token)); - } -} diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php deleted file mode 100644 index 6ee9ae9f9d3d8..0000000000000 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -@trigger_error('The '.__NAMESPACE__.'\DefaultCsrfProvider is deprecated since version 2.4 and will be removed in version 3.0. Use the \Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage class instead.', E_USER_DEPRECATED); - -/** - * Default implementation of CsrfProviderInterface. - * - * This provider uses the session ID returned by session_id() as well as a - * user-defined secret value to secure the CSRF token. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.4, to be removed in 3.0. - * Use {@link \Symfony\Component\Security\Csrf\CsrfTokenManager} in - * combination with {@link \Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage} - * instead. - */ -class DefaultCsrfProvider implements CsrfProviderInterface -{ - /** - * A secret value used for generating the CSRF token. - * - * @var string - */ - protected $secret; - - /** - * Initializes the provider with a secret value. - * - * A recommended value for the secret is a generated value with at least - * 32 characters and mixed letters, digits and special characters. - * - * @param string $secret A secret value included in the CSRF token - */ - public function __construct($secret) - { - $this->secret = $secret; - } - - /** - * {@inheritdoc} - */ - public function generateCsrfToken($intention) - { - return sha1($this->secret.$intention.$this->getSessionId()); - } - - /** - * {@inheritdoc} - */ - public function isCsrfTokenValid($intention, $token) - { - return $token === $this->generateCsrfToken($intention); - } - - /** - * Returns the ID of the user session. - * - * Automatically starts the session if necessary. - * - * @return string The session ID - */ - protected function getSessionId() - { - if (PHP_SESSION_NONE === session_status()) { - session_start(); - } - - return session_id(); - } -} diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/SessionCsrfProvider.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/SessionCsrfProvider.php deleted file mode 100644 index 2bbbde4a302ff..0000000000000 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/SessionCsrfProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -@trigger_error('The '.__NAMESPACE__.'\SessionCsrfProvider is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage class instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpFoundation\Session\Session; - -/** - * This provider uses a Symfony Session object to retrieve the user's - * session ID. - * - * @see DefaultCsrfProvider - * - * @author Bernhard Schussek - * - * @deprecated since version 2.4, to be removed in 3.0. - * Use {@link \Symfony\Component\Security\Csrf\CsrfTokenManager} in - * combination with {@link \Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage} - * instead. - */ -class SessionCsrfProvider extends DefaultCsrfProvider -{ - /** - * The user session from which the session ID is returned. - * - * @var Session - */ - protected $session; - - /** - * Initializes the provider with a Session object and a secret value. - * - * A recommended value for the secret is a generated value with at least - * 32 characters and mixed letters, digits and special characters. - * - * @param Session $session The user session - * @param string $secret A secret value included in the CSRF token - */ - public function __construct(Session $session, $secret) - { - parent::__construct($secret); - - $this->session = $session; - } - - /** - * {@inheritdoc} - */ - protected function getSessionId() - { - $this->session->start(); - - return $this->session->getId(); - } -} diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index 3b5156118aa3f..e96c1c930d5c1 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -114,17 +114,4 @@ public function preSubmit(FormEvent $event) $event->setData($data); } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the preSubmit() method instead.', E_USER_DEPRECATED); - - $this->preSubmit($event); - } } diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php index 1c678ac665d09..9e88a3eb3b304 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php @@ -46,7 +46,6 @@ public function extractConfiguration(FormInterface $form) $data = array( 'id' => $this->buildId($form), 'name' => $form->getName(), - 'type' => $form->getConfig()->getType()->getName(), 'type_class' => get_class($form->getConfig()->getType()->getInnerType()), 'synchronized' => $this->valueExporter->exportValue($form->isSynchronized()), 'passed_options' => array(), diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index 3a8a6b254523e..bd84e672e7a33 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -41,20 +41,7 @@ public function getType($name) throw new InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name)); } - $type = $this->container->get($this->typeServiceIds[$name]); - - // BC: validate result of getName() for legacy names (non-FQCN) - if ($name !== get_class($type) && $type->getName() !== $name) { - throw new InvalidArgumentException( - sprintf('The type name specified for the service "%s" does not match the actual name. Expected "%s", given "%s"', - $this->typeServiceIds[$name], - $name, - $type->getName() - ) - ); - } - - return $type; + return $this->container->get($this->typeServiceIds[$name]); } public function hasType($name) diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php index e2751e5bc85f1..606c3fa5d4911 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/Form.php @@ -21,12 +21,6 @@ class Form extends Constraint const NOT_SYNCHRONIZED_ERROR = 1; const NO_SUCH_FIELD_ERROR = 2; - /** - * @deprecated since version 2.6, to be removed in 3.0. - * Use {@self NOT_SYNCHRONIZED_ERROR} instead. - */ - const ERR_INVALID = 1; - protected static $errorNames = array( self::NOT_SYNCHRONIZED_ERROR => 'NOT_SYNCHRONIZED_ERROR', self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR', diff --git a/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php b/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php index 4bebce09cd574..0aae4bb8536b7 100644 --- a/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php @@ -14,7 +14,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\Extension\Validator\Constraints\Form; @@ -37,15 +36,11 @@ public static function getSubscribedEvents() } /** - * @param ValidatorInterface|LegacyValidatorInterface $validator - * @param ViolationMapperInterface $violationMapper + * @param ValidatorInterface $validator + * @param ViolationMapperInterface $violationMapper */ - public function __construct($validator, ViolationMapperInterface $violationMapper) + public function __construct(ValidatorInterface $validator, ViolationMapperInterface $violationMapper) { - if (!$validator instanceof ValidatorInterface && !$validator instanceof LegacyValidatorInterface) { - throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); - } - $this->validator = $validator; $this->violationMapper = $violationMapper; } diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php index 066a3d9eec3f7..0cc3da7c6bb23 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php @@ -15,7 +15,6 @@ use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper; use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener; use Symfony\Component\Validator\Validator\ValidatorInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -35,14 +34,10 @@ class FormTypeValidatorExtension extends BaseValidatorExtension private $violationMapper; /** - * @param ValidatorInterface|LegacyValidatorInterface $validator + * @param ValidatorInterface $validator */ - public function __construct($validator) + public function __construct(ValidatorInterface $validator) { - if (!$validator instanceof ValidatorInterface && !$validator instanceof LegacyValidatorInterface) { - throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); - } - $this->validator = $validator; $this->violationMapper = new ViolationMapper(); } @@ -67,18 +62,9 @@ public function configureOptions(OptionsResolver $resolver) return is_object($constraints) ? array($constraints) : (array) $constraints; }; - $cascadeValidationNormalizer = function (Options $options, $cascadeValidation) { - if (null !== $cascadeValidation) { - @trigger_error('The "cascade_validation" option is deprecated since version 2.8 and will be removed in 3.0. Use "constraints" with a Valid constraint instead.', E_USER_DEPRECATED); - } - - return null === $cascadeValidation ? false : $cascadeValidation; - }; - $resolver->setDefaults(array( 'error_mapping' => array(), 'constraints' => array(), - 'cascade_validation' => null, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'allow_extra_fields' => false, @@ -86,7 +72,6 @@ public function configureOptions(OptionsResolver $resolver) )); $resolver->setNormalizer('constraints', $constraintsNormalizer); - $resolver->setNormalizer('cascade_validation', $cascadeValidationNormalizer); } /** diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php index e7ed95c459d03..60e43b3cdc376 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php @@ -11,13 +11,11 @@ namespace Symfony\Component\Form\Extension\Validator; -use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Extension\Validator\Constraints\Form; use Symfony\Component\Form\AbstractExtension; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Validator\ValidatorInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; /** * Extension supporting the Symfony Validator component in forms. @@ -28,22 +26,9 @@ class ValidatorExtension extends AbstractExtension { private $validator; - /** - * @param ValidatorInterface|LegacyValidatorInterface $validator - * - * @throws UnexpectedTypeException If $validator is invalid - */ - public function __construct($validator) + public function __construct(ValidatorInterface $validator) { - // 2.5 API - if ($validator instanceof ValidatorInterface) { - $metadata = $validator->getMetadataFor('Symfony\Component\Form\Form'); - // 2.4 API - } elseif ($validator instanceof LegacyValidatorInterface) { - $metadata = $validator->getMetadataFactory()->getMetadataFor('Symfony\Component\Form\Form'); - } else { - throw new UnexpectedTypeException($validator, 'Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); - } + $metadata = $validator->getMetadataFor('Symfony\Component\Form\Form'); // Register the form constraints in the validator programmatically. // This functionality is required when using the Form component without @@ -59,13 +44,7 @@ public function __construct($validator) public function loadTypeGuesser() { - // 2.5 API - if ($this->validator instanceof ValidatorInterface) { - return new ValidatorTypeGuesser($this->validator); - } - - // 2.4 API - return new ValidatorTypeGuesser($this->validator->getMetadataFactory()); + return new ValidatorTypeGuesser($this->validator); } protected function loadTypeExtensions() diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index a277b580c5f2a..f0e2704880e51 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -673,23 +673,6 @@ public function submit($submittedData, $clearMissing = true) return $this; } - /** - * Alias of {@link submit()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link submit()} instead. - */ - public function bind($submittedData) - { - // This method is deprecated for Request too, but the error is - // triggered in Form::submit() method. - if (!$submittedData instanceof Request) { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the '.__CLASS__.'::submit method instead.', E_USER_DEPRECATED); - } - - return $this->submit($submittedData); - } - /** * {@inheritdoc} */ @@ -716,19 +699,6 @@ public function isSubmitted() return $this->submitted; } - /** - * Alias of {@link isSubmitted()}. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link isSubmitted()} instead. - */ - public function isBound() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the '.__CLASS__.'::isSubmitted method instead.', E_USER_DEPRECATED); - - return $this->submitted; - } - /** * {@inheritdoc} */ @@ -834,25 +804,6 @@ public function getErrors($deep = false, $flatten = true) return new FormErrorIterator($this, $errors); } - /** - * Returns a string representation of all form errors (including children errors). - * - * This method should only be used to help debug a form. - * - * @param int $level The indentation level (used internally) - * - * @return string A string representation of all errors - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link getErrors()} instead and cast the result to a string. - */ - public function getErrorsAsString($level = 0) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use (string) Form::getErrors(true, false) instead.', E_USER_DEPRECATED); - - return self::indent((string) $this->getErrors(true, false), $level); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index d217cf019365d..56b38e25bac5d 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -346,21 +346,6 @@ public function getInheritData() return $this->inheritData; } - /** - * Alias of {@link getInheritData()}. - * - * @return FormConfigBuilder The configuration object. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link getInheritData()} instead. - */ - public function getVirtual() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the FormConfigBuilder::getInheritData() method instead.', E_USER_DEPRECATED); - - return $this->getInheritData(); - } - /** * {@inheritdoc} */ @@ -710,23 +695,6 @@ public function setInheritData($inheritData) return $this; } - /** - * Alias of {@link setInheritData()}. - * - * @param bool $inheritData Whether the form should inherit its parent's data. - * - * @return FormConfigBuilder The configuration object. - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link setInheritData()} instead. - */ - public function setVirtual($inheritData) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the FormConfigBuilder::setInheritData() method instead.', E_USER_DEPRECATED); - - $this->setInheritData($inheritData); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index e00d8ab4fad29..051d57993d6f8 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -105,17 +105,12 @@ public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extens $options['data'] = $data; } - if ($type instanceof FormTypeInterface) { - @trigger_error('Passing type instances to FormBuilder::add(), Form::add() or the FormFactory is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); - $type = $this->resolveType($type); - } elseif (is_string($type)) { - $type = $this->registry->getType($type); - } elseif ($type instanceof ResolvedFormTypeInterface) { - @trigger_error('Passing type instances to FormBuilder::add(), Form::add() or the FormFactory is deprecated since version 2.8 and will not be supported in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED); - } else { - throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface'); + if (!is_string($type)) { + throw new UnexpectedTypeException($type, 'string'); } + $type = $this->registry->getType($type); + $builder = $type->createBuilder($this, $name, $options); // Explicitly call buildForm() in order to be able to override either diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index e9809edcdc2ca..2c5c7ff55d1b2 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -34,11 +34,6 @@ class FormRegistry implements FormRegistryInterface */ private $types = array(); - /** - * @var string[] - */ - private $legacyNames = array(); - /** * @var FormTypeGuesserInterface|false|null */ @@ -100,10 +95,6 @@ public function getType($name) $this->resolveAndAddType($type); } - if (isset($this->legacyNames[$name])) { - @trigger_error(sprintf('Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "%s" instead.', $name, get_class($this->types[$name]->getInnerType())), E_USER_DEPRECATED); - } - return $this->types[$name]; } @@ -120,28 +111,6 @@ private function resolveAndAddType(FormTypeInterface $type) $typeExtensions = array(); $parentType = $type->getParent(); $fqcn = get_class($type); - $name = $type->getName(); - $hasCustomName = $name !== $fqcn; - - if ($parentType instanceof FormTypeInterface) { - @trigger_error('Returning a FormTypeInterface from FormTypeInterface::getParent() is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED); - - $this->resolveAndAddType($parentType); - $parentType = $parentType->getName(); - } - - if ($hasCustomName) { - foreach ($this->extensions as $extension) { - $typeExtensions = array_merge( - $typeExtensions, - $extension->getTypeExtensions($name) - ); - } - - if ($typeExtensions) { - @trigger_error('Returning a type name from FormTypeExtensionInterface::getExtendedType() is deprecated since version 2.8 and will be removed in 3.0. Return the fully-qualified type class name instead.', E_USER_DEPRECATED); - } - } foreach ($this->extensions as $extension) { $typeExtensions = array_merge( @@ -157,12 +126,6 @@ private function resolveAndAddType(FormTypeInterface $type) ); $this->types[$fqcn] = $resolvedType; - - if ($hasCustomName) { - // Enable access by the explicit type name until Symfony 3.0 - $this->types[$name] = $resolvedType; - $this->legacyNames[$name] = true; - } } /** @@ -170,10 +133,6 @@ private function resolveAndAddType(FormTypeInterface $type) */ public function hasType($name) { - if (isset($this->legacyNames[$name])) { - @trigger_error(sprintf('Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name "%s" instead.', $name, get_class($this->types[$name]->getInnerType())), E_USER_DEPRECATED); - } - if (isset($this->types[$name])) { return true; } diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php index cf3e5cc7bd904..584e650a1d8b2 100644 --- a/src/Symfony/Component/Form/FormTypeInterface.php +++ b/src/Symfony/Component/Form/FormTypeInterface.php @@ -78,26 +78,7 @@ public function configureOptions(OptionsResolver $resolver); /** * Returns the name of the parent type. * - * You can also return a type instance from this method, although doing so - * is discouraged because it leads to a performance penalty. The support - * for returning type instances may be dropped from future releases. - * - * Returning a {@link FormTypeInterface} instance is deprecated since - * Symfony 2.8 and will be unsupported as of Symfony 3.0. Return the - * fully-qualified class name of the parent type instead. - * - * @return string|null|FormTypeInterface The name of the parent type if any, - * null otherwise. + * @return string|null The name of the parent type if any, null otherwise */ public function getParent(); - - /** - * Returns the name of this type. - * - * @return string The name of this type - * - * @deprecated Deprecated since Symfony 2.8, to be removed in Symfony 3.0. - * Use the fully-qualified class name of the type instead. - */ - public function getName(); } diff --git a/src/Symfony/Component/Form/PreloadedExtension.php b/src/Symfony/Component/Form/PreloadedExtension.php index a8fd9d0097e35..5b49e353b7874 100644 --- a/src/Symfony/Component/Form/PreloadedExtension.php +++ b/src/Symfony/Component/Form/PreloadedExtension.php @@ -48,10 +48,6 @@ public function __construct(array $types, array $typeExtensions, FormTypeGuesser $this->typeGuesser = $typeGuesser; foreach ($types as $type) { - // Up to Symfony 2.8, types were identified by their names - $this->types[$type->getName()] = $type; - - // Since Symfony 2.8, types are identified by their FQCN $this->types[get_class($type)] = $type; } } diff --git a/src/Symfony/Component/Form/ResolvedFormType.php b/src/Symfony/Component/Form/ResolvedFormType.php index 5ccc2e1fb50f0..2bc1b4e7b4e60 100644 --- a/src/Symfony/Component/Form/ResolvedFormType.php +++ b/src/Symfony/Component/Form/ResolvedFormType.php @@ -24,16 +24,6 @@ */ class ResolvedFormType implements ResolvedFormTypeInterface { - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $blockPrefix; - /** * @var FormTypeInterface */ @@ -56,64 +46,17 @@ class ResolvedFormType implements ResolvedFormTypeInterface public function __construct(FormTypeInterface $innerType, array $typeExtensions = array(), ResolvedFormTypeInterface $parent = null) { - $fqcn = get_class($innerType); - $name = $innerType->getName(); - $hasCustomName = $name !== $fqcn; - - if (method_exists($innerType, 'getBlockPrefix')) { - $reflector = new \ReflectionMethod($innerType, 'getName'); - $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; - - $reflector = new \ReflectionMethod($innerType, 'getBlockPrefix'); - $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'; - - // Bundles compatible with both 2.3 and 2.8 should implement both methods - // Anyone else should only override getBlockPrefix() if they actually - // want to have a different block prefix than the default one - if ($isOldOverwritten && !$isNewOverwritten) { - @trigger_error(get_class($this->innerType).': The FormTypeInterface::getName() method is deprecated since version 2.8 and will be removed in 3.0. Remove it from your classes. Use getBlockPrefix() if you want to customize the template block prefix. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED); - } - - $blockPrefix = $innerType->getBlockPrefix(); - } else { - @trigger_error(get_class($this->innerType).': The FormTypeInterface::getBlockPrefix() method will be added in version 3.0. You should extend AbstractType or add it to your implementation.', E_USER_DEPRECATED); - - // Deal with classes that don't extend AbstractType - // Calculate block prefix from the FQCN by default - $blockPrefix = $hasCustomName ? $name : StringUtil::fqcnToBlockPrefix($fqcn); - } - - // As of Symfony 2.8, getName() returns the FQCN by default - // Otherwise check that the name matches the old naming restrictions - if ($hasCustomName && !preg_match('/^[a-z0-9_]*$/i', $name)) { - throw new InvalidArgumentException(sprintf( - 'The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".', - get_class($innerType), - $name - )); - } - foreach ($typeExtensions as $extension) { if (!$extension instanceof FormTypeExtensionInterface) { throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormTypeExtensionInterface'); } } - $this->name = $name; - $this->blockPrefix = $blockPrefix; $this->innerType = $innerType; $this->typeExtensions = $typeExtensions; $this->parent = $parent; } - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - /** * Returns the prefix of the template block name for this type. * @@ -121,7 +64,7 @@ public function getName() */ public function getBlockPrefix() { - return $this->blockPrefix; + return $this->innerType->getBlockPrefix(); } /** diff --git a/src/Symfony/Component/Form/ResolvedFormTypeInterface.php b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php index f8253e710c7e2..f496cdc578899 100644 --- a/src/Symfony/Component/Form/ResolvedFormTypeInterface.php +++ b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php @@ -20,13 +20,6 @@ */ interface ResolvedFormTypeInterface { - /** - * Returns the name of the type. - * - * @return string The type name. - */ - public function getName(); - /** * Returns the parent type. * diff --git a/src/Symfony/Component/Form/Test/DeprecationErrorHandler.php b/src/Symfony/Component/Form/Test/DeprecationErrorHandler.php deleted file mode 100644 index a88ec7921465e..0000000000000 --- a/src/Symfony/Component/Form/Test/DeprecationErrorHandler.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormEvent; - -/** - * @deprecated since version 2.3, to be removed in 3.0. - */ -class DeprecationErrorHandler -{ - public static function handle($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & ~E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public static function handleBC($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & ~E_USER_DEPRECATED) { - return true; - } - - return false; - } - - public static function preBind($listener, FormEvent $event) - { - set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle')); - $listener->preBind($event); - restore_error_handler(); - } -} diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index 668c6eef9bb6c..0cde03e51f8c8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -137,14 +137,6 @@ public function testPassMaxLengthToView() $this->assertSame(10, $view->vars['attr']['maxlength']); } - public function testPassMaxLengthBCToView() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, array('max_length' => 10)); - $view = $form->createView(); - - $this->assertSame(10, $view->vars['attr']['maxlength']); - } - public function testDataClassMayBeNull() { $this->factory->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', null, array( diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php deleted file mode 100644 index 50c071ef53072..0000000000000 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.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\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase; - -/** - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\Test\TypeTestCase} instead. - */ -abstract class TypeTestCase extends BaseTypeTestCase -{ - protected function setUp() - { - @trigger_error('Abstract class '.__CLASS__.' is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Test\TypeTestCase class instead.', E_USER_DEPRECATED); - parent::setUp(); - } -} diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php index fc0b76fdf0557..905cd258157be 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php @@ -81,7 +81,6 @@ public function testExtractConfiguration() $this->assertSame(array( 'id' => 'name', 'name' => 'name', - 'type' => 'type_name', 'type_class' => 'stdClass', 'synchronized' => 'true', 'passed_options' => array(), @@ -115,7 +114,6 @@ public function testExtractConfigurationSortsPassedOptions() $this->assertSame(array( 'id' => 'name', 'name' => 'name', - 'type' => 'type_name', 'type_class' => 'stdClass', 'synchronized' => 'true', 'passed_options' => array( @@ -150,7 +148,6 @@ public function testExtractConfigurationSortsResolvedOptions() $this->assertSame(array( 'id' => 'name', 'name' => 'name', - 'type' => 'type_name', 'type_class' => 'stdClass', 'synchronized' => 'true', 'passed_options' => array(), @@ -190,7 +187,6 @@ public function testExtractConfigurationBuildsIdRecursively() $this->assertSame(array( 'id' => 'grandParent_parent_name', 'name' => 'name', - 'type' => 'type_name', 'type_class' => 'stdClass', 'synchronized' => 'true', 'passed_options' => array(), diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index 74d6095d17d59..cf9252f1e80ff 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -22,7 +22,6 @@ use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; -use Symfony\Component\Validator\Validation; /** * @author Bernhard Schussek @@ -56,11 +55,6 @@ protected function setUp() parent::setUp(); } - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new FormValidator($this->serverParams); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php index 788b8a082b50e..570f26a83f83f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php @@ -180,33 +180,11 @@ public function testValidateWithEmptyViolationList() $this->listener->validateForm(new FormEvent($form, null)); } - public function testValidatorInterfaceSinceSymfony25() + public function testValidatorInterface() { - // Mock of ValidatorInterface since apiVersion 2.5 $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); $listener = new ValidationListener($validator, $this->violationMapper); $this->assertAttributeSame($validator, 'validator', $listener); } - - /** - * @group legacy - */ - public function testValidatorInterfaceUntilSymfony24() - { - // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - - $listener = new ValidationListener($validator, $this->violationMapper); - $this->assertAttributeSame($validator, 'validator', $listener); - } - - /** - * @group legacy - * @expectedException \InvalidArgumentException - */ - public function testInvalidValidatorInterface() - { - new ValidationListener(null, $this->violationMapper); - } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php index 214b8236cb670..9f920003c51f2 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php @@ -45,32 +45,14 @@ public function testValidConstraint() $this->assertSame(array($valid), $form->getConfig()->getOption('constraints')); } - public function testValidatorInterfaceSinceSymfony25() + public function testValidatorInterface() { - // Mock of ValidatorInterface since apiVersion 2.5 $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); } - public function testValidatorInterfaceUntilSymfony24() - { - // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - - $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); - $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidValidatorInterface() - { - new FormTypeValidatorExtension(null); - } - protected function createForm(array $options = array()) { return $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, $options); diff --git a/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php b/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php index 8e8628ab8fc67..042bee51280e2 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/TestExtension.php @@ -31,7 +31,7 @@ public function __construct(FormTypeGuesserInterface $guesser) public function addType(FormTypeInterface $type) { - $this->types[$type->getName() ?: get_class($type)] = $type; + $this->types[get_class($type)] = $type; } public function getType($name) diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index 2c3ab000ffe30..9d5cb472ab33b 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php @@ -40,7 +40,7 @@ public function testAddType() $extensions = $registry->getExtensions(); $this->assertCount(1, $extensions); - $this->assertTrue($extensions[0]->hasType($this->type->getName())); + $this->assertTrue($extensions[0]->hasType(get_class($this->type))); $this->assertNull($extensions[0]->getTypeGuesser()); } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryTest.php b/src/Symfony/Component/Form/Tests/FormFactoryTest.php index ee3e47eca9150..3649d18f46646 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryTest.php +++ b/src/Symfony/Component/Form/Tests/FormFactoryTest.php @@ -153,7 +153,7 @@ public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() /** * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - * @expectedExceptionMessage Expected argument of type "string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface", "stdClass" given + * @expectedExceptionMessage Expected argument of type "string", "stdClass" given */ public function testCreateNamedBuilderThrowsUnderstandableException() { diff --git a/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php b/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php deleted file mode 100644 index 09fd394fb9ccf..0000000000000 --- a/src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Test\FormIntegrationTestCase as BaseFormIntegrationTestCase; - -/** - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\Test\FormIntegrationTestCase} instead. - */ -abstract class FormIntegrationTestCase extends BaseFormIntegrationTestCase -{ - /** - * {@inheritdoc} - */ - protected function setUp() - { - @trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Test\FormIntegrationTestCase class instead.', E_USER_DEPRECATED); - parent::setUp(); - } -} diff --git a/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php b/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php deleted file mode 100644 index 884bfe3733bb4..0000000000000 --- a/src/Symfony/Component/Form/Tests/FormPerformanceTestCase.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Test\FormPerformanceTestCase as BaseFormPerformanceTestCase; - -/** - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link \Symfony\Component\Form\Test\FormPerformanceTestCase} instead. - */ -abstract class FormPerformanceTestCase extends BaseFormPerformanceTestCase -{ - /** - * {@inheritdoc} - */ - protected function setUp() - { - @trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Test\FormPerformanceTestCase class instead.', E_USER_DEPRECATED); - parent::setUp(); - } -} diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 13fe8141a36a2..51cea54356f74 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -323,51 +323,6 @@ public function testFinishView() $this->resolvedType->finishView($view, $form, $options); } - /** - * @dataProvider provideValidNames - */ - public function testGetName($name) - { - $this->type->expects($this->once()) - ->method('getName') - ->willReturn($name); - - $resolvedType = new ResolvedFormType($this->type); - - $this->assertSame($name, $resolvedType->getName()); - } - - /** - * @dataProvider provideInvalidNames - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testGetNameFailsIfInvalidChars($name) - { - $this->type->expects($this->once()) - ->method('getName') - ->willReturn($name); - - new ResolvedFormType($this->type); - } - - public function provideValidNames() - { - return array( - array('text'), - array('type123'), - array('my_type123'), - ); - } - - public function provideInvalidNames() - { - return array( - array('my-type'), - array('my[type]'), - array('my{type}'), - ); - } - public function testGetBlockPrefix() { $this->type->expects($this->once()) diff --git a/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php b/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php index ba157b7d182f4..f07ec82f0a0ec 100644 --- a/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php +++ b/src/Symfony/Component/Form/Util/InheritDataAwareIterator.php @@ -23,6 +23,21 @@ * * @author Bernhard Schussek */ -class InheritDataAwareIterator extends VirtualFormAwareIterator +class InheritDataAwareIterator extends \IteratorIterator implements \RecursiveIterator { + /** + * {@inheritdoc} + */ + public function getChildren() + { + return new static($this->current()); + } + + /** + *{@inheritdoc} + */ + public function hasChildren() + { + return (bool) $this->current()->getConfig()->getInheritData(); + } } diff --git a/src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php b/src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php deleted file mode 100644 index acc864818d9a3..0000000000000 --- a/src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -/** - * Iterator that traverses an array of forms. - * - * You can wrap the iterator into a {@link \RecursiveIterator} in order to - * enter any child form that inherits its parent's data and iterate the children - * of that form as well. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link InheritDataAwareIterator} instead. - */ -class VirtualFormAwareIterator extends \IteratorIterator implements \RecursiveIterator -{ - public function __construct(\Traversable $iterator) - { - /* - * Prevent to trigger deprecation notice when already using the - * InheritDataAwareIterator class that extends this deprecated one. - * The {@link Symfony\Component\Form\Util\InheritDataAwareIterator::__construct} method - * forces this argument to false. - */ - if (__CLASS__ === get_class($this)) { - @trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Util\InheritDataAwareIterator class instead.', E_USER_DEPRECATED); - } - - parent::__construct($iterator); - } - - /** - * {@inheritdoc} - */ - public function getChildren() - { - return new static($this->current()); - } - - /** - *{@inheritdoc} - */ - public function hasChildren() - { - return (bool) $this->current()->getConfig()->getInheritData(); - } -} diff --git a/src/Symfony/Component/Validator/ClassBasedInterface.php b/src/Symfony/Component/Validator/ClassBasedInterface.php deleted file mode 100644 index 7c2eb8f0f7c92..0000000000000 --- a/src/Symfony/Component/Validator/ClassBasedInterface.php +++ /dev/null @@ -1,30 +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; - -/** - * An object backed by a PHP class. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Mapping\ClassMetadataInterface} instead. - */ -interface ClassBasedInterface -{ - /** - * Returns the name of the backing PHP class. - * - * @return string The name of the backing class. - */ - public function getClassName(); -} diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index df6e86e627b62..cada59295b8b0 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -11,9 +11,7 @@ namespace Symfony\Component\Validator; -use Symfony\Component\Validator\Context\ExecutionContextInterface as ExecutionContextInterface2Dot5; -use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface; -use Symfony\Component\Validator\Violation\LegacyConstraintViolationBuilder; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Base class for constraint validators. @@ -50,51 +48,6 @@ public function initialize(ExecutionContextInterface $context) $this->context = $context; } - /** - * Wrapper for {@link ExecutionContextInterface::buildViolation} that - * supports the 2.4 context API. - * - * @param string $message The violation message - * @param array $parameters The message parameters - * - * @return ConstraintViolationBuilderInterface The violation builder - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - protected function buildViolation($message, array $parameters = array()) - { - @trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - if ($this->context instanceof ExecutionContextInterface2Dot5) { - return $this->context->buildViolation($message, $parameters); - } - - return new LegacyConstraintViolationBuilder($this->context, $message, $parameters); - } - - /** - * Wrapper for {@link ExecutionContextInterface::buildViolation} that - * supports the 2.4 context API. - * - * @param ExecutionContextInterface $context The context to use - * @param string $message The violation message - * @param array $parameters The message parameters - * - * @return ConstraintViolationBuilderInterface The violation builder - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - protected function buildViolationInContext(ExecutionContextInterface $context, $message, array $parameters = array()) - { - @trigger_error('The '.__METHOD__.' is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - if ($context instanceof ExecutionContextInterface2Dot5) { - return $context->buildViolation($message, $parameters); - } - - return new LegacyConstraintViolationBuilder($context, $message, $parameters); - } - /** * Returns a string representation of the type of the value. * diff --git a/src/Symfony/Component/Validator/ConstraintValidatorInterface.php b/src/Symfony/Component/Validator/ConstraintValidatorInterface.php index 85fd451ac4a69..b215346a48885 100644 --- a/src/Symfony/Component/Validator/ConstraintValidatorInterface.php +++ b/src/Symfony/Component/Validator/ConstraintValidatorInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Validator\Context\ExecutionContextInterface; + /** * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index 31b44d23cd3da..665d73e80888f 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -141,19 +141,6 @@ public function getMessageTemplate() /** * {@inheritdoc} - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use getParameters() instead - */ - public function getMessageParameters() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.7, to be removed in 3.0. Use the ConstraintViolation::getParameters() method instead.', E_USER_DEPRECATED); - - return $this->parameters; - } - - /** - * Alias of {@link getMessageParameters()}. */ public function getParameters() { @@ -162,19 +149,6 @@ public function getParameters() /** * {@inheritdoc} - * - * @deprecated since version 2.7, to be removed in 3.0. - * Use getPlural() instead - */ - public function getMessagePluralization() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.7, to be removed in 3.0. Use the ConstraintViolation::getPlural() method instead.', E_USER_DEPRECATED); - - return $this->plural; - } - - /** - * Alias of {@link getMessagePluralization()}. */ public function getPlural() { diff --git a/src/Symfony/Component/Validator/ConstraintViolationInterface.php b/src/Symfony/Component/Validator/ConstraintViolationInterface.php index eff79b6e1552c..bcbc718d28e03 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationInterface.php +++ b/src/Symfony/Component/Validator/ConstraintViolationInterface.php @@ -46,7 +46,7 @@ public function getMessage(); * Returns the raw violation message. * * The raw violation message contains placeholders for the parameters - * returned by {@link getMessageParameters}. Typically you'll pass the + * returned by {@link getParameters}. Typically you'll pass the * message template and parameters to a translation engine. * * @return string The raw violation message. @@ -60,10 +60,8 @@ public function getMessageTemplate(); * that appear in the message template. * * @see getMessageTemplate() - * - * @deprecated since version 2.7, to be replaced by getParameters() in 3.0. */ - public function getMessageParameters(); + public function getParameters(); /** * Returns a number for pluralizing the violation message. @@ -80,10 +78,8 @@ public function getMessageParameters(); * pluralization form (in this case "choices"). * * @return int|null The number to use to pluralize of the message. - * - * @deprecated since version 2.7, to be replaced by getPlural() in 3.0. */ - public function getMessagePluralization(); + public function getPlural(); /** * Returns the root element of the validation. diff --git a/src/Symfony/Component/Validator/Constraints/AllValidator.php b/src/Symfony/Component/Validator/Constraints/AllValidator.php index 94ff8190e47cb..a5eb32bbd9796 100644 --- a/src/Symfony/Component/Validator/Constraints/AllValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AllValidator.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -40,17 +39,10 @@ public function validate($value, Constraint $constraint) $context = $this->context; - if ($context instanceof ExecutionContextInterface) { - $validator = $context->getValidator()->inContext($context); - - foreach ($value as $key => $element) { - $validator->atPath('['.$key.']')->validate($element, $constraint->constraints); - } - } else { - // 2.4 API - foreach ($value as $key => $element) { - $context->validateValue($element, $constraint->constraints, '['.$key.']'); - } + $validator = $context->getValidator()->inContext($context); + + foreach ($value as $key => $element) { + $validator->atPath('['.$key.']')->validate($element, $constraint->constraints); } } } diff --git a/src/Symfony/Component/Validator/Constraints/Callback.php b/src/Symfony/Component/Validator/Constraints/Callback.php index bef94dd9cb104..c95c34d4c3f21 100644 --- a/src/Symfony/Component/Validator/Constraints/Callback.php +++ b/src/Symfony/Component/Validator/Constraints/Callback.php @@ -28,13 +28,6 @@ class Callback extends Constraint */ public $callback; - /** - * @var array - * - * @deprecated since version 2.4, to be removed in 3.0. - */ - public $methods; - /** * {@inheritdoc} */ @@ -45,16 +38,9 @@ public function __construct($options = null) $options = $options['value']; } - if (is_array($options) && isset($options['methods'])) { - @trigger_error('The "methods" option of the '.__CLASS__.' class is deprecated since version 2.4 and will be removed in 3.0. Use the "callback" option instead.', E_USER_DEPRECATED); - } - - if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups'])) { + if (is_array($options) && !isset($options['callback']) && !isset($options['groups'])) { if (is_callable($options) || !$options) { $options = array('callback' => $options); - } else { - // @deprecated, to be removed in 3.0 - $options = array('methods' => $options); } } diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index df4920401197f..28079b40f1894 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -32,45 +32,29 @@ public function validate($object, Constraint $constraint) throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Callback'); } - if (null !== $constraint->callback && null !== $constraint->methods) { - throw new ConstraintDefinitionException( - 'The Callback constraint supports either the option "callback" '. - 'or "methods", but not both at the same time.' - ); - } - - // has to be an array so that we can differentiate between callables - // and method names - if (null !== $constraint->methods && !is_array($constraint->methods)) { - throw new UnexpectedTypeException($constraint->methods, 'array'); - } - - $methods = $constraint->methods ?: array($constraint->callback); - - foreach ($methods as $method) { - if ($method instanceof \Closure) { - $method($object, $this->context); - } elseif (is_array($method)) { - if (!is_callable($method)) { - if (isset($method[0]) && is_object($method[0])) { - $method[0] = get_class($method[0]); - } - throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method))); + $method = $constraint->callback; + if ($method instanceof \Closure) { + $method($object, $this->context); + } elseif (is_array($method)) { + if (!is_callable($method)) { + if (isset($method[0]) && is_object($method[0])) { + $method[0] = get_class($method[0]); } + throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method))); + } - call_user_func($method, $object, $this->context); - } elseif (null !== $object) { - if (!method_exists($object, $method)) { - throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class %s', $method, get_class($object))); - } + call_user_func($method, $object, $this->context); + } elseif (null !== $object) { + if (!method_exists($object, $method)) { + throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class %s', $method, get_class($object))); + } - $reflMethod = new \ReflectionMethod($object, $method); + $reflMethod = new \ReflectionMethod($object, $method); - if ($reflMethod->isStatic()) { - $reflMethod->invoke(null, $object, $this->context); - } else { - $reflMethod->invoke($object, $this->context); - } + if ($reflMethod->isStatic()) { + $reflMethod->invoke(null, $object, $this->context); + } else { + $reflMethod->invoke($object, $this->context); } } } diff --git a/src/Symfony/Component/Validator/Constraints/Collection/Optional.php b/src/Symfony/Component/Validator/Constraints/Collection/Optional.php deleted file mode 100644 index 68471f925579a..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/Collection/Optional.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\Constraints\Collection; - -@trigger_error('The '.__NAMESPACE__.'\Optional class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Validator\Constraints\Optional class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Validator\Constraints\Optional as BaseOptional; - -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Bernhard Schussek - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link \Symfony\Component\Validator\Constraints\Optional} instead. - */ -class Optional extends BaseOptional -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/Collection/Required.php b/src/Symfony/Component/Validator/Constraints/Collection/Required.php deleted file mode 100644 index 4b062bb558db7..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/Collection/Required.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\Constraints\Collection; - -@trigger_error('The '.__NAMESPACE__.'\Required class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Validator\Constraints\Required class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Validator\Constraints\Required as BaseRequired; - -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Bernhard Schussek - * - * @deprecated since version 2.3, to be removed in 3.0. - * Use {@link \Symfony\Component\Validator\Constraints\Required} instead. - */ -class Required extends BaseRequired -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php index 737e880968aa0..f4a6d19ec7571 100644 --- a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -56,53 +55,30 @@ public function validate($value, Constraint $constraint) if ($existsInArray || $existsInArrayAccess) { if (count($fieldConstraint->constraints) > 0) { - if ($context instanceof ExecutionContextInterface) { - $context->getValidator() - ->inContext($context) - ->atPath('['.$field.']') - ->validate($value[$field], $fieldConstraint->constraints); - } else { - // 2.4 API - $context->validateValue($value[$field], $fieldConstraint->constraints, '['.$field.']'); - } - } - } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) { - if ($context instanceof ExecutionContextInterface) { - $context->buildViolation($constraint->missingFieldsMessage) - ->atPath('['.$field.']') - ->setParameter('{{ field }}', $this->formatValue($field)) - ->setInvalidValue(null) - ->setCode(Collection::MISSING_FIELD_ERROR) - ->addViolation(); - } else { - $this->buildViolationInContext($context, $constraint->missingFieldsMessage) + $context->getValidator() + ->inContext($context) ->atPath('['.$field.']') - ->setParameter('{{ field }}', $this->formatValue($field)) - ->setInvalidValue(null) - ->setCode(Collection::MISSING_FIELD_ERROR) - ->addViolation(); + ->validate($value[$field], $fieldConstraint->constraints); } + } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) { + $context->buildViolation($constraint->missingFieldsMessage) + ->atPath('['.$field.']') + ->setParameter('{{ field }}', $this->formatValue($field)) + ->setInvalidValue(null) + ->setCode(Collection::MISSING_FIELD_ERROR) + ->addViolation(); } } if (!$constraint->allowExtraFields) { foreach ($value as $field => $fieldValue) { if (!isset($constraint->fields[$field])) { - if ($context instanceof ExecutionContextInterface) { - $context->buildViolation($constraint->extraFieldsMessage) - ->atPath('['.$field.']') - ->setParameter('{{ field }}', $this->formatValue($field)) - ->setInvalidValue($fieldValue) - ->setCode(Collection::NO_SUCH_FIELD_ERROR) - ->addViolation(); - } else { - $this->buildViolationInContext($context, $constraint->extraFieldsMessage) - ->atPath('['.$field.']') - ->setParameter('{{ field }}', $this->formatValue($field)) - ->setInvalidValue($fieldValue) - ->setCode(Collection::NO_SUCH_FIELD_ERROR) - ->addViolation(); - } + $context->buildViolation($constraint->extraFieldsMessage) + ->atPath('['.$field.']') + ->setParameter('{{ field }}', $this->formatValue($field)) + ->setInvalidValue($fieldValue) + ->setCode(Collection::NO_SUCH_FIELD_ERROR) + ->addViolation(); } } } diff --git a/src/Symfony/Component/Validator/Constraints/False.php b/src/Symfony/Component/Validator/Constraints/False.php deleted file mode 100644 index 1e103ade514d6..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/False.php +++ /dev/null @@ -1,26 +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\Constraints; - -@trigger_error('The '.__NAMESPACE__.'\False class is deprecated since version 2.7 and will be removed in 3.0. Use the IsFalse class in the same namespace instead.', E_USER_DEPRECATED); - -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. Use IsFalse instead. - */ -class False extends IsFalse -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/FalseValidator.php b/src/Symfony/Component/Validator/Constraints/FalseValidator.php deleted file mode 100644 index 9614c3037fe92..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/FalseValidator.php +++ /dev/null @@ -1,23 +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\Constraints; - -@trigger_error('The '.__NAMESPACE__.'\FalseValidator class is deprecated since version 2.7 and will be removed in 3.0. Use the IsFalseValidator class in the same namespace instead.', E_USER_DEPRECATED); - -/** - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. Use IsFalseValidator instead. - */ -class FalseValidator extends IsFalseValidator -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/GroupSequence.php b/src/Symfony/Component/Validator/Constraints/GroupSequence.php index aea05583103d5..8a9627b016f96 100644 --- a/src/Symfony/Component/Validator/Constraints/GroupSequence.php +++ b/src/Symfony/Component/Validator/Constraints/GroupSequence.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Validator\Constraints; -use Symfony\Component\Validator\Exception\OutOfBoundsException; - /** * A sequence of validation groups. * @@ -53,10 +51,8 @@ * @Target({"CLASS", "ANNOTATION"}) * * @author Bernhard Schussek - * - * Implementing \ArrayAccess, \IteratorAggregate and \Countable is @deprecated since 2.5 and will be removed in 3.0. */ -class GroupSequence implements \ArrayAccess, \IteratorAggregate, \Countable +class GroupSequence { /** * The groups in the sequence. @@ -91,121 +87,4 @@ public function __construct(array $groups) // Support for Doctrine annotations $this->groups = isset($groups['value']) ? $groups['value'] : $groups; } - - /** - * Returns an iterator for this group. - * - * Implemented for backwards compatibility with Symfony < 2.5. - * - * @return \Traversable The iterator - * - * @see \IteratorAggregate::getIterator() - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function getIterator() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - return new \ArrayIterator($this->groups); - } - - /** - * 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 since version 2.5, to be removed in 3.0. - */ - public function offsetExists($offset) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - return isset($this->groups[$offset]); - } - - /** - * 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 since version 2.5, to be removed in 3.0. - */ - public function offsetGet($offset) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (!isset($this->groups[$offset])) { - throw new OutOfBoundsException(sprintf( - 'The offset "%s" does not exist.', - $offset - )); - } - - return $this->groups[$offset]; - } - - /** - * 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 since version 2.5, to be removed in 3.0. - */ - public function offsetSet($offset, $value) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (null !== $offset) { - $this->groups[$offset] = $value; - - return; - } - - $this->groups[] = $value; - } - - /** - * Removes the group at the given offset. - * - * Implemented for backwards compatibility with Symfony < 2.5. - * - * @param int $offset The offset - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function offsetUnset($offset) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - unset($this->groups[$offset]); - } - - /** - * Returns the number of groups in the sequence. - * - * Implemented for backwards compatibility with Symfony < 2.5. - * - * @return int The number of groups - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function count() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - return count($this->groups); - } } diff --git a/src/Symfony/Component/Validator/Constraints/Iban.php b/src/Symfony/Component/Validator/Constraints/Iban.php index 9c4d3838fa0f8..bcb30655aa44b 100644 --- a/src/Symfony/Component/Validator/Constraints/Iban.php +++ b/src/Symfony/Component/Validator/Constraints/Iban.php @@ -23,21 +23,15 @@ */ class Iban extends Constraint { - /** @deprecated, to be removed in 3.0. */ - const TOO_SHORT_ERROR = '88e5e319-0aeb-4979-a27e-3d9ce0c16166'; const INVALID_COUNTRY_CODE_ERROR = 'de78ee2c-bd50-44e2-aec8-3d8228aeadb9'; const INVALID_CHARACTERS_ERROR = '8d3d85e4-784f-4719-a5bc-d9e40d45a3a5'; - /** @deprecated, to be removed in 3.0. */ - const INVALID_CASE_ERROR = 'f4bf62fe-03ec-42af-a53b-68e21b1e7274'; const CHECKSUM_FAILED_ERROR = 'b9401321-f9bf-4dcb-83c1-f31094440795'; const INVALID_FORMAT_ERROR = 'c8d318f1-2ecc-41ba-b983-df70d225cf5a'; const NOT_SUPPORTED_COUNTRY_CODE_ERROR = 'e2c259f3-4b46-48e6-b72e-891658158ec8'; protected static $errorNames = array( - self::TOO_SHORT_ERROR => 'TOO_SHORT_ERROR', self::INVALID_COUNTRY_CODE_ERROR => 'INVALID_COUNTRY_CODE_ERROR', self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', - self::INVALID_CASE_ERROR => 'INVALID_CASE_ERROR', self::CHECKSUM_FAILED_ERROR => 'CHECKSUM_FAILED_ERROR', self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR', self::NOT_SUPPORTED_COUNTRY_CODE_ERROR => 'NOT_SUPPORTED_COUNTRY_CODE_ERROR', diff --git a/src/Symfony/Component/Validator/Constraints/Isbn.php b/src/Symfony/Component/Validator/Constraints/Isbn.php index f1e83b99ea02a..615feb66416d4 100644 --- a/src/Symfony/Component/Validator/Constraints/Isbn.php +++ b/src/Symfony/Component/Validator/Constraints/Isbn.php @@ -43,20 +43,6 @@ class Isbn extends Constraint public $type; public $message; - /** - * @deprecated since version 2.5, to be removed in 3.0. Use option "type" instead. - * - * @var bool - */ - public $isbn10 = false; - - /** - * @deprecated since version 2.5, to be removed in 3.0. Use option "type" instead. - * - * @var bool - */ - public $isbn13 = false; - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index aaf52dc561c3c..3d4695281dba6 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -47,16 +47,6 @@ public function validate($value, Constraint $constraint) $value = (string) $value; $canonical = str_replace('-', '', $value); - if (null === $constraint->type) { - if ($constraint->isbn10 && !$constraint->isbn13) { - @trigger_error('The "isbn10" option of the Isbn constraint is deprecated since version 2.5 and will be removed in 3.0. Use the "type" option instead.', E_USER_DEPRECATED); - $constraint->type = 'isbn10'; - } elseif ($constraint->isbn13 && !$constraint->isbn10) { - @trigger_error('The "isbn13" option of the Isbn constraint is deprecated since version 2.5 and will be removed in 3.0. Use the "type" option instead.', E_USER_DEPRECATED); - $constraint->type = 'isbn13'; - } - } - // Explicitly validate against ISBN-10 if ('isbn10' === $constraint->type) { if (true !== ($code = $this->validateIsbn10($canonical))) { diff --git a/src/Symfony/Component/Validator/Constraints/Null.php b/src/Symfony/Component/Validator/Constraints/Null.php deleted file mode 100644 index 705d93fc41f3c..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/Null.php +++ /dev/null @@ -1,26 +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\Constraints; - -@trigger_error('The '.__NAMESPACE__.'\Null class is deprecated since version 2.7 and will be removed in 3.0. Use the IsNull class in the same namespace instead.', E_USER_DEPRECATED); - -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. Use IsNull instead. - */ -class Null extends IsNull -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php deleted file mode 100644 index bd17eab528c20..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ /dev/null @@ -1,23 +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\Constraints; - -@trigger_error('The '.__NAMESPACE__.'\NullValidator class is deprecated since version 2.7 and will be removed in 3.0. Use the IsNullValidator class in the same namespace instead.', E_USER_DEPRECATED); - -/** - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. Use IsNullValidator instead. - */ -class NullValidator extends IsNullValidator -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/Range.php b/src/Symfony/Component/Validator/Constraints/Range.php index bf050ac58dd18..dcaf9db955246 100644 --- a/src/Symfony/Component/Validator/Constraints/Range.php +++ b/src/Symfony/Component/Validator/Constraints/Range.php @@ -26,24 +26,6 @@ class Range extends Constraint const TOO_HIGH_ERROR = '2d28afcb-e32e-45fb-a815-01c431a86a69'; const TOO_LOW_ERROR = '76454e69-502c-46c5-9643-f447d837c4d5'; - /** - * @deprecated Deprecated since version 2.8, to be removed in 3.0. Use - * {@link INVALID_CHARACTERS_ERROR} instead. - */ - const INVALID_VALUE_ERROR = self::INVALID_CHARACTERS_ERROR; - - /** - * @deprecated Deprecated since version 2.8, to be removed in 3.0. Use - * {@link TOO_HIGH_ERROR} instead. - */ - const BEYOND_RANGE_ERROR = self::TOO_HIGH_ERROR; - - /** - * @deprecated Deprecated since version 2.8, to be removed in 3.0. Use - * {@link TOO_LOW_ERROR} instead. - */ - const BELOW_RANGE_ERROR = self::TOO_LOW_ERROR; - protected static $errorNames = array( self::INVALID_CHARACTERS_ERROR => 'INVALID_CHARACTERS_ERROR', self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR', diff --git a/src/Symfony/Component/Validator/Constraints/True.php b/src/Symfony/Component/Validator/Constraints/True.php deleted file mode 100644 index b9efff375e1bf..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/True.php +++ /dev/null @@ -1,26 +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\Constraints; - -@trigger_error('The '.__NAMESPACE__.'\True class is deprecated since version 2.7 and will be removed in 3.0. Use the IsTrue class in the same namespace instead.', E_USER_DEPRECATED); - -/** - * @Annotation - * @Target({"PROPERTY", "METHOD", "ANNOTATION"}) - * - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. Use IsTrue instead. - */ -class True extends IsTrue -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/TrueValidator.php b/src/Symfony/Component/Validator/Constraints/TrueValidator.php deleted file mode 100644 index 14d879808da02..0000000000000 --- a/src/Symfony/Component/Validator/Constraints/TrueValidator.php +++ /dev/null @@ -1,23 +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\Constraints; - -@trigger_error('The '.__NAMESPACE__.'\TrueValidator class is deprecated since version 2.7 and will be removed in 3.0. Use the IsTrueValidator class in the same namespace instead.', E_USER_DEPRECATED); - -/** - * @author Bernhard Schussek - * - * @deprecated since version 2.7, to be removed in 3.0. Use IsTrueValidator instead. - */ -class TrueValidator extends IsTrueValidator -{ -} diff --git a/src/Symfony/Component/Validator/Constraints/UuidValidator.php b/src/Symfony/Component/Validator/Constraints/UuidValidator.php index 08f9e27b736c8..e3c856f44b41e 100644 --- a/src/Symfony/Component/Validator/Constraints/UuidValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UuidValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Constraints\Deprecated\UuidValidator as Deprecated; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -57,21 +56,6 @@ class UuidValidator extends ConstraintValidator const LOOSE_MAX_LENGTH = 39; const LOOSE_FIRST_HYPHEN_POSITION = 4; - /** - * @deprecated since version 2.6, to be removed in 3.0 - */ - const STRICT_PATTERN = '/^[a-f0-9]{8}-[a-f0-9]{4}-[%s][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i'; - - /** - * @deprecated since version 2.6, to be removed in 3.0 - */ - const LOOSE_PATTERN = '/^[a-f0-9]{4}(?:-?[a-f0-9]{4}){7}$/i'; - - /** - * @deprecated since version 2.6, to be removed in 3.0 - */ - const STRICT_UUID_LENGTH = 36; - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Validator/Constraints/Valid.php b/src/Symfony/Component/Validator/Constraints/Valid.php index 0fb7829065225..439da3ae0056a 100644 --- a/src/Symfony/Component/Validator/Constraints/Valid.php +++ b/src/Symfony/Component/Validator/Constraints/Valid.php @@ -24,11 +24,6 @@ class Valid extends Constraint { public $traverse = true; - /** - * @deprecated since version 2.5, to be removed in Symfony 3.0. - */ - public $deep = true; - public function __construct($options = null) { if (is_array($options) && array_key_exists('groups', $options)) { @@ -38,10 +33,6 @@ public function __construct($options = null) )); } - if (is_array($options) && array_key_exists('deep', $options)) { - @trigger_error('The "deep" option for the Valid constraint is deprecated since version 2.5 and will be removed in 3.0. When traversing arrays, nested arrays are always traversed. When traversing nested objects, their traversal strategy is used.', E_USER_DEPRECATED); - } - parent::__construct($options); } } diff --git a/src/Symfony/Component/Validator/Context/ExecutionContext.php b/src/Symfony/Component/Validator/Context/ExecutionContext.php index 722bcc947d2f4..9233436bea747 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContext.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContext.php @@ -12,16 +12,15 @@ namespace Symfony\Component\Validator\Context; 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\Mapping\ClassMetadataInterface; use Symfony\Component\Validator\Mapping\MetadataInterface; +use Symfony\Component\Validator\Mapping\MemberMetadata; 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; /** @@ -183,25 +182,8 @@ public function setConstraint(Constraint $constraint) /** * {@inheritdoc} */ - public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) + public function addViolation($message, array $parameters = array()) { - // The parameters $invalidValue and following are ignored by the new - // 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); - - $this - ->buildViolation($message, $parameters) - ->setInvalidValue($invalidValue) - ->setPlural($plural) - ->setCode($code) - ->addViolation() - ; - - return; - } - $this->violations->add(new ConstraintViolation( $this->translator->trans($message, $parameters, $this->translationDomain), $message, @@ -294,7 +276,7 @@ public function getGroup() */ public function getClassName() { - return $this->metadata instanceof ClassBasedInterface ? $this->metadata->getClassName() : null; + return $this->metadata instanceof MemberMetadata || $this->metadata instanceof ClassMetadataInterface ? $this->metadata->getClassName() : null; } /** @@ -313,103 +295,6 @@ public function getPropertyPath($subPath = '') return PropertyPath::append($this->propertyPath, $subPath); } - /** - * {@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) - { - @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) - ; - } - - /** - * {@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__.'::getValidator() 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); - - $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; - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php index 2ef80b66f041a..044f7ce91fe0e 100644 --- a/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php +++ b/src/Symfony/Component/Validator/Context/ExecutionContextInterface.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Validator\Context; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface; +use Symfony\Component\Validator\Mapping\ClassMetadataInterface; use Symfony\Component\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface; @@ -60,8 +60,16 @@ * * @author Bernhard Schussek */ -interface ExecutionContextInterface extends LegacyExecutionContextInterface +interface ExecutionContextInterface { + /** + * Adds a violation at the current node of the validation graph. + * + * @param string $message The error message + * @param array $params The parameters substituted in the error message + */ + public function addViolation($message, array $params = array()); + /** * Returns a builder for adding a violation with extended information. * @@ -224,4 +232,114 @@ public function markObjectAsInitialized($cacheKey); * @see ObjectInitializerInterface */ public function isObjectInitialized($cacheKey); + + /** + * Returns the violations generated by the validator so far. + * + * @return ConstraintViolationListInterface The constraint violation list. + */ + public function getViolations(); + + /** + * Returns the value at which validation was started in the object graph. + * + * The validator, when given an object, traverses the properties and + * related objects and their properties. The root of the validation is the + * object from which the traversal started. + * + * The current value is returned by {@link getValue}. + * + * @return mixed The root value of the validation. + */ + public function getRoot(); + + /** + * Returns the value that the validator is currently validating. + * + * If you want to retrieve the object that was originally passed to the + * validator, use {@link getRoot}. + * + * @return mixed The currently validated value. + */ + public function getValue(); + + /** + * Returns the metadata for the currently validated value. + * + * With the core implementation, this method returns a + * {@link Mapping\ClassMetadata} instance if the current value is an object, + * a {@link Mapping\PropertyMetadata} instance if the current value is + * the value of a property and a {@link Mapping\GetterMetadata} instance if + * the validated value is the result of a getter method. + * + * If the validated value is neither of these, for example if the validator + * has been called with a plain value and constraint, this method returns + * null. + * + * @return MetadataInterface|null The metadata of the currently validated + * value. + */ + public function getMetadata(); + + /** + * Returns the validation group that is currently being validated. + * + * @return string The current validation group. + */ + public function getGroup(); + + /** + * Returns the class name of the current node. + * + * If the metadata of the current node does not implement + * {@link ClassMetadataInterface} or if no metadata is available for the + * current node, this method returns null. + * + * @return string|null The class name or null, if no class name could be found. + */ + public function getClassName(); + + /** + * Returns the property name of the current node. + * + * If the metadata of the current node does not implement + * {@link PropertyMetadataInterface} or if no metadata is available for the + * current node, this method returns null. + * + * @return string|null The property name or null, if no property name could be found. + */ + public function getPropertyName(); + + /** + * Returns the property path to the value that the validator is currently + * validating. + * + * For example, take the following object graph: + * + *
+     * (Person)---($address: Address)---($street: string)
+     * 
+ * + * When the Person instance is passed to the validator, the + * property path is initially empty. When the $address property + * of that person is validated, the property path is "address". When + * the $street property of the related Address instance + * is validated, the property path is "address.street". + * + * Properties of objects are prefixed with a dot in the property path. + * Indices of arrays or objects implementing the {@link \ArrayAccess} + * interface are enclosed in brackets. For example, if the property in + * the previous example is $addresses and contains an array + * of Address instance, the property path generated for the + * $street property of one of these addresses is for example + * "addresses[0].street". + * + * @param string $subPath Optional. The suffix appended to the current + * property path. + * + * @return string The current property path. The result may be an empty + * string if the validator is currently validating the + * root value of the validation graph. + */ + public function getPropertyPath($subPath = ''); } diff --git a/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php b/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php deleted file mode 100644 index f52b359fb39ca..0000000000000 --- a/src/Symfony/Component/Validator/Context/LegacyExecutionContext.php +++ /dev/null @@ -1,55 +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\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\MetadataFactoryInterface; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * An execution context that is compatible with the legacy API (< 2.5). - * - * @since 2.5 - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -class LegacyExecutionContext extends ExecutionContext -{ - /** - * @var MetadataFactoryInterface - */ - private $metadataFactory; - - /** - * Creates a new context. - * - * @see ExecutionContext::__construct() - * - * @internal Called by {@link LegacyExecutionContextFactory}. Should not be used - * in user code. - */ - public function __construct(ValidatorInterface $validator, $root, MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null) - { - parent::__construct( - $validator, - $root, - $translator, - $translationDomain - ); - - $this->metadataFactory = $metadataFactory; - } -} diff --git a/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php b/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php deleted file mode 100644 index c110644e99c1b..0000000000000 --- a/src/Symfony/Component/Validator/Context/LegacyExecutionContextFactory.php +++ /dev/null @@ -1,77 +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\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; - -/** - * Creates new {@link LegacyExecutionContext} instances. - * - * Implemented for backward compatibility with Symfony < 2.5. - * - * @since 2.5 - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -class LegacyExecutionContextFactory implements ExecutionContextFactoryInterface -{ - /** - * @var MetadataFactoryInterface - */ - private $metadataFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var string|null - */ - private $translationDomain; - - /** - * Creates a new context factory. - * - * @param MetadataFactoryInterface $metadataFactory The metadata factory - * @param TranslatorInterface $translator The translator - * @param string|null $translationDomain The translation domain - * to use for translating - * violation messages - */ - public function __construct(MetadataFactoryInterface $metadataFactory, TranslatorInterface $translator, $translationDomain = null) - { - $this->metadataFactory = $metadataFactory; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - } - - /** - * {@inheritdoc} - */ - public function createContext(ValidatorInterface $validator, $root) - { - return new LegacyExecutionContext( - $validator, - $root, - $this->metadataFactory, - $this->translator, - $this->translationDomain - ); - } -} diff --git a/src/Symfony/Component/Validator/DefaultTranslator.php b/src/Symfony/Component/Validator/DefaultTranslator.php deleted file mode 100644 index 85853d8d858ce..0000000000000 --- a/src/Symfony/Component/Validator/DefaultTranslator.php +++ /dev/null @@ -1,171 +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; - -@trigger_error('The class '.__NAMESPACE__.'\DefaultTranslator is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Translation\IdentityTranslator instead.', E_USER_DEPRECATED); - -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Exception\BadMethodCallException; -use Symfony\Component\Validator\Exception\InvalidArgumentException; - -/** - * Simple translator implementation that simply replaces the parameters in - * the message IDs. - * - * Example usage: - * - * $translator = new DefaultTranslator(); - * - * echo $translator->trans( - * 'This is a {{ var }}.', - * array('{{ var }}' => 'donkey') - * ); - * - * // -> This is a donkey. - * - * echo $translator->transChoice( - * 'This is {{ count }} donkey.|These are {{ count }} donkeys.', - * 3, - * array('{{ count }}' => 'three') - * ); - * - * // -> These are three donkeys. - * - * This translator does not support message catalogs, translation domains or - * locales. Instead, it implements a subset of the capabilities of - * {@link \Symfony\Component\Translation\Translator} and can be used in places - * where translation is not required by default but should be optional. - * - * @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Component\Translation\IdentityTranslator instead. - * - * @author Bernhard Schussek - */ -class DefaultTranslator implements TranslatorInterface -{ - /** - * Interpolates the given message. - * - * Parameters are replaced in the message in the same manner that - * {@link strtr()} uses. - * - * Example usage: - * - * $translator = new DefaultTranslator(); - * - * echo $translator->trans( - * 'This is a {{ var }}.', - * array('{{ var }}' => 'donkey') - * ); - * - * // -> This is a donkey. - * - * @param string $id The message id - * @param array $parameters An array of parameters for the message - * @param string $domain Ignored - * @param string $locale Ignored - * - * @return string The interpolated string - */ - public function trans($id, array $parameters = array(), $domain = null, $locale = null) - { - return strtr($id, $parameters); - } - - /** - * Interpolates the given choice message by choosing a variant according to a number. - * - * The variants are passed in the message ID using the format - * "|". "" is chosen if the passed $number is - * exactly 1. "" is chosen otherwise. - * - * This format is consistent with the format supported by - * {@link \Symfony\Component\Translation\Translator}, but it does not - * have the same expressiveness. While Translator supports intervals in - * message translations, which are needed for languages other than English, - * this translator does not. You should use Translator or a custom - * implementation of {@link \Symfony\Component\Translation\TranslatorInterface} if you need this or similar - * functionality. - * - * Example usage: - * - * echo $translator->transChoice( - * 'This is {{ count }} donkey.|These are {{ count }} donkeys.', - * 0, - * array('{{ count }}' => 0) - * ); - * - * // -> These are 0 donkeys. - * - * echo $translator->transChoice( - * 'This is {{ count }} donkey.|These are {{ count }} donkeys.', - * 1, - * array('{{ count }}' => 1) - * ); - * - * // -> This is 1 donkey. - * - * echo $translator->transChoice( - * 'This is {{ count }} donkey.|These are {{ count }} donkeys.', - * 3, - * array('{{ count }}' => 3) - * ); - * - * // -> These are 3 donkeys. - * - * @param string $id The message id - * @param int $number The number to use to find the index of the message - * @param array $parameters An array of parameters for the message - * @param string $domain Ignored - * @param string $locale Ignored - * - * @return string The translated string - * - * @throws InvalidArgumentException If the message id does not have the format - * "singular|plural". - */ - public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) - { - $ids = explode('|', $id); - - if (1 == $number) { - return strtr($ids[0], $parameters); - } - - if (!isset($ids[1])) { - throw new InvalidArgumentException(sprintf('The message "%s" cannot be pluralized, because it is missing a plural (e.g. "There is one apple|There are %%count%% apples").', $id)); - } - - return strtr($ids[1], $parameters); - } - - /** - * Not supported. - * - * @param string $locale The locale - * - * @throws BadMethodCallException - */ - public function setLocale($locale) - { - throw new BadMethodCallException('Unsupported method.'); - } - - /** - * Returns the locale of the translator. - * - * @return string Always returns 'en' - */ - public function getLocale() - { - return 'en'; - } -} diff --git a/src/Symfony/Component/Validator/ExecutionContext.php b/src/Symfony/Component/Validator/ExecutionContext.php deleted file mode 100644 index 5875e94ef45d7..0000000000000 --- a/src/Symfony/Component/Validator/ExecutionContext.php +++ /dev/null @@ -1,295 +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; - -@trigger_error('The '.__NAMESPACE__.'\ExecutionContext class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\Validator\Context\ExecutionContext class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Default implementation of {@link ExecutionContextInterface}. - * - * This class is immutable by design. - * - * @author Fabien Potencier - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContext} instead. - */ -class ExecutionContext implements ExecutionContextInterface -{ - /** - * @var GlobalExecutionContextInterface - */ - private $globalContext; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - /** - * @var MetadataInterface - */ - private $metadata; - - /** - * @var mixed - */ - private $value; - - /** - * @var string - */ - private $group; - - /** - * @var string - */ - private $propertyPath; - - /** - * Creates a new execution context. - * - * @param GlobalExecutionContextInterface $globalContext The global context storing node-independent state. - * @param TranslatorInterface $translator The translator for translating violation messages. - * @param null|string $translationDomain The domain of the validation messages. - * @param MetadataInterface $metadata The metadata of the validated node. - * @param mixed $value The value of the validated node. - * @param string $group The current validation group. - * @param string $propertyPath The property path to the current node. - */ - public function __construct(GlobalExecutionContextInterface $globalContext, TranslatorInterface $translator, $translationDomain = null, MetadataInterface $metadata = null, $value = null, $group = null, $propertyPath = '') - { - if (null === $group) { - $group = Constraint::DEFAULT_GROUP; - } - - $this->globalContext = $globalContext; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - $this->metadata = $metadata; - $this->value = $value; - $this->propertyPath = $propertyPath; - $this->group = $group; - } - - /** - * {@inheritdoc} - */ - public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null) - { - if (null === $plural) { - $translatedMessage = $this->translator->trans($message, $params, $this->translationDomain); - } else { - try { - $translatedMessage = $this->translator->transChoice($message, $plural, $params, $this->translationDomain); - } catch (\InvalidArgumentException $e) { - $translatedMessage = $this->translator->trans($message, $params, $this->translationDomain); - } - } - - $this->globalContext->getViolations()->add(new ConstraintViolation( - $translatedMessage, - $message, - $params, - $this->globalContext->getRoot(), - $this->propertyPath, - // check using func_num_args() to allow passing null values - func_num_args() >= 3 ? $invalidValue : $this->value, - $plural, - $code - )); - } - - /** - * {@inheritdoc} - */ - public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) - { - $this->globalContext->getViolations()->add(new ConstraintViolation( - null === $plural - ? $this->translator->trans($message, $parameters, $this->translationDomain) - : $this->translator->transChoice($message, $plural, $parameters, $this->translationDomain), - $message, - $parameters, - $this->globalContext->getRoot(), - $this->getPropertyPath($subPath), - // check using func_num_args() to allow passing null values - func_num_args() >= 4 ? $invalidValue : $this->value, - $plural, - $code - )); - } - - /** - * {@inheritdoc} - */ - public function getViolations() - { - return $this->globalContext->getViolations(); - } - - /** - * {@inheritdoc} - */ - public function getRoot() - { - return $this->globalContext->getRoot(); - } - - /** - * {@inheritdoc} - */ - public function getPropertyPath($subPath = '') - { - if ('' != $subPath && '' !== $this->propertyPath && '[' !== $subPath[0]) { - return $this->propertyPath.'.'.$subPath; - } - - return $this->propertyPath.$subPath; - } - - /** - * {@inheritdoc} - */ - public function getClassName() - { - if ($this->metadata instanceof ClassBasedInterface) { - return $this->metadata->getClassName(); - } - } - - /** - * {@inheritdoc} - */ - public function getPropertyName() - { - if ($this->metadata instanceof PropertyMetadataInterface) { - return $this->metadata->getPropertyName(); - } - } - - /** - * {@inheritdoc} - */ - public function getValue() - { - return $this->value; - } - - /** - * {@inheritdoc} - */ - public function getGroup() - { - return $this->group; - } - - /** - * {@inheritdoc} - */ - public function getMetadata() - { - return $this->metadata; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFor($value) - { - return $this->globalContext->getMetadataFactory()->getMetadataFor($value); - } - - /** - * {@inheritdoc} - */ - public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false) - { - $propertyPath = $this->getPropertyPath($subPath); - - foreach ($this->resolveGroups($groups) as $group) { - $this->globalContext->getVisitor()->validate($value, $group, $propertyPath, $traverse, $deep); - } - } - - /** - * {@inheritdoc} - */ - public function validateValue($value, $constraints, $subPath = '', $groups = null) - { - $constraints = is_array($constraints) ? $constraints : array($constraints); - - if (null === $groups && '' === $subPath) { - $context = clone $this; - $context->value = $value; - $context->executeConstraintValidators($value, $constraints); - - return; - } - - $propertyPath = $this->getPropertyPath($subPath); - - foreach ($this->resolveGroups($groups) as $group) { - $context = clone $this; - $context->value = $value; - $context->group = $group; - $context->propertyPath = $propertyPath; - $context->executeConstraintValidators($value, $constraints); - } - } - - /** - * {@inheritdoc} - */ - public function getMetadataFactory() - { - return $this->globalContext->getMetadataFactory(); - } - - /** - * Executes the validators of the given constraints for the given value. - * - * @param mixed $value The value to validate. - * @param Constraint[] $constraints The constraints to match against. - */ - private function executeConstraintValidators($value, array $constraints) - { - foreach ($constraints as $constraint) { - $validator = $this->globalContext->getValidatorFactory()->getInstance($constraint); - $validator->initialize($this); - $validator->validate($value, $constraint); - } - } - - /** - * Returns an array of group names. - * - * @param null|string|string[] $groups The groups to resolve. If a single string is - * passed, it is converted to an array. If null - * is passed, an array containing the current - * group of the context is returned. - * - * @return array An array of validation groups. - */ - private function resolveGroups($groups) - { - return $groups ? (array) $groups : (array) $this->group; - } -} diff --git a/src/Symfony/Component/Validator/ExecutionContextInterface.php b/src/Symfony/Component/Validator/ExecutionContextInterface.php deleted file mode 100644 index b07e928e2c17f..0000000000000 --- a/src/Symfony/Component/Validator/ExecutionContextInterface.php +++ /dev/null @@ -1,319 +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; - -/** - * Stores the validator's state during validation. - * - * For example, let's validate the following object graph: - * - *
- * (Person)---($firstName: string)
- *      \
- *   ($address: Address)---($street: string)
- * 
- * - * We validate the Person instance, which becomes the "root" of the - * validation run (see {@link getRoot}). The state of the context after the - * first step will be like this: - * - *
- * (Person)---($firstName: string)
- *    ^ \
- *   ($address: Address)---($street: string)
- * 
- * - * The validator is stopped at the Person node, both the root and the - * value (see {@link getValue}) of the context point to the Person - * instance. The property path is empty at this point (see {@link getPropertyPath}). - * The metadata of the context is the metadata of the Person node - * (see {@link getMetadata}). - * - * After advancing to the property $firstName of the Person - * instance, the state of the context looks like this: - * - *
- * (Person)---($firstName: string)
- *      \              ^
- *   ($address: Address)---($street: string)
- * 
- * - * The validator is stopped at the property $firstName. The root still - * points to the Person instance, because this is where the validation - * started. The property path is now "firstName" and the current value is the - * value of that property. - * - * After advancing to the $address property and then to the - * $street property of the Address instance, the context state - * looks like this: - * - *
- * (Person)---($firstName: string)
- *      \
- *   ($address: Address)---($street: string)
- *                               ^
- * 
- * - * The validator is stopped at the property $street. The root still - * points to the Person instance, but the property path is now - * "address.street" and the validated value is the value of that property. - * - * Apart from the root, the property path and the currently validated value, - * the execution context also knows the metadata of the current node (see - * {@link getMetadata}) which for example returns a {@link Mapping\PropertyMetadata} - * or a {@link Mapping\ClassMetadata} object. he context also contains the - * validation group that is currently being validated (see {@link getGroup}) and - * the violations that happened up until now (see {@link getViolations}). - * - * Apart from reading the execution context, you can also use - * {@link addViolation} or {@link addViolationAt} to add new violations and - * {@link validate} or {@link validateValue} to validate values that the - * validator otherwise would not reach. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContextInterface} instead. - */ -interface ExecutionContextInterface -{ - /** - * Adds a violation at the current node of the validation graph. - * - * Note: the parameters $invalidValue, $plural and $code are deprecated since version 2.5 and will be removed in 3.0. - * - * @param string $message The error message - * @param array $params The parameters substituted in the error message - * @param mixed $invalidValue The invalid, validated value - * @param int|null $plural The number to use to pluralize of the message - * @param int|null $code The violation code - */ - public function addViolation($message, array $params = array(), $invalidValue = null, $plural = null, $code = null); - - /** - * Adds a violation at the validation graph node with the given property - * path relative to the current property path. - * - * @param string $subPath The relative property path for the violation - * @param string $message The error message - * @param array $parameters The parameters substituted in the error message - * @param mixed $invalidValue The invalid, validated value - * @param int|null $plural The number to use to pluralize of the message - * @param int|null $code The violation code - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContextInterface::buildViolation()} - * instead. - */ - public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null); - - /** - * Validates the given value within the scope of the current validation. - * - * The value may be any value recognized by the used metadata factory - * (see {@link MetadataFactoryInterface::getMetadata}), or an array or a - * traversable object of such values. - * - * Usually you validate a value that is not the current node of the - * execution context. For this case, you can pass the {@link $subPath} - * argument which is appended to the current property path when a violation - * is created. For example, take the following object graph: - * - *
-     * (Person)---($address: Address)---($phoneNumber: PhoneNumber)
-     *                     ^
-     * 
- * - * When the execution context stops at the Person instance, the - * property path is "address". When you validate the PhoneNumber - * instance now, pass "phoneNumber" as sub path to correct the property path - * to "address.phoneNumber": - * - *
-     * $context->validate($address->phoneNumber, 'phoneNumber');
-     * 
- * - * Any violations generated during the validation will be added to the - * violation list that you can access with {@link getViolations}. - * - * @param mixed $value The value to validate. - * @param string $subPath The path to append to the context's property path. - * @param null|string|string[] $groups The groups to validate in. If you don't pass any - * groups here, the current group of the context - * will be used. - * @param bool $traverse Whether to traverse the value if it is an array - * or an instance of \Traversable. - * @param bool $deep Whether to traverse the value recursively if - * it is a collection of collections. - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContextInterface::getValidator()} - * instead. - */ - public function validate($value, $subPath = '', $groups = null, $traverse = false, $deep = false); - - /** - * Validates a value against a constraint. - * - * Use the parameter $subPath to adapt the property path for the - * validated value. For example, take the following object graph: - * - *
-     * (Person)---($address: Address)---($street: string)
-     *                     ^
-     * 
- * - * When the validator validates the Address instance, the - * property path stored in the execution context is "address". When you - * manually validate the property $street now, pass the sub path - * "street" to adapt the full property path to "address.street": - * - *
-     * $context->validate($address->street, new NotNull(), 'street');
-     * 
- * - * @param mixed $value The value to validate. - * @param Constraint|Constraint[] $constraints The constraint(s) to validate against. - * @param string $subPath The path to append to the context's property path. - * @param null|string|string[] $groups The groups to validate in. If you don't pass any - * groups here, the current group of the context - * will be used. - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContextInterface::getValidator()} - * instead. - */ - public function validateValue($value, $constraints, $subPath = '', $groups = null); - - /** - * Returns the violations generated by the validator so far. - * - * @return ConstraintViolationListInterface The constraint violation list. - */ - public function getViolations(); - - /** - * Returns the value at which validation was started in the object graph. - * - * The validator, when given an object, traverses the properties and - * related objects and their properties. The root of the validation is the - * object from which the traversal started. - * - * The current value is returned by {@link getValue}. - * - * @return mixed The root value of the validation. - */ - public function getRoot(); - - /** - * Returns the value that the validator is currently validating. - * - * If you want to retrieve the object that was originally passed to the - * validator, use {@link getRoot}. - * - * @return mixed The currently validated value. - */ - public function getValue(); - - /** - * Returns the metadata for the currently validated value. - * - * With the core implementation, this method returns a - * {@link Mapping\ClassMetadata} instance if the current value is an object, - * a {@link Mapping\PropertyMetadata} instance if the current value is - * the value of a property and a {@link Mapping\GetterMetadata} instance if - * the validated value is the result of a getter method. - * - * If the validated value is neither of these, for example if the validator - * has been called with a plain value and constraint, this method returns - * null. - * - * @return MetadataInterface|null The metadata of the currently validated - * value. - */ - public function getMetadata(); - - /** - * Returns the used metadata factory. - * - * @return MetadataFactoryInterface The metadata factory. - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContextInterface::getValidator()} - * instead and call - * {@link Validator\ValidatorInterface::getMetadataFor()} or - * {@link Validator\ValidatorInterface::hasMetadataFor()} there. - */ - public function getMetadataFactory(); - - /** - * Returns the validation group that is currently being validated. - * - * @return string The current validation group. - */ - public function getGroup(); - - /** - * Returns the class name of the current node. - * - * If the metadata of the current node does not implement - * {@link ClassBasedInterface} or if no metadata is available for the - * current node, this method returns null. - * - * @return string|null The class name or null, if no class name could be found. - */ - public function getClassName(); - - /** - * Returns the property name of the current node. - * - * If the metadata of the current node does not implement - * {@link PropertyMetadataInterface} or if no metadata is available for the - * current node, this method returns null. - * - * @return string|null The property name or null, if no property name could be found. - */ - public function getPropertyName(); - - /** - * Returns the property path to the value that the validator is currently - * validating. - * - * For example, take the following object graph: - * - *
-     * (Person)---($address: Address)---($street: string)
-     * 
- * - * When the Person instance is passed to the validator, the - * property path is initially empty. When the $address property - * of that person is validated, the property path is "address". When - * the $street property of the related Address instance - * is validated, the property path is "address.street". - * - * Properties of objects are prefixed with a dot in the property path. - * Indices of arrays or objects implementing the {@link \ArrayAccess} - * interface are enclosed in brackets. For example, if the property in - * the previous example is $addresses and contains an array - * of Address instance, the property path generated for the - * $street property of one of these addresses is for example - * "addresses[0].street". - * - * @param string $subPath Optional. The suffix appended to the current - * property path. - * - * @return string The current property path. The result may be an empty - * string if the validator is currently validating the - * root value of the validation graph. - */ - public function getPropertyPath($subPath = ''); -} diff --git a/src/Symfony/Component/Validator/GlobalExecutionContextInterface.php b/src/Symfony/Component/Validator/GlobalExecutionContextInterface.php deleted file mode 100644 index 5c646f294baee..0000000000000 --- a/src/Symfony/Component/Validator/GlobalExecutionContextInterface.php +++ /dev/null @@ -1,71 +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; - -/** - * Stores the node-independent state of a validation run. - * - * When the validator validates a graph of objects, it uses two classes to - * store the state during the validation: - * - *
    - *
  • For each node in the validation graph (objects, properties, getters) the - * validator creates an instance of {@link ExecutionContextInterface} that - * stores the information about that node.
  • - *
  • One single GlobalExecutionContextInterface stores the state - * that is independent of the current node.
  • - *
- * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Context\ExecutionContextInterface} instead. - */ -interface GlobalExecutionContextInterface -{ - /** - * Returns the violations generated by the validator so far. - * - * @return ConstraintViolationListInterface A list of constraint violations. - */ - public function getViolations(); - - /** - * Returns the value at which validation was started in the object graph. - * - * @return mixed The root value. - * - * @see ExecutionContextInterface::getRoot() - */ - public function getRoot(); - - /** - * Returns the visitor instance used to validate the object graph nodes. - * - * @return ValidationVisitorInterface The validation visitor. - */ - public function getVisitor(); - - /** - * Returns the factory for constraint validators. - * - * @return ConstraintValidatorFactoryInterface The constraint validator factory. - */ - public function getValidatorFactory(); - - /** - * Returns the factory for validation metadata objects. - * - * @return MetadataFactoryInterface The metadata factory. - */ - public function getMetadataFactory(); -} diff --git a/src/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php deleted file mode 100644 index 01b80138d590e..0000000000000 --- a/src/Symfony/Component/Validator/Mapping/BlackholeMetadataFactory.php +++ /dev/null @@ -1,28 +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\Mapping; - -@trigger_error('The '.__NAMESPACE__.'\BlackholeMetadataFactory class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\Validator\Mapping\Factory\BlackHoleMetadataFactory class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Validator\Mapping\Factory\BlackHoleMetadataFactory as MappingBlackHoleMetadataFactory; - -/** - * Alias of {@link Factory\BlackHoleMetadataFactory}. - * - * @author Fabien Potencier - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Factory\BlackHoleMetadataFactory} instead. - */ -class BlackholeMetadataFactory extends MappingBlackHoleMetadataFactory -{ -} diff --git a/src/Symfony/Component/Validator/Mapping/Cache/ApcCache.php b/src/Symfony/Component/Validator/Mapping/Cache/ApcCache.php deleted file mode 100644 index 63fc8ac05a405..0000000000000 --- a/src/Symfony/Component/Validator/Mapping/Cache/ApcCache.php +++ /dev/null @@ -1,57 +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\Mapping\Cache; - -@trigger_error('The '.__NAMESPACE__.'\ApcCache class is deprecated since version 2.5 and will be removed in 3.0. Use DoctrineCache with the Doctrine\Common\Cache\ApcCache class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Validator\Mapping\ClassMetadata; - -/** - * @deprecated since version 2.5, to be removed in 3.0. - * Use DoctrineCache with \Doctrine\Common\Cache\ApcCache instead. - */ -class ApcCache implements CacheInterface -{ - private $prefix; - - public function __construct($prefix) - { - if (!extension_loaded('apc')) { - throw new \RuntimeException('Unable to use ApcCache to cache validator mappings as APC is not enabled.'); - } - - $this->prefix = $prefix; - } - - public function has($class) - { - if (!function_exists('apc_exists')) { - $exists = false; - - apc_fetch($this->prefix.$class, $exists); - - return $exists; - } - - return apc_exists($this->prefix.$class); - } - - public function read($class) - { - return apc_fetch($this->prefix.$class); - } - - public function write(ClassMetadata $metadata) - { - apc_store($this->prefix.$metadata->getClassName(), $metadata); - } -} diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 3f4f51b83b41c..d38dd322b3a4b 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -17,7 +17,6 @@ use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\GroupDefinitionException; -use Symfony\Component\Validator\ValidationVisitorInterface; /** * Default implementation of {@link ClassMetadataInterface}. @@ -27,7 +26,7 @@ * @author Bernhard Schussek * @author Fabien Potencier */ -class ClassMetadata extends ElementMetadata implements ClassMetadataInterface +class ClassMetadata extends GenericMetadata implements ClassMetadataInterface { /** * @var string @@ -126,47 +125,6 @@ public function __construct($class) } } - /** - * {@inheritdoc} - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - if (null === $propagatedGroup && Constraint::DEFAULT_GROUP === $group - && ($this->hasGroupSequence() || $this->isGroupSequenceProvider())) { - if ($this->hasGroupSequence()) { - $groups = $this->getGroupSequence()->groups; - } else { - $groups = $value->getGroupSequence(); - } - - foreach ($groups as $group) { - $this->accept($visitor, $value, $group, $propertyPath, Constraint::DEFAULT_GROUP); - - if (count($visitor->getViolations()) > 0) { - break; - } - } - - return; - } - - $visitor->visit($this, $value, $group, $propertyPath); - - if (null !== $value) { - $pathPrefix = empty($propertyPath) ? '' : $propertyPath.'.'; - - foreach ($this->getConstrainedProperties() as $property) { - foreach ($this->getPropertyMetadata($property) as $member) { - $member->accept($visitor, $member->getPropertyValue($value), $group, $pathPrefix.$property, $propagatedGroup); - } - } - } - } - /** * {@inheritdoc} */ @@ -368,52 +326,6 @@ public function mergeConstraints(ClassMetadata $source) } } - /** - * Adds a member metadata. - * - * @param MemberMetadata $metadata - * - * @deprecated since version 2.6, to be removed in 3.0. - */ - protected function addMemberMetadata(MemberMetadata $metadata) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the addPropertyMetadata() method instead.', E_USER_DEPRECATED); - - $this->addPropertyMetadata($metadata); - } - - /** - * Returns true if metadatas of members is present for the given property. - * - * @param string $property The name of the property - * - * @return bool - * - * @deprecated since version 2.6, to be removed in 3.0. Use {@link hasPropertyMetadata} instead. - */ - public function hasMemberMetadatas($property) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the hasPropertyMetadata() method instead.', E_USER_DEPRECATED); - - return $this->hasPropertyMetadata($property); - } - - /** - * Returns all metadatas of members describing the given property. - * - * @param string $property The name of the property - * - * @return MemberMetadata[] An array of MemberMetadata - * - * @deprecated since version 2.6, to be removed in 3.0. Use {@link getPropertyMetadata} instead. - */ - public function getMemberMetadatas($property) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the getPropertyMetadata() method instead.', E_USER_DEPRECATED); - - return $this->getPropertyMetadata($property); - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php deleted file mode 100644 index 4069b3fbcad0e..0000000000000 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php +++ /dev/null @@ -1,28 +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\Mapping; - -@trigger_error('The '.__NAMESPACE__.'\ClassMetadataFactory class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; - -/** - * Alias of {@link LazyLoadingMetadataFactory}. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link LazyLoadingMetadataFactory} instead. - */ -class ClassMetadataFactory extends LazyLoadingMetadataFactory -{ -} diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php b/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php index 577440d61d8c7..0a3f2b13402db 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadataInterface.php @@ -11,9 +11,6 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\ClassBasedInterface; -use Symfony\Component\Validator\PropertyMetadataContainerInterface as LegacyPropertyMetadataContainerInterface; - /** * Stores all metadata needed for validating objects of specific class. * @@ -33,7 +30,7 @@ * @see \Symfony\Component\Validator\GroupSequenceProviderInterface * @see TraversalStrategy */ -interface ClassMetadataInterface extends MetadataInterface, LegacyPropertyMetadataContainerInterface, ClassBasedInterface +interface ClassMetadataInterface extends MetadataInterface { /** * Returns the names of all constrained properties. @@ -78,4 +75,33 @@ public function getGroupSequence(); * @see \Symfony\Component\Validator\GroupSequenceProviderInterface */ public function isGroupSequenceProvider(); + + /** + * Check if there's any metadata attached to the given named property. + * + * @param string $property The property name. + * + * @return bool + */ + public function hasPropertyMetadata($property); + + /** + * Returns all metadata instances for the given named property. + * + * If your implementation does not support properties, simply throw an + * exception in this method (for example a BadMethodCallException). + * + * @param string $property The property name. + * + * @return PropertyMetadataInterface[] A list of metadata instances. Empty if + * no metadata exists for the property. + */ + public function getPropertyMetadata($property); + + /** + * Returns the name of the backing PHP class. + * + * @return string The name of the backing class. + */ + public function getClassName(); } diff --git a/src/Symfony/Component/Validator/Mapping/ElementMetadata.php b/src/Symfony/Component/Validator/Mapping/ElementMetadata.php deleted file mode 100644 index 69fe8bfa73729..0000000000000 --- a/src/Symfony/Component/Validator/Mapping/ElementMetadata.php +++ /dev/null @@ -1,30 +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\Mapping; - -/** - * Contains the metadata of a structural element. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Extend {@link GenericMetadata} instead. - */ -abstract class ElementMetadata extends GenericMetadata -{ - public function __construct() - { - if (!$this instanceof MemberMetadata && !$this instanceof ClassMetadata) { - @trigger_error('The '.__CLASS__.' class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\Validator\Mapping\GenericMetadata class instead.', E_USER_DEPRECATED); - } - } -} diff --git a/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php b/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php index 6e55e771dd1aa..c3fbb69a0efe5 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/MetadataFactoryInterface.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Validator\Mapping\Factory; -use Symfony\Component\Validator\MetadataFactoryInterface as LegacyMetadataFactoryInterface; +use Symfony\Component\Validator\Exception; /** * Returns {@link \Symfony\Component\Validator\Mapping\MetadataInterface} instances for values. @@ -20,6 +20,25 @@ * * @author Bernhard Schussek */ -interface MetadataFactoryInterface extends LegacyMetadataFactoryInterface +interface MetadataFactoryInterface { + /** + * Returns the metadata for the given value. + * + * @param mixed $value Some value + * + * @return MetadataInterface The metadata for the value + * + * @throws Exception\NoSuchMetadataException If no metadata exists for the given value + */ + public function getMetadataFor($value); + + /** + * Returns whether the class is able to return metadata for the given value. + * + * @param mixed $value Some value + * + * @return bool Whether metadata can be returned for that value + */ + public function hasMetadataFor($value); } diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index 3459074fcabf7..32df7d159efb7 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -112,13 +112,10 @@ public function __clone() * * If the constraint {@link Valid} is added, the cascading strategy will be * changed to {@link CascadingStrategy::CASCADE}. Depending on the - * properties $traverse and $deep of that constraint, the traversal strategy + * $traverse property of that constraint, the traversal strategy * will be set to one of the following: * - * - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled and $deep - * is enabled - * - {@link TraversalStrategy::IMPLICIT} | {@link TraversalStrategy::STOP_RECURSION} - * if $traverse is enabled, but $deep is disabled + * - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled * - {@link TraversalStrategy::NONE} if $traverse is disabled * * @param Constraint $constraint The constraint to add @@ -144,10 +141,6 @@ public function addConstraint(Constraint $constraint) if ($constraint->traverse) { // Traverse unless the value is not traversable $this->traversalStrategy = TraversalStrategy::IMPLICIT; - - if (!$constraint->deep) { - $this->traversalStrategy |= TraversalStrategy::STOP_RECURSION; - } } else { $this->traversalStrategy = TraversalStrategy::NONE; } @@ -225,21 +218,4 @@ public function getTraversalStrategy() { return $this->traversalStrategy; } - - /** - * Exists for compatibility with the deprecated - * {@link Symfony\Component\Validator\MetadataInterface}. - * - * Should not be used. - * - * Implemented for backward compatibility with Symfony < 2.5. - * - * @throws BadMethodCallException - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath) - { - throw new BadMethodCallException('Not supported.'); - } } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php index d1b8c35b36891..b95ef164a346b 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php @@ -74,7 +74,6 @@ public function loadClassMetadata(ClassMetadata $metadata) foreach ($this->reader->getMethodAnnotations($method) as $constraint) { if ($constraint instanceof Callback) { $constraint->callback = $method->getName(); - $constraint->methods = null; $metadata->addConstraint($constraint); } elseif ($constraint instanceof Constraint) { diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index 0def248431f2d..084db389284da 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -27,7 +27,7 @@ * * @see PropertyMetadataInterface */ -abstract class MemberMetadata extends ElementMetadata implements PropertyMetadataInterface +abstract class MemberMetadata extends GenericMetadata implements PropertyMetadataInterface { /** * @var string @@ -75,22 +75,6 @@ public function __construct($class, $name, $property) $this->property = $property; } - /** - * {@inheritdoc} - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - - $visitor->visit($this, $value, $group, $propertyPath); - - if ($this->isCascaded()) { - $visitor->validate($value, $propagatedGroup ?: $group, $propertyPath, $this->isCollectionCascaded(), $this->isCollectionCascadedDeeply()); - } - } - /** * {@inheritdoc} */ @@ -182,53 +166,6 @@ public function isPrivate($objectOrClassName) return $this->getReflectionMember($objectOrClassName)->isPrivate(); } - /** - * Returns whether objects stored in this member should be validated. - * - * @return bool - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link getCascadingStrategy()} instead. - */ - public function isCascaded() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the getCascadingStrategy() method instead.', E_USER_DEPRECATED); - - return (bool) ($this->cascadingStrategy & CascadingStrategy::CASCADE); - } - - /** - * Returns whether arrays or traversable objects stored in this member - * should be traversed and validated in each entry. - * - * @return bool - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link getTraversalStrategy()} instead. - */ - public function isCollectionCascaded() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the getTraversalStrategy() method instead.', E_USER_DEPRECATED); - - return (bool) ($this->traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE)); - } - - /** - * Returns whether arrays or traversable objects stored in this member - * should be traversed recursively for inner arrays/traversable objects. - * - * @return bool - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link getTraversalStrategy()} instead. - */ - public function isCollectionCascadedDeeply() - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. Use the getTraversalStrategy() method instead.', E_USER_DEPRECATED); - - return !($this->traversalStrategy & TraversalStrategy::STOP_RECURSION); - } - /** * Returns the reflection instance for accessing the member's value. * diff --git a/src/Symfony/Component/Validator/Mapping/MetadataInterface.php b/src/Symfony/Component/Validator/Mapping/MetadataInterface.php index e5f09e17edc82..70173c434076f 100644 --- a/src/Symfony/Component/Validator/Mapping/MetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/MetadataInterface.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Validator\Mapping; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\MetadataInterface as LegacyMetadataInterface; +use Symfony\Component\Validator\ValidationVisitorInterface; /** * A container for validation metadata. @@ -31,7 +31,7 @@ * @see CascadingStrategy * @see TraversalStrategy */ -interface MetadataInterface extends LegacyMetadataInterface +interface MetadataInterface { /** * Returns the strategy for cascading objects. @@ -57,4 +57,13 @@ public function getTraversalStrategy(); * @return Constraint[] A list of Constraint instances */ public function getConstraints(); + + /** + * Returns all constraints for a given validation group. + * + * @param string $group The validation group + * + * @return Constraint[] A list of constraint instances + */ + public function findConstraints($group); } diff --git a/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php b/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php index 8a77aa83faba5..d5983e239d32d 100644 --- a/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php +++ b/src/Symfony/Component/Validator/Mapping/PropertyMetadataInterface.php @@ -11,9 +11,6 @@ namespace Symfony\Component\Validator\Mapping; -use Symfony\Component\Validator\ClassBasedInterface; -use Symfony\Component\Validator\PropertyMetadataInterface as LegacyPropertyMetadataInterface; - /** * Stores all metadata needed for validating the value of a class property. * @@ -32,6 +29,21 @@ * @see CascadingStrategy * @see TraversalStrategy */ -interface PropertyMetadataInterface extends MetadataInterface, LegacyPropertyMetadataInterface, ClassBasedInterface +interface PropertyMetadataInterface extends MetadataInterface { + /** + * Returns the name of the property. + * + * @return string The property name. + */ + public function getPropertyName(); + + /** + * Extracts the value of the property from the given container. + * + * @param mixed $containingValue The container to extract the property value from. + * + * @return mixed The value of the property. + */ + public function getPropertyValue($containingValue); } diff --git a/src/Symfony/Component/Validator/MetadataFactoryInterface.php b/src/Symfony/Component/Validator/MetadataFactoryInterface.php deleted file mode 100644 index 555bea9aa21e5..0000000000000 --- a/src/Symfony/Component/Validator/MetadataFactoryInterface.php +++ /dev/null @@ -1,43 +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; - -/** - * Returns {@link MetadataInterface} instances for values. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Mapping\Factory\MetadataFactoryInterface} instead. - */ -interface MetadataFactoryInterface -{ - /** - * Returns the metadata for the given value. - * - * @param mixed $value Some value - * - * @return MetadataInterface The metadata for the value - * - * @throws Exception\NoSuchMetadataException If no metadata exists for the given value - */ - public function getMetadataFor($value); - - /** - * Returns whether the class is able to return metadata for the given value. - * - * @param mixed $value Some value - * - * @return bool Whether metadata can be returned for that value - */ - public function hasMetadataFor($value); -} diff --git a/src/Symfony/Component/Validator/MetadataInterface.php b/src/Symfony/Component/Validator/MetadataInterface.php deleted file mode 100644 index 2c8944903c6bf..0000000000000 --- a/src/Symfony/Component/Validator/MetadataInterface.php +++ /dev/null @@ -1,73 +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; - -/** - * A container for validation metadata. - * - * The container contains constraints that may belong to different validation - * groups. Constraints for a specific group can be fetched by calling - * {@link findConstraints}. - * - * Implement this interface to add validation metadata to your own metadata - * layer. Each metadata may have named properties. Each property can be - * represented by one or more {@link PropertyMetadataInterface} instances that - * are returned by {@link getPropertyMetadata}. Since - * PropertyMetadataInterface inherits from MetadataInterface, - * each property may be divided into further properties. - * - * The {@link accept} method of each metadata implements the Visitor pattern. - * The method should forward the call to the visitor's - * {@link ValidationVisitorInterface::visit} method and additionally call - * accept() on all structurally related metadata instances. - * - * For example, to store constraints for PHP classes and their properties, - * create a class ClassMetadata (implementing MetadataInterface) - * and a class PropertyMetadata (implementing PropertyMetadataInterface). - * ClassMetadata::getPropertyMetadata($property) returns all - * PropertyMetadata instances for a property of that class. Its - * accept()-method simply forwards to ValidationVisitorInterface::visit() - * and calls accept() on all contained PropertyMetadata - * instances, which themselves call ValidationVisitorInterface::visit() - * again. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Mapping\MetadataInterface} instead. - */ -interface MetadataInterface -{ - /** - * Implementation of the Visitor design pattern. - * - * Calls {@link ValidationVisitorInterface::visit} and then forwards the - * accept()-call to all property metadata instances. - * - * @param ValidationVisitorInterface $visitor The visitor implementing the validation logic - * @param mixed $value The value to validate - * @param string|string[] $group The validation group to validate in - * @param string $propertyPath The current property path in the validation graph - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath); - - /** - * Returns all constraints for a given validation group. - * - * @param string $group The validation group - * - * @return Constraint[] A list of constraint instances - */ - public function findConstraints($group); -} diff --git a/src/Symfony/Component/Validator/PropertyMetadataContainerInterface.php b/src/Symfony/Component/Validator/PropertyMetadataContainerInterface.php deleted file mode 100644 index 5441be1c3d063..0000000000000 --- a/src/Symfony/Component/Validator/PropertyMetadataContainerInterface.php +++ /dev/null @@ -1,45 +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; - -/** - * A container for {@link PropertyMetadataInterface} instances. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Mapping\ClassMetadataInterface} instead. - */ -interface PropertyMetadataContainerInterface -{ - /** - * Check if there's any metadata attached to the given named property. - * - * @param string $property The property name. - * - * @return bool - */ - public function hasPropertyMetadata($property); - - /** - * Returns all metadata instances for the given named property. - * - * If your implementation does not support properties, simply throw an - * exception in this method (for example a BadMethodCallException). - * - * @param string $property The property name. - * - * @return PropertyMetadataInterface[] A list of metadata instances. Empty if - * no metadata exists for the property. - */ - public function getPropertyMetadata($property); -} diff --git a/src/Symfony/Component/Validator/PropertyMetadataInterface.php b/src/Symfony/Component/Validator/PropertyMetadataInterface.php deleted file mode 100644 index 46e7c692c85ca..0000000000000 --- a/src/Symfony/Component/Validator/PropertyMetadataInterface.php +++ /dev/null @@ -1,46 +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; - -/** - * A container for validation metadata of a property. - * - * What exactly you define as "property" is up to you. The validator expects - * implementations of {@link MetadataInterface} that contain constraints and - * optionally a list of named properties that also have constraints (and may - * have further sub properties). Such properties are mapped by implementations - * of this interface. - * - * @author Bernhard Schussek - * - * @see MetadataInterface - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Mapping\PropertyMetadataInterface} instead. - */ -interface PropertyMetadataInterface extends MetadataInterface -{ - /** - * Returns the name of the property. - * - * @return string The property name. - */ - public function getPropertyName(); - - /** - * Extracts the value of the property from the given container. - * - * @param mixed $containingValue The container to extract the property value from. - * - * @return mixed The value of the property. - */ - public function getPropertyValue($containingValue); -} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php index 5a5fa51a0af48..9642eec97b4f6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -17,8 +17,6 @@ use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\Context\ExecutionContext; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Context\LegacyExecutionContext; -use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\PropertyMetadata; use Symfony\Component\Validator\Validation; @@ -100,27 +98,7 @@ protected function createContext() $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); - switch ($this->getApiVersion()) { - case Validation::API_VERSION_2_5: - $context = new ExecutionContext( - $validator, - $this->root, - $translator - ); - break; - case Validation::API_VERSION_2_4: - case Validation::API_VERSION_2_5_BC: - $context = new LegacyExecutionContext( - $validator, - $this->root, - $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'), - $translator - ); - break; - default: - throw new \RuntimeException('Invalid API version'); - } - + $context = new ExecutionContext($validator, $this->root, $translator); $context->setGroup($this->group); $context->setNode($this->value, $this->object, $this->metadata, $this->propertyPath); $context->setConstraint($this->constraint); @@ -133,33 +111,6 @@ protected function createContext() return $context; } - /** - * @param mixed $message - * @param array $parameters - * @param string $propertyPath - * @param string $invalidValue - * @param null $plural - * @param null $code - * - * @return ConstraintViolation - * - * @deprecated to be removed in Symfony 3.0. Use {@link buildViolation()} instead. - */ - protected function createViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null) - { - return new ConstraintViolation( - null, - $message, - $parameters, - $this->root, - $propertyPath, - $invalidValue, - $plural, - $code, - $this->constraint - ); - } - protected function setGroup($group) { $this->group = $group; @@ -243,51 +194,6 @@ protected function assertNoViolation() $this->assertSame(0, $violationsCount = count($this->context->getViolations()), sprintf('0 violation expected. Got %u.', $violationsCount)); } - /** - * @param mixed $message - * @param array $parameters - * @param string $propertyPath - * @param string $invalidValue - * @param null $plural - * @param null $code - * - * @deprecated To be removed in Symfony 3.0. Use - * {@link buildViolation()} instead. - */ - protected function assertViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the buildViolation() method instead.', E_USER_DEPRECATED); - - $this->buildViolation($message) - ->setParameters($parameters) - ->atPath($propertyPath) - ->setInvalidValue($invalidValue) - ->setCode($code) - ->setPlural($plural) - ->assertRaised(); - } - - /** - * @param array $expected - * - * @deprecated To be removed in Symfony 3.0. Use - * {@link buildViolation()} instead. - */ - protected function assertViolations(array $expected) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the buildViolation() method instead.', E_USER_DEPRECATED); - - $violations = $this->context->getViolations(); - - $this->assertCount(count($expected), $violations); - - $i = 0; - - foreach ($expected as $violation) { - $this->assertEquals($violation, $violations[$i++]); - } - } - /** * @param $message * @@ -298,11 +204,6 @@ protected function buildViolation($message) return new ConstraintViolationAssertion($this->context, $message, $this->constraint); } - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - abstract protected function createValidator(); } @@ -312,7 +213,7 @@ abstract protected function createValidator(); class ConstraintViolationAssertion { /** - * @var LegacyExecutionContextInterface + * @var ExecutionContextInterface */ private $context; @@ -331,7 +232,7 @@ class ConstraintViolationAssertion private $constraint; private $cause; - public function __construct(LegacyExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = array()) + public function __construct(ExecutionContextInterface $context, $message, Constraint $constraint = null, array $assertions = array()) { $this->context = $context; $this->message = $message; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index 57dd6006974b0..5be5c855ae6de 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -19,11 +19,6 @@ class AllValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new AllValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index 17d8bfbc2e80b..4dacb1df85aff 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -17,11 +17,6 @@ class BlankValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new BlankValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php index 385c19ab241a2..9ec1348872a5c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php @@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\CallbackValidator; -use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Validation; class CallbackValidatorTest_Class @@ -46,11 +46,6 @@ public static function validateStatic($object, ExecutionContextInterface $contex class CallbackValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new CallbackValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index 2d623c97846ee..55c3c0e634c00 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -17,11 +17,6 @@ class CardSchemeValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new CardSchemeValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index b515b843584ab..7478c17e2bd40 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -22,11 +22,6 @@ function choice_callback() class ChoiceValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new ChoiceValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index 0376814341fb8..21edf0d420ac5 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -21,11 +21,6 @@ abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new CollectionValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php index 6713166ce461f..cba048bf45482 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php @@ -20,11 +20,6 @@ */ abstract class CountValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new CountValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index c2220bab71e3c..1599f8276fa44 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -18,11 +18,6 @@ class CountryValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new CountryValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index b0ed4f0192e66..9eda2d6175c11 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -18,11 +18,6 @@ class CurrencyValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new CurrencyValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 25d88aa2ab882..990b0f1d0741d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -17,11 +17,6 @@ class DateTimeValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new DateTimeValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index 21f0a2dcc3d60..7e38b518aaa9c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -17,11 +17,6 @@ class DateValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new DateValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 7e7a5cc70f0d3..2f44f8aac6ea7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -17,11 +17,6 @@ class EmailValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new EmailValidator(false); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index 47f1e483fb4b2..1542f8f605337 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -20,11 +20,6 @@ */ class EqualToValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new EqualToValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 62cbdbf02f673..553e9f748f0d7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -19,11 +19,6 @@ class ExpressionValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new ExpressionValidator(PropertyAccess::createPropertyAccessor()); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 686b62b0911b5..c08354a00a6ad 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -22,11 +22,6 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest protected $file; - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new FileValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index 41899b2ef10da..7afae0767b314 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -20,11 +20,6 @@ */ class GreaterThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new GreaterThanOrEqualValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index 080928c2e6d27..8cff7596c3728 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -20,11 +20,6 @@ */ class GreaterThanValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new GreaterThanValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index e9deb11de4943..49070e5c14dec 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -17,11 +17,6 @@ class IbanValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IbanValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index ae07c77bd1232..007ba2e7dff13 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -20,11 +20,6 @@ */ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IdenticalToValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index 4605a06577a8a..a41fd8c6d0192 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -33,11 +33,6 @@ class ImageValidatorTest extends AbstractConstraintValidatorTest protected $imagePortrait; protected $image4By3; - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new ImageValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index 439d45cc050fc..afc2be8757928 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -17,11 +17,6 @@ class IpValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IpValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php index 46cadecaf65af..ea4f7b0abd9d4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsFalseValidatorTest.php @@ -17,11 +17,6 @@ class IsFalseValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IsFalseValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php index 5a5575313b731..25fb16cbe8505 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php @@ -17,11 +17,6 @@ class IsNullValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IsNullValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php index 1c5927da4bf4d..6cf785fdf3574 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsTrueValidatorTest.php @@ -17,11 +17,6 @@ class IsTrueValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IsTrueValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index e73b89d60bab1..6f8cfc6cd43ae 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -20,11 +20,6 @@ */ class IsbnValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IsbnValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php index a6d39944b0ac1..e439ebc077247 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -20,11 +20,6 @@ */ class IssnValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new IssnValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 530627d7cdb0e..b977ad1c78bb2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -18,11 +18,6 @@ class LanguageValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new LanguageValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index 75a3d6ee62845..f61483d147d2c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -17,11 +17,6 @@ class LengthValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new LengthValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index 8b1adef1806c1..b5bebc7032315 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -20,11 +20,6 @@ */ class LessThanOrEqualValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new LessThanOrEqualValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index c3dea687be826..78d35b6b1e2ce 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -20,11 +20,6 @@ */ class LessThanValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new LessThanValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 53b779618a8ad..34d15d0bd6eb2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -17,11 +17,6 @@ class LocaleValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new LocaleValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php index b0e88c3456b08..62460ca5d3b83 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php @@ -17,11 +17,6 @@ class LuhnValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new LuhnValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php index c7c081a63beb0..6b4bd03cbc22f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php @@ -17,11 +17,6 @@ class NotBlankValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new NotBlankValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index 1ee8a54ac35fe..8cf2fe1594ad3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -20,11 +20,6 @@ */ class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new NotEqualToValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 3810a847f4f01..e93ccb36ca1ca 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -20,11 +20,6 @@ */ class NotIdenticalToValidatorTest extends AbstractComparisonValidatorTestCase { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new NotIdenticalToValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php index a244f6382ba60..19a215a186c2c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php @@ -17,11 +17,6 @@ class NotNullValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new NotNullValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index 08ebd1282506f..5d0a0491dcad9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -18,11 +18,6 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new RangeValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 88e69966b59ec..0f2da5f907a4d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -17,11 +17,6 @@ class RegexValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new RegexValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index a6ca1435ed338..69feceee0c439 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -17,11 +17,6 @@ class TimeValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new TimeValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index 51bd992d8f81d..476b516e78187 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -19,11 +19,6 @@ class TypeValidatorTest extends AbstractConstraintValidatorTest { protected static $file; - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new TypeValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index edc4dc8aab07b..201ecff2b1591 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -17,11 +17,6 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new UrlValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php index 0abda39f02942..5cb9343d84344 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UuidValidatorTest.php @@ -20,11 +20,6 @@ */ class UuidValidatorTest extends AbstractConstraintValidatorTest { - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - protected function createValidator() { return new UuidValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php b/src/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php index 0f6a2f4ae3d9f..073efb5d90976 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/CallbackClass.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Validator\Tests\Fixtures; -use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * @author Bernhard Schussek diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php index b3b85c895b016..867b024c27672 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/ConstraintAValidator.php @@ -13,7 +13,7 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; class ConstraintAValidator extends ConstraintValidator { diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php b/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php index 526ecc5f5c635..3088399aedd35 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Validator\Tests\Fixtures; use Symfony\Component\Validator\Constraints as Assert; -use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * @Symfony\Component\Validator\Tests\Fixtures\ConstraintA diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php index e3f0d9a007800..98aa57ce8024b 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Validator\Tests\Fixtures; use Symfony\Component\Validator\Exception\NoSuchMetadataException; -use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\MetadataInterface; class FakeMetadataFactory implements MetadataFactoryInterface diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/LegacyClassMetadata.php b/src/Symfony/Component/Validator/Tests/Fixtures/LegacyClassMetadata.php deleted file mode 100644 index 6a832a109f99e..0000000000000 --- a/src/Symfony/Component/Validator/Tests/Fixtures/LegacyClassMetadata.php +++ /dev/null @@ -1,20 +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\Fixtures; - -use Symfony\Component\Validator\ClassBasedInterface; -use Symfony\Component\Validator\MetadataInterface; -use Symfony\Component\Validator\PropertyMetadataContainerInterface; - -interface LegacyClassMetadata extends MetadataInterface, PropertyMetadataContainerInterface, ClassBasedInterface -{ -} diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php b/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php deleted file mode 100644 index 84c5a80bf2d16..0000000000000 --- a/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php +++ /dev/null @@ -1,70 +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\Fixtures; - -use Symfony\Component\Validator\ConstraintViolationList; -use Symfony\Component\Validator\GlobalExecutionContextInterface; -use Symfony\Component\Validator\ValidationVisitorInterface; - -/** - * @since 2.5.3 - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0 - */ -class StubGlobalExecutionContext implements GlobalExecutionContextInterface -{ - private $violations; - private $root; - private $visitor; - - public function __construct($root = null, ValidationVisitorInterface $visitor = null) - { - $this->violations = new ConstraintViolationList(); - $this->root = $root; - $this->visitor = $visitor; - } - - public function getViolations() - { - return $this->violations; - } - - public function setRoot($root) - { - $this->root = $root; - } - - public function getRoot() - { - return $this->root; - } - - public function setVisitor(ValidationVisitorInterface $visitor) - { - $this->visitor = $visitor; - } - - public function getVisitor() - { - return $this->visitor; - } - - public function getValidatorFactory() - { - } - - public function getMetadataFactory() - { - } -} diff --git a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php similarity index 99% rename from src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php rename to src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php index 099fe3b5a5d55..bcb1f7563eaff 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php @@ -19,7 +19,7 @@ use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\Tests\Fixtures\Entity; use Symfony\Component\Validator\Tests\Fixtures\FailingConstraint; use Symfony\Component\Validator\Tests\Fixtures\FakeClassMetadata; @@ -27,13 +27,9 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; /** - * Verifies that a validator satisfies the API of Symfony 2.5+. - * - * @since 2.5 - * * @author Bernhard Schussek */ -abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest +abstract class AbstractTest extends AbstractValidatorTest { /** * @var ValidatorInterface diff --git a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php index f3a2a64338822..2b3b1e5bc3005 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/AbstractValidatorTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintViolationInterface; -use Symfony\Component\Validator\ExecutionContextInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Tests\Fixtures\Entity; use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; diff --git a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php similarity index 93% rename from src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php rename to src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php index b27e6454bea7a..ab045fc477b21 100644 --- a/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php +++ b/src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php @@ -14,11 +14,11 @@ use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Validator\ConstraintValidatorFactory; use Symfony\Component\Validator\Context\ExecutionContextFactory; -use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\Tests\Fixtures\Entity; use Symfony\Component\Validator\Validator\RecursiveValidator; -class RecursiveValidator2Dot5ApiTest extends Abstract2Dot5ApiTest +class RecursiveValidatorTest extends AbstractTest { protected function createValidator(MetadataFactoryInterface $metadataFactory, array $objectInitializers = array()) { diff --git a/src/Symfony/Component/Validator/Validation.php b/src/Symfony/Component/Validator/Validation.php index 1693f7311add4..de77e838fb6ff 100644 --- a/src/Symfony/Component/Validator/Validation.php +++ b/src/Symfony/Component/Validator/Validation.php @@ -18,24 +18,6 @@ */ final class Validation { - /** - * The Validator API provided by Symfony 2.4 and older. - * - * @deprecated use API_VERSION_2_5_BC instead. - */ - const API_VERSION_2_4 = 1; - - /** - * The Validator API provided by Symfony 2.5 and newer. - */ - const API_VERSION_2_5 = 2; - - /** - * The Validator API provided by Symfony 2.5 and newer with a backwards - * compatibility layer for 2.4 and older. - */ - const API_VERSION_2_5_BC = 3; - /** * Creates a new validator. * diff --git a/src/Symfony/Component/Validator/ValidationVisitor.php b/src/Symfony/Component/Validator/ValidationVisitor.php deleted file mode 100644 index 838646260f36b..0000000000000 --- a/src/Symfony/Component/Validator/ValidationVisitor.php +++ /dev/null @@ -1,212 +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; - -@trigger_error('The '.__NAMESPACE__.'\ValidationVisitor 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\Exception\NoSuchMetadataException; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Default implementation of {@link ValidationVisitorInterface} and - * {@link GlobalExecutionContextInterface}. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -class ValidationVisitor implements ValidationVisitorInterface, GlobalExecutionContextInterface -{ - /** - * @var mixed - */ - private $root; - - /** - * @var MetadataFactoryInterface - */ - private $metadataFactory; - - /** - * @var ConstraintValidatorFactoryInterface - */ - private $validatorFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - /** - * @var array - */ - private $objectInitializers; - - /** - * @var ConstraintViolationList - */ - private $violations; - - /** - * @var array - */ - private $validatedObjects = array(); - - /** - * Creates a new validation visitor. - * - * @param mixed $root The value passed to the validator. - * @param MetadataFactoryInterface $metadataFactory The factory for obtaining metadata instances. - * @param ConstraintValidatorFactoryInterface $validatorFactory The factory for creating constraint validators. - * @param TranslatorInterface $translator The translator for translating violation messages. - * @param string|null $translationDomain The domain of the translation messages. - * @param ObjectInitializerInterface[] $objectInitializers The initializers for preparing objects before validation. - * - * @throws UnexpectedTypeException If any of the object initializers is not an instance of ObjectInitializerInterface - */ - public function __construct($root, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, TranslatorInterface $translator, $translationDomain = null, array $objectInitializers = array()) - { - foreach ($objectInitializers as $initializer) { - if (!$initializer instanceof ObjectInitializerInterface) { - throw new UnexpectedTypeException($initializer, 'Symfony\Component\Validator\ObjectInitializerInterface'); - } - } - - $this->root = $root; - $this->metadataFactory = $metadataFactory; - $this->validatorFactory = $validatorFactory; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - $this->objectInitializers = $objectInitializers; - $this->violations = new ConstraintViolationList(); - } - - /** - * {@inheritdoc} - */ - public function visit(MetadataInterface $metadata, $value, $group, $propertyPath) - { - $context = new ExecutionContext( - $this, - $this->translator, - $this->translationDomain, - $metadata, - $value, - $group, - $propertyPath - ); - - $context->validateValue($value, $metadata->findConstraints($group)); - } - - /** - * {@inheritdoc} - */ - public function validate($value, $group, $propertyPath, $traverse = false, $deep = false) - { - if (null === $value) { - return; - } - - if (is_object($value)) { - $hash = spl_object_hash($value); - - // Exit, if the object is already validated for the current group - if (isset($this->validatedObjects[$hash][$group])) { - return; - } - - // Initialize if the object wasn't initialized before - if (!isset($this->validatedObjects[$hash])) { - foreach ($this->objectInitializers as $initializer) { - if (!$initializer instanceof ObjectInitializerInterface) { - throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.'); - } - $initializer->initialize($value); - } - } - - // Remember validating this object before starting and possibly - // traversing the object graph - $this->validatedObjects[$hash][$group] = true; - } - - // Validate arrays recursively by default, otherwise every driver needs - // to implement special handling for arrays. - // https://github.com/symfony/symfony/issues/6246 - if (is_array($value) || ($traverse && $value instanceof \Traversable)) { - foreach ($value as $key => $element) { - // Ignore any scalar values in the collection - if (is_object($element) || is_array($element)) { - // Only repeat the traversal if $deep is set - $this->validate($element, $group, $propertyPath.'['.$key.']', $deep, $deep); - } - } - - try { - $this->metadataFactory->getMetadataFor($value)->accept($this, $value, $group, $propertyPath); - } catch (NoSuchMetadataException $e) { - // Metadata doesn't necessarily have to exist for - // traversable objects, because we know how to validate - // them anyway. Optionally, additional metadata is supported. - } - } else { - $this->metadataFactory->getMetadataFor($value)->accept($this, $value, $group, $propertyPath); - } - } - - /** - * {@inheritdoc} - */ - public function getViolations() - { - return $this->violations; - } - - /** - * {@inheritdoc} - */ - public function getRoot() - { - return $this->root; - } - - /** - * {@inheritdoc} - */ - public function getVisitor() - { - return $this; - } - - /** - * {@inheritdoc} - */ - public function getValidatorFactory() - { - return $this->validatorFactory; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFactory() - { - return $this->metadataFactory; - } -} diff --git a/src/Symfony/Component/Validator/ValidationVisitorInterface.php b/src/Symfony/Component/Validator/ValidationVisitorInterface.php deleted file mode 100644 index 0ab7b7366776c..0000000000000 --- a/src/Symfony/Component/Validator/ValidationVisitorInterface.php +++ /dev/null @@ -1,82 +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; - -/** - * Validates values against constraints defined in {@link MetadataInterface} - * instances. - * - * This interface is an implementation of the Visitor design pattern. A value - * is validated by first passing it to the {@link validate} method. That method - * will determine the matching {@link MetadataInterface} for validating the - * value. It then calls the {@link MetadataInterface::accept} method of that - * metadata. accept() does two things: - * - *
    - *
  1. It calls {@link visit} to validate the value against the constraints of - * the metadata.
  2. - *
  3. It calls accept() on all nested metadata instances with the - * corresponding values extracted from the current value. For example, if the - * current metadata represents a class and the current value is an object of - * that class, the metadata contains nested instances for each property of that - * class. It forwards the call to these nested metadata with the values of the - * corresponding properties in the original object.
  4. - *
- * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - */ -interface ValidationVisitorInterface -{ - /** - * Validates a value. - * - * If the value is an array or a traversable object, you can set the - * parameter $traverse to true in order to run through - * the collection and validate each element. If these elements can be - * collections again and you want to traverse them recursively, set the - * parameter $deep to true as well. - * - * If you set $traversable to true, the visitor will - * nevertheless try to find metadata for the collection and validate its - * constraints. If no such metadata is found, the visitor ignores that and - * only iterates the collection. - * - * If you don't set $traversable to true and the visitor - * does not find metadata for the given value, it will fail with an - * exception. - * - * @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. - * @param bool $traverse Whether to traverse the value if it is traversable. - * @param bool $deep Whether to traverse nested traversable values recursively. - * - * @throws Exception\NoSuchMetadataException If no metadata can be found for - * the given value. - */ - public function validate($value, $group, $propertyPath, $traverse = false, $deep = false); - - /** - * Validates a value against the constraints defined in some metadata. - * - * This method implements the Visitor design pattern. See also - * {@link ValidationVisitorInterface}. - * - * @param MetadataInterface $metadata The metadata holding the constraints. - * @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. - */ - public function visit(MetadataInterface $metadata, $value, $group, $propertyPath); -} diff --git a/src/Symfony/Component/Validator/Validator.php b/src/Symfony/Component/Validator/Validator.php deleted file mode 100644 index 4da27e7b375a0..0000000000000 --- a/src/Symfony/Component/Validator/Validator.php +++ /dev/null @@ -1,237 +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; - -@trigger_error('The '.__NAMESPACE__.'\Validator class is deprecated since version 2.5 and will be removed in 3.0. Use the Symfony\Component\Validator\Validator\RecursiveValidator class instead.', E_USER_DEPRECATED); - -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Valid; -use Symfony\Component\Validator\Exception\ValidatorException; - -/** - * Default implementation of {@link ValidatorInterface}. - * - * @author Fabien Potencier - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Validator\RecursiveValidator} instead. - */ -class Validator implements ValidatorInterface, Mapping\Factory\MetadataFactoryInterface -{ - /** - * @var MetadataFactoryInterface - */ - private $metadataFactory; - - /** - * @var ConstraintValidatorFactoryInterface - */ - private $validatorFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - /** - * @var array - */ - private $objectInitializers; - - public function __construct( - MetadataFactoryInterface $metadataFactory, - ConstraintValidatorFactoryInterface $validatorFactory, - TranslatorInterface $translator, - $translationDomain = 'validators', - array $objectInitializers = array() - ) { - $this->metadataFactory = $metadataFactory; - $this->validatorFactory = $validatorFactory; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - $this->objectInitializers = $objectInitializers; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFactory() - { - return $this->metadataFactory; - } - - /** - * {@inheritdoc} - */ - public function getMetadataFor($value) - { - return $this->metadataFactory->getMetadataFor($value); - } - - /** - * {@inheritdoc} - */ - public function hasMetadataFor($value) - { - return $this->metadataFactory->hasMetadataFor($value); - } - - /** - * {@inheritdoc} - */ - public function validate($value, $groups = null, $traverse = false, $deep = false) - { - $visitor = $this->createVisitor($value); - - foreach ($this->resolveGroups($groups) as $group) { - $visitor->validate($value, $group, '', $traverse, $deep); - } - - return $visitor->getViolations(); - } - - /** - * {@inheritdoc} - * - * @throws ValidatorException If the metadata for the value does not support properties. - */ - public function validateProperty($containingValue, $property, $groups = null) - { - $visitor = $this->createVisitor($containingValue); - $metadata = $this->metadataFactory->getMetadataFor($containingValue); - - if (!$metadata instanceof PropertyMetadataContainerInterface) { - $valueAsString = is_scalar($containingValue) - ? '"'.$containingValue.'"' - : 'the value of type '.gettype($containingValue); - - throw new ValidatorException(sprintf('The metadata for %s does not support properties.', $valueAsString)); - } - - foreach ($this->resolveGroups($groups) as $group) { - if (!$metadata->hasPropertyMetadata($property)) { - continue; - } - - foreach ($metadata->getPropertyMetadata($property) as $propMeta) { - $propMeta->accept($visitor, $propMeta->getPropertyValue($containingValue), $group, $property); - } - } - - return $visitor->getViolations(); - } - - /** - * {@inheritdoc} - * - * @throws ValidatorException If the metadata for the value does not support properties. - */ - public function validatePropertyValue($containingValue, $property, $value, $groups = null) - { - $visitor = $this->createVisitor(is_object($containingValue) ? $containingValue : $value); - $metadata = $this->metadataFactory->getMetadataFor($containingValue); - - if (!$metadata instanceof PropertyMetadataContainerInterface) { - $valueAsString = is_scalar($containingValue) - ? '"'.$containingValue.'"' - : 'the value of type '.gettype($containingValue); - - throw new ValidatorException(sprintf('The metadata for '.$valueAsString.' does not support properties.')); - } - - // If $containingValue is passed as class name, take $value as root - // and start the traversal with an empty property path - $propertyPath = is_object($containingValue) ? $property : ''; - - foreach ($this->resolveGroups($groups) as $group) { - if (!$metadata->hasPropertyMetadata($property)) { - continue; - } - - foreach ($metadata->getPropertyMetadata($property) as $propMeta) { - $propMeta->accept($visitor, $value, $group, $propertyPath); - } - } - - return $visitor->getViolations(); - } - - /** - * {@inheritdoc} - */ - public function validateValue($value, $constraints, $groups = null) - { - $context = new ExecutionContext($this->createVisitor($value), $this->translator, $this->translationDomain); - - $constraints = is_array($constraints) ? $constraints : array($constraints); - - foreach ($constraints as $constraint) { - if ($constraint instanceof Valid) { - // Why can't the Valid constraint be executed directly? - // - // It cannot be executed like regular other constraints, because regular - // constraints are only executed *if they belong to the validated group*. - // The Valid constraint, on the other hand, is always executed and propagates - // the group to the cascaded object. The propagated group depends on - // - // * Whether a group sequence is currently being executed. Then the default - // group is propagated. - // - // * Otherwise the validated group is propagated. - - throw new ValidatorException( - sprintf( - 'The constraint %s cannot be validated. Use the method validate() instead.', - get_class($constraint) - ) - ); - } - - $context->validateValue($value, $constraint, '', $groups); - } - - return $context->getViolations(); - } - - /** - * @param mixed $root - * - * @return ValidationVisitor - */ - private function createVisitor($root) - { - return new ValidationVisitor( - $root, - $this->metadataFactory, - $this->validatorFactory, - $this->translator, - $this->translationDomain, - $this->objectInitializers - ); - } - - /** - * @param null|string|string[] $groups - * - * @return string[] - */ - private function resolveGroups($groups) - { - return $groups ? (array) $groups : array(Constraint::DEFAULT_GROUP); - } -} diff --git a/src/Symfony/Component/Validator/Validator/LegacyValidator.php b/src/Symfony/Component/Validator/Validator/LegacyValidator.php deleted file mode 100644 index e35f4c91401b3..0000000000000 --- a/src/Symfony/Component/Validator/Validator/LegacyValidator.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\Validator; - -@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+. - * - * @since 2.5 - * - * @author Bernhard Schussek - * - * @see \Symfony\Component\Validator\ValidatorInterface - * @see \Symfony\Component\Validator\Validator\ValidatorInterface - * @deprecated since version 2.5, to be removed in 3.0. - */ -class LegacyValidator extends RecursiveValidator -{ -} diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index e27f6f637fc36..a5dc3e7ee3299 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -26,7 +26,7 @@ use Symfony\Component\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Mapping\PropertyMetadataInterface; use Symfony\Component\Validator\Mapping\TraversalStrategy; -use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\ObjectInitializerInterface; use Symfony\Component\Validator\Util\PropertyPath; diff --git a/src/Symfony/Component/Validator/Validator/RecursiveValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveValidator.php index e4dc0fb057d29..e8c60d7090122 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveValidator.php @@ -17,9 +17,8 @@ use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\ObjectInitializerInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; /** * Recursive implementation of {@link ValidatorInterface}. @@ -28,7 +27,7 @@ * * @author Bernhard Schussek */ -class RecursiveValidator implements ValidatorInterface, LegacyValidatorInterface +class RecursiveValidator implements ValidatorInterface { /** * @var ExecutionContextFactoryInterface @@ -115,21 +114,8 @@ public function hasMetadataFor($object) /** * {@inheritdoc} */ - public function validate($value, $groups = null, $traverse = false, $deep = false) + public function validate($value, $constraints = null, $groups = null) { - $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; - } 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) ->validate($value, $constraints, $groups) ->getViolations(); @@ -156,26 +142,6 @@ public function validatePropertyValue($objectOrClass, $propertyName, $value, $gr ->getViolations(); } - /** - * {@inheritdoc} - */ - 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 $this->validate($value, $constraints, $groups); - } - - /** - * {@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) && (0 === count($constraints) || current($constraints) instanceof Constraint)); diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php index 4a69976ed2b11..d61471349379b 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilder.php +++ b/src/Symfony/Component/Validator/ValidatorBuilder.php @@ -23,6 +23,7 @@ use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; use Symfony\Component\Validator\Mapping\Loader\LoaderChain; use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; @@ -292,41 +293,6 @@ public function setTranslationDomain($translationDomain) return $this; } - /** - * {@inheritdoc} - * - * @deprecated since version 2.5, to be removed in 3.0. - * The validator will function without a property accessor. - */ - public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. The validator will function without a property accessor.', E_USER_DEPRECATED); - - if (null !== $this->validatorFactory) { - throw new ValidatorException('You cannot set a property accessor after setting a custom validator factory. Configure your validator factory instead.'); - } - - $this->propertyAccessor = $propertyAccessor; - - return $this; - } - - /** - * {@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)); - } - - return $this; - } - /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php index e15fb7aa14e67..5c5ff592236a9 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilderInterface.php +++ b/src/Symfony/Component/Validator/ValidatorBuilderInterface.php @@ -15,6 +15,7 @@ use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; /** * A configurable builder for ValidatorInterface objects. @@ -160,30 +161,6 @@ public function setTranslator(TranslatorInterface $translator); */ public function setTranslationDomain($translationDomain); - /** - * Sets the property accessor for resolving property paths. - * - * @param PropertyAccessorInterface $propertyAccessor The property accessor - * - * @return ValidatorBuilderInterface The builder object - * - * @deprecated since version 2.5, to be removed in 3.0. - */ - public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor); - - /** - * Sets the API version that the returned validator should support. - * - * @param int $apiVersion The required API version - * - * @return ValidatorBuilderInterface The builder object - * - * @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); - /** * Builds and returns a new validator object. * diff --git a/src/Symfony/Component/Validator/ValidatorInterface.php b/src/Symfony/Component/Validator/ValidatorInterface.php deleted file mode 100644 index cffc1388d7f6f..0000000000000 --- a/src/Symfony/Component/Validator/ValidatorInterface.php +++ /dev/null @@ -1,103 +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; - -/** - * Validates values and graphs of objects and arrays. - * - * @author Bernhard Schussek - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link \Symfony\Component\Validator\Validator\ValidatorInterface} instead. - */ -interface ValidatorInterface -{ - /** - * Validates a value. - * - * The accepted values depend on the {@link MetadataFactoryInterface} - * implementation. - * - * The signature changed with Symfony 2.5 (see - * {@link Validator\ValidatorInterface::validate()}. This signature will be - * disabled in Symfony 3.0. - * - * @param mixed $value The value to validate - * @param array|null $groups The validation groups to validate. - * @param bool $traverse Whether to traverse the value if it is traversable. - * @param bool $deep Whether to traverse nested traversable values recursively. - * - * @return ConstraintViolationListInterface A list of constraint violations. If the - * list is empty, validation succeeded. - */ - public function validate($value, $groups = null, $traverse = false, $deep = false); - - /** - * Validates a property of a value against its current value. - * - * The accepted values depend on the {@link MetadataFactoryInterface} - * implementation. - * - * @param mixed $containingValue The value containing the property. - * @param string $property The name of the property to validate. - * @param array|null $groups The validation groups to validate. - * - * @return ConstraintViolationListInterface A list of constraint violations. If the - * list is empty, validation succeeded. - */ - public function validateProperty($containingValue, $property, $groups = null); - - /** - * Validate a property of a value against a potential value. - * - * The accepted values depend on the {@link MetadataFactoryInterface} - * implementation. - * - * @param mixed $containingValue The value containing the property. - * @param string $property The name of the property to validate - * @param string $value The value to validate against the - * constraints of the property. - * @param array|null $groups The validation groups to validate. - * - * @return ConstraintViolationListInterface A list of constraint violations. If the - * list is empty, validation succeeded. - */ - public function validatePropertyValue($containingValue, $property, $value, $groups = null); - - /** - * Validates a value against a constraint or a list of constraints. - * - * @param mixed $value The value to validate. - * @param Constraint|Constraint[] $constraints The constraint(s) to validate against. - * @param array|null $groups The validation groups to validate. - * - * @return ConstraintViolationListInterface A list of constraint violations. If the - * list is empty, validation succeeded. - * - * @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); - - /** - * Returns the factory for metadata instances. - * - * @return MetadataFactoryInterface The metadata factory. - * - * @deprecated since version 2.5, to be removed in 3.0. - * Use {@link Validator\ValidatorInterface::getMetadataFor()} or - * {@link Validator\ValidatorInterface::hasMetadataFor()} - * instead. - */ - public function getMetadataFactory(); -} diff --git a/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php b/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php deleted file mode 100644 index 7410b0a6fc2d7..0000000000000 --- a/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php +++ /dev/null @@ -1,166 +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\Violation; - -@trigger_error('The '.__NAMESPACE__.'\LegacyConstraintViolationBuilder class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); - -use Symfony\Component\Validator\ExecutionContextInterface; - -/** - * Backwards-compatible implementation of {@link ConstraintViolationBuilderInterface}. - * - * @author Bernhard Schussek - * - * @internal You should not instantiate or use this class. Code against - * {@link ConstraintViolationBuilderInterface} instead. - * - * @deprecated since version 2.5.5, to be removed in 3.0. - */ -class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInterface -{ - /** - * @var ExecutionContextInterface - */ - private $context; - - /** - * @var string - */ - private $message; - - /** - * @var array - */ - private $parameters; - - /** - * @var mixed - */ - private $invalidValue; - - /** - * @var string - */ - private $propertyPath; - - /** - * @var int|null - */ - private $plural; - - /** - * @var mixed - */ - private $code; - - public function __construct(ExecutionContextInterface $context, $message, array $parameters) - { - $this->context = $context; - $this->message = $message; - $this->parameters = $parameters; - $this->invalidValue = $context->getValue(); - } - - /** - * {@inheritdoc} - */ - public function atPath($path) - { - $this->propertyPath = $path; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setParameter($key, $value) - { - $this->parameters[$key] = $value; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setParameters(array $parameters) - { - $this->parameters = $parameters; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setTranslationDomain($translationDomain) - { - // can't be set in the old API - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setInvalidValue($invalidValue) - { - $this->invalidValue = $invalidValue; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setPlural($number) - { - $this->plural = $number; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setCode($code) - { - $this->code = $code; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setCause($cause) - { - // do nothing - we can't save the cause through the old API - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addViolation() - { - if ($this->propertyPath) { - $this->context->addViolationAt($this->propertyPath, $this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code); - - return; - } - - $this->context->addViolation($this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code); - } -} diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 4ddf0607b378d..2f72e3387afa8 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -25,7 +25,6 @@ "symfony/intl": "~2.8|~3.0", "symfony/yaml": "~2.8|~3.0", "symfony/config": "~2.8|~3.0", - "symfony/property-access": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0", @@ -39,8 +38,7 @@ "symfony/yaml": "", "symfony/config": "", "egulias/email-validator": "Strict (RFC compliant) email validation", - "symfony/property-access": "For using the 2.4 Validator API", - "symfony/expression-language": "For using the 2.4 Expression validator" + "symfony/expression-language": "For using the Expression validator" }, "autoload": { "psr-4": { "Symfony\\Component\\Validator\\": "" }