Skip to content

[3.0] Remove more deprecated interfaces in Form and Validator #16067

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;

use Symfony\Component\Console\Descriptor\DescriptorInterface;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->end()
->scalarNode('translation_domain')->defaultValue('validators')->end()
->booleanNode('strict_email')->defaultFalse()->end()
->enumNode('api')
->info('Deprecated since version 2.7, to be removed in 3.0')
->values(array('2.4', '2.5', '2.5-bc', 'auto'))
->beforeNormalization()
// XML/YAML parse as numbers, not as strings
->ifTrue(function ($v) { return is_scalar($v); })
->then(function ($v) { return (string) $v; })
->end()
->end()
->end()
->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,12 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
*/
const ROUND_HALF_DOWN = \NumberFormatter::ROUND_HALFDOWN;

/**
* @deprecated since version 2.7, will be replaced by a $scale private property in 3.0.
*/
protected $precision;

protected $grouping;

protected $roundingMode;

private $scale;

public function __construct($scale = null, $grouping = false, $roundingMode = self::ROUND_HALF_UP)
{
if (null === $grouping) {
Expand All @@ -91,7 +88,7 @@ public function __construct($scale = null, $grouping = false, $roundingMode = se
$roundingMode = self::ROUND_HALF_UP;
}

$this->precision = $scale;
$this->scale = $scale;
$this->grouping = $grouping;
$this->roundingMode = $roundingMode;
}
Expand Down Expand Up @@ -211,8 +208,8 @@ protected function getNumberFormatter()
{
$formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);

if (null !== $this->precision) {
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision);
if (null !== $this->scale) {
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->scale);
$formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, $this->roundingMode);
}

Expand All @@ -230,9 +227,9 @@ protected function getNumberFormatter()
*/
private function round($number)
{
if (null !== $this->precision && null !== $this->roundingMode) {
if (null !== $this->scale && null !== $this->roundingMode) {
// shift number to maintain the correct scale during rounding
$roundingCoef = pow(10, $this->precision);
$roundingCoef = pow(10, $this->scale);
$number *= $roundingCoef;

switch ($this->roundingMode) {
Expand Down
12 changes: 2 additions & 10 deletions src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,7 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
$pattern = $formatter->getPattern();
$timezone = $formatter->getTimezoneId();

if ($setTimeZone = PHP_VERSION_ID >= 50500 || method_exists($formatter, 'setTimeZone')) {
$formatter->setTimeZone('UTC');
} else {
$formatter->setTimeZoneId('UTC');
}
$formatter->setTimeZone('UTC');

if (preg_match($regex, $pattern, $matches)) {
$formatter->setPattern($matches[0]);
Expand All @@ -301,11 +297,7 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
$formatter->setPattern($pattern);
}

if ($setTimeZone) {
$formatter->setTimeZone($timezone);
} else {
$formatter->setTimeZoneId($timezone);
}
$formatter->setTimeZone($timezone);

return $timestamps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class IntegerType extends AbstractType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class MoneyType extends AbstractType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class NumberType extends AbstractType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class PercentType extends AbstractType
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function configureOptions(OptionsResolver $resolver)
return $options['widget'] !== 'single_text';
};

$placeholder = $placeholderDefault = function (Options $options) {
$placeholderDefault = function (Options $options) {
return $options['required'] ? null : '';
};

Expand Down Expand Up @@ -219,7 +219,7 @@ public function configureOptions(OptionsResolver $resolver)
'with_seconds' => false,
'model_timezone' => null,
'view_timezone' => null,
'placeholder' => $placeholder,
'placeholder' => $placeholderDefault,
'html5' => true,
// Don't modify \DateTime classes by reference, we treat
// them like immutable value objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class DependencyInjectionExtension implements FormExtensionInterface
private $guesser;
private $guesserLoaded = false;

public function __construct(ContainerInterface $container,
array $typeServiceIds, array $typeExtensionServiceIds,
array $guesserServiceIds)
public function __construct(ContainerInterface $container, array $typeServiceIds, array $typeExtensionServiceIds, array $guesserServiceIds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is done, then not only in master

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will let @nicolas-grekas submit a PR for this on 2.3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #16084

{
$this->container = $container;
$this->typeServiceIds = $typeServiceIds;
Expand Down
5 changes: 0 additions & 5 deletions src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Symfony\Component\Form\Util\FormUtil;
use Symfony\Component\Form\Util\InheritDataAwareIterator;
use Symfony\Component\Form\Util\OrderedHashMap;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\PropertyAccess\PropertyPath;

/**
Expand Down Expand Up @@ -506,10 +505,6 @@ public function handleRequest($request = null)
*/
public function submit($submittedData, $clearMissing = true)
{
if ($submittedData instanceof Request) {
@trigger_error('Passing a Symfony\Component\HttpFoundation\Request object to the '.__CLASS__.'::bind and '.__METHOD__.' methods is deprecated since 2.3 and will be removed in 3.0. Use the '.__CLASS__.'::handleRequest method instead. If you want to test whether the form was submitted separately, you can use the '.__CLASS__.'::isSubmitted method.', E_USER_DEPRECATED);
}

if ($this->submitted) {
throw new AlreadySubmittedException('A form can only be submitted once');
}
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Form/FormTypeExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function finishView(FormView $view, FormInterface $form, array $options);
* Configures the options for this type.
*
* @param OptionsResolver $resolver The resolver for the options.
*
*/
public function configureOptions(OptionsResolver $resolver);

Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Form/ResolvedFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

namespace Symfony\Component\Form;

use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\Util\StringUtil;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Expand Down
6 changes: 0 additions & 6 deletions src/Symfony/Component/Templating/Loader/CacheLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public function load(TemplateReferenceInterface $template)
if (is_file($path)) {
if (null !== $this->logger) {
$this->logger->debug('Fetching template from cache.', array('name' => $template->get('name')));
} elseif (null !== $this->debugger) {
// just for BC, to be removed in 3.0
$this->debugger->log(sprintf('Fetching template "%s" from cache.', $template->get('name')));
}

return new FileStorage($path);
Expand All @@ -80,9 +77,6 @@ public function load(TemplateReferenceInterface $template)

if (null !== $this->logger) {
$this->logger->debug('Storing template in cache.', array('name' => $template->get('name')));
} elseif (null !== $this->debugger) {
// just for BC, to be removed in 3.0
$this->debugger->log(sprintf('Storing template "%s" in cache.', $template->get('name')));
}

return new FileStorage($path);
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/Validator/Constraints/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public function __construct($options = null)
}

if (is_array($options) && !isset($options['callback']) && !isset($options['groups'])) {
if (is_callable($options) || !$options) {
$options = array('callback' => $options);
}
$options = array('callback' => $options);
}

parent::__construct($options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\Validator\Context;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
use Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\Mapping\MetadataInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
Expand Down Expand Up @@ -267,7 +267,7 @@ 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,
* {@link Mapping\ClassMetadataInterface} 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.
Expand All @@ -292,7 +292,7 @@ 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
* {@link Mapping\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.
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Component/Validator/Mapping/GenericMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Traverse;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Exception\BadMethodCallException;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\ValidationVisitorInterface;

/**
* A generic container of {@link Constraint} objects.
Expand Down Expand Up @@ -115,7 +113,7 @@ public function __clone()
* $traverse property of that constraint, the traversal strategy
* will be set to one of the following:
*
* - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
* - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
* - {@link TraversalStrategy::NONE} if $traverse is disabled
*
* @param Constraint $constraint The constraint to add
Expand All @@ -139,7 +137,6 @@ public function addConstraint(Constraint $constraint)
$this->cascadingStrategy = CascadingStrategy::CASCADE;

if ($constraint->traverse) {
// Traverse unless the value is not traversable
$this->traversalStrategy = TraversalStrategy::IMPLICIT;
} else {
$this->traversalStrategy = TraversalStrategy::NONE;
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Validator/Mapping/MemberMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\ValidationVisitorInterface;

/**
* Stores all metadata needed for validating a class property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Validator\Mapping;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ValidationVisitorInterface;

/**
* A container for validation metadata.
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Validator/ValidatorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Context\ExecutionContextFactory;
use Symfony\Component\Validator\Exception\InvalidArgumentException;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Validator;

use Doctrine\Common\Annotations\Reader;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/Validator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"symfony/yaml": "",
"symfony/config": "",
"egulias/email-validator": "Strict (RFC compliant) email validation",
"symfony/property-access": "For using the Expression validator",
"symfony/expression-language": "For using the Expression validator"
},
"autoload": {
Expand Down