8000 [3.0] Remove more deprecated interfaces in Form and Validator · symfony/symfony@a743fb6 · GitHub
[go: up one dir, main page]

Skip to content

Commit a743fb6

Browse files
[3.0] Remove more deprecated interfaces in Form and Validator
1 parent 372be7e commit a743fb6

22 files changed

+18
-67
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

1414
use Symfony\Component\Console\Descriptor\DescriptorInterface;
15-
use Symfony\Component\Console\Helper\Table;
1615
use Symfony\Component\Console\Output\OutputInterface;
1716
use Symfony\Component\DependencyInjection\Alias;
1817
use Symfony\Component\DependencyInjection\ContainerBuilder;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,6 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
437437
->end()
438438
->scalarNode('translation_domain')->defaultValue('validators')->end()
439439
->booleanNode('strict_email')->defaultFalse()->end()
440-
->enumNode('api')
441-
->info('Deprecated since version 2.7, to be removed in 3.0')
442-
->values(array('2.4', '2.5', '2.5-bc', 'auto'))
443-
->beforeNormalization()
444-
// XML/YAML parse as numbers, not as strings
445-
->ifTrue(function ($v) { return is_scalar($v); })
446-
->then(function ($v) { return (string) $v; })
447-
F438 ->end()
448-
->end()
449440
->end()
450441
->end()
451442
->end()

src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,12 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
7272
*/
7373
const ROUND_HALF_DOWN = \NumberFormatter::ROUND_HALFDOWN;
7474

75-
/**
76-
* @deprecated since version 2.7, will be replaced by a $scale private property in 3.0.
77-
*/
78-
protected $precision;
79-
8075
protected $grouping;
8176

8277
protected $roundingMode;
8378

79+
private $scale;
80+
8481
public function __construct($scale = null, $grouping = false, $roundingMode = self::ROUND_HALF_UP)
8582
{
8683
if (null === $grouping) {
@@ -91,7 +88,7 @@ public function __construct($scale = null, $grouping = false, $roundingMode = se
9188
$roundingMode = self::ROUND_HALF_UP;
9289
}
9390

94-
$this->precision = $scale;
91+
$this->scale = $scale;
9592
$this->grouping = $grouping;
9693
$this->roundingMode = $roundingMode;
9794
}
@@ -211,8 +208,8 @@ protected function getNumberFormatter()
211208
{
212209
$formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
213210

214-
if (null !== $this->precision) {
215-
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision);
211+
if (null !== $this-&g 10000 t;scale) {
212+
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->scale);
216213
$formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, $this->roundingMode);
217214
}
218215

@@ -230,9 +227,9 @@ protected function getNumberFormatter()
230227
*/
231228
private function round($number)
232229
{
233-
if (null !== $this->precision && null !== $this->roundingMode) {
230+
if (null !== $this->scale && null !== $this->roundingMode) {
234231
// shift number to maintain the correct scale during rounding
235-
$roundingCoef = pow(10, $this->precision);
232+
$roundingCoef = pow(10, $this->scale);
236233
$number *= $roundingCoef;
237234

238235
switch ($this->roundingMode) {

src/Symfony/Component/Form/Extension/Core/Type/DateType.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $
283283
$pattern = $formatter->getPattern();
284284
$timezone = $formatter->getTimezoneId();
285285

286-
if ($setTimeZone = PHP_VERSION_ID >= 50500 || method_exists($formatter, 'setTimeZone')) {
287-
$formatter->setTimeZone('UTC');
288-
} else {
289-
$formatter->setTimeZoneId('UTC');
290-
}
286+
$formatter->setTimeZone('UTC');
291287

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

304-
if ($setTimeZone) {
305-
$formatter->setTimeZone($timezone);
306-
} else {
307-
$formatter->setTimeZoneId($timezone);
308-
}
300+
$formatter->setTimeZone($timezone);
309301

310302
return $timestamps;
311303
}

src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\FormBuilderInterface;
1616
use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
17-
use Symfony\Component\OptionsResolver\Options;
1817
use Symfony\Component\OptionsResolver\OptionsResolver;
1918

2019
class IntegerType extends AbstractType

src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Form\FormBuilderInterface;
1717
use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
1818
use Symfony\Component\Form\FormView;
19-
use Symfony\Component\OptionsResolver\Options;
2019
use Symfony\Component\OptionsResolver\OptionsResolver;
2120

2221
class MoneyType extends AbstractType

src/Symfony/Component/Form/Extension/Core/Type/NumberType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\FormBuilderInterface;
1616
use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
17-
use Symfony\Component\OptionsResolver\Options;
1817
use Symfony\Component\OptionsResolver\OptionsResolver;
1918

2019
class NumberType extends AbstractType

src/Symfony/Component/Form/Extension/Core/Type/PercentType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\FormBuilderInterface;
1616
use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer;
17-
use Symfony\Component\OptionsResolver\Options;
1817
use Symfony\Component\OptionsResolver\OptionsResolver;
1918

2019
class PercentType extends AbstractType

src/Symfony/Component/Form/Extension/Core/Type/TimeType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function configureOptions(OptionsResolver $resolver)
171171
return $options['widget'] !== 'single_text';
172172
};
173173

174-
$placeholder = $placeholderDefault = function (Options $options) {
174+
$placeholderDefault = function (Options $options) {
175175
return $options['required'] ? null : '';
176176
};
177177

@@ -219,7 +219,7 @@ public function configureOptions(OptionsResolver $resolver)
219219
'with_seconds' => false,
220220
'model_timezone' => null,
221221
'view_timezone' => null,
222-
'placeholder' => $placeholder,
222+
'placeholder' => $placeholderDefault,
223223
'html5' => true,
224224
// Don't modify \DateTime classes by reference, we treat
225225
// them like immutable value objects

src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class DependencyInjectionExtension implements FormExtensionInterface
2525
private $guesser;
2626
private $guesserLoaded = false;
2727

28-
public function __construct(ContainerInterface $container,
29-
array $typeServiceIds, array $typeExtensionServiceIds,
30-
array $guesserServiceIds)
28+
public function __construct(ContainerInterface $container, array $typeServiceIds, array $typeExtensionServiceIds, array $guesserServiceIds)
3129
{
3230
$this->container = $container;
3331
$this->typeServiceIds = $typeServiceIds;

src/Symfony/Component/Form/Form.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Form\Util\FormUtil;
2121
use Symfony\Component\Form\Util\InheritDataAwareIterator;
2222
use Symfony\Component\Form\Util\OrderedHashMap;
23-
use Symfony\Component\HttpFoundation\Request;
2423
use Symfony\Component\PropertyAccess\PropertyPath;
2524

2625
/**
@@ -506,10 +505,6 @@ public function handleRequest($request = null)
506505
*/
507506
public function submit($submittedData, $clearMissing = true)
508507
{
509-
if ($submittedData instanceof Request) {
510-
@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);
511-
}
512-
513508
if ($this->submitted) {
514509
throw new AlreadySubmittedException('A form can only be submitted once');
515510
}

src/Symfony/Component/Form/FormTypeExtensionInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public function finishView(FormView $view, FormInterface $form, array $options);
6363
* Configures the options for this type.
6464
*
6565
* @param OptionsResolver $resolver The resolver for the options.
66-
*
6766
*/
6867
public function configureOptions(OptionsResolver $resolver);
6968

src/Symfony/Component/Form/ResolvedFormType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
namespace Symfony\Component\Form;
1313

14-
use Symfony\Component\Form\Exception\InvalidArgumentException;
1514
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1615
use Symfony\Component\EventDispatcher\EventDispatcher;
17-
use Symfony\Component\Form\Util\StringUtil;
1816
use Symfony\Component\OptionsResolver\OptionsResolver;
1917

2018
/**

src/Symfony/Component/Templating/Loader/CacheLoader.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ public function load(TemplateReferenceInterface $template)
5858
if (is_file($path)) {
5959
if (null !== $this->logger) {
6060
$this->logger->debug('Fetching template from cache.', array('name' => $template->get('name')));
61-
} elseif (null !== $this->debugger) {
62-
// just for BC, to be removed in 3.0
63-
$this->debugger->log(sprintf('Fetching template "%s" from cache.', $template->get('name')));
6461
}
6562

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

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

8882
return new FileStorage($path);

src/Symfony/Component/Validator/Constraints/Callback.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ public function __construct($options = null)
3939
}
4040

4141
if (is_array($options) && !isset($options['callback']) && !isset($options['groups'])) {
42-
if (is_callable($options) || !$options) {
43-
$options = array('callback' => $options);
44-
}
42+
$options = array('callback' => $options);
4543
}
4644

4745
parent::__construct($options);

src/Symfony/Component/Validator/Context/ExecutionContextInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Validator\Context;
1313

1414
use Symfony\Component\Validator\Constraint;
15-
use Symfony\Component\Validator\Mapping\ClassMetadataInterface;
15+
use Symfony\Component\Validator\Mapping;
1616
use Symfony\Component\Validator\Mapping\MetadataInterface;
1717
use Symfony\Component\Validator\Validator\ValidatorInterface;
1818
use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
@@ -267,7 +267,7 @@ public function getValue();
267267
* Returns the metadata for the currently validated value.
268268
*
269269
* With the core implementation, this method returns a
270-
* {@link Mapping\ClassMetadata} instance if the current value is an object,
270+
* {@link Mapping\ClassMetadataInterface} instance if the current value is an object,
271271
* a {@link Mapping\PropertyMetadata} instance if the current value is
272272
* the value of a property and a {@link Mapping\GetterMetadata} instance if
273273
* the validated value is the result of a getter method.
@@ -292,7 +292,7 @@ public function getGroup();
292292
* Returns the class name of the current node.
293293
*
294294
* If the metadata of the current node does not implement
295-
* {@link ClassMetadataInterface} or if no metadata is available for the
295+
* {@link Mapping\ClassMetadataInterface} or if no metadata is available for the
296296
* current node, this method returns null.
297297
*
298298
* @return string|null The class name or null, if no class name could be found.

src/Symfony/Component/Validator/Mapping/GenericMetadata.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\Traverse;
1616
use Symfony\Component\Validator\Constraints\Valid;
17-
use Symfony\Component\Validator\Exception\BadMethodCallException;
1817
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
19-
use Symfony\Component\Validator\ValidationVisitorInterface;
2018

2119
/**
2220
* A generic container of {@link Constraint} objects.
@@ -115,7 +113,7 @@ public function __clone()
115113
* $traverse property of that constraint, the traversal strategy
116114
* will be set to one of the following:
117115
*
118-
* - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
116+
* - {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
119117
* - {@link TraversalStrategy::NONE} if $traverse is disabled
120118
*
121119
* @param Constraint $constraint The constraint to add
@@ -139,7 +137,6 @@ public function addConstraint(Constraint $constraint)
139137
$this->cascadingStrategy = CascadingStrategy::CASCADE;
140138

141139
if ($constraint->traverse) {
142-
// Traverse unless the value is not traversable
143140
$this->traversalStrategy = TraversalStrategy::IMPLICIT;
144141
} else {
145142
$this->traversalStrategy = TraversalStrategy::NONE;

src/Symfony/Component/Validator/Mapping/MemberMetadata.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
16-
use Symfony\Component\Validator\ValidationVisitorInterface;
1716

1817
/**
1918
* Stores all metadata needed for validating a class property.

src/Symfony/Component/Validator/Mapping/MetadataInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Validator\Mapping;
1313

1414
use Symfony\Component\Validator\Constraint;
15-
use Symfony\Component\Validator\ValidationVisitorInterface;
1615

1716
/**
1817
* A container for validation metadata.

src/Symfony/Component/Validator/ValidatorBuilder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\Translation\IdentityTranslator;
2020
use Symfony\Component\Translation\TranslatorInterface;
2121
use Symfony\Component\Validator\Context\ExecutionContextFactory;
22-
use Symfony\Component\Validator\Exception\InvalidArgumentException;
2322
use Symfony\Component\Validator\Exception\ValidatorException;
2423
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
2524
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;

src/Symfony/Component/Validator/ValidatorBuilderInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Validator;
1313

1414
use Doctrine\Common\Annotations\Reader;
15-
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
1615
use Symfony\Component\Translation\TranslatorInterface;
1716
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
1817
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"symfony/yaml": "",
3939
"symfony/config": "",
4040
"egulias/email-validator": "Strict (RFC compliant) email validation",
41+
"symfony/property-access": "For using the Expression validator",
4142
"symfony/expression-language": "For using the Expression validator"
4243
},
4344
"autoload": {

0 commit comments

Comments
 (0)
0