Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 761bcca

Browse filesBrowse files
committed
[Form] Missing deprecated paths removal
1 parent 6f0f7e1 commit 761bcca
Copy full SHA for 761bcca

File tree

11 files changed

+50
-207
lines changed
Filter options

11 files changed

+50
-207
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<argument /><!-- All services with tag "form.type" are stored in a service locator by FormPass -->
3939
<argument type="collection" /><!-- All services with tag "form.type_extension" are stored here by FormPass -->
4040
<argument type="iterator" /><!-- All services with tag "form.type_guesser" are stored here by FormPass -->
41-
<argument>null</argument><!-- @deprecated argument in 3.3, to be removed in 4.0 -->
4241
</service>
4342

4443
<!-- ValidatorTypeGuesser -->

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/form_debug.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/form_debug.xml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<service id="data_collector.form" class="Symfony\Component\Form\Extension\DataCollector\FormDataCollector" public="true">
2727
<tag name="data_collector" template="@WebProfiler/Collector/form.html.twig" id="form" priority="310" />
2828
<argument type="service" id="data_collector.form.extractor" />
29-
<argument>false</argument>
3029
</service>
3130
</services>
3231
</container>

‎src/Symfony/Component/Form/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ CHANGELOG
1313
* removed the support for caching loaded choice lists in `LazyChoiceList`,
1414
cache the choice list in the used `ChoiceLoaderInterface` implementation
1515
instead
16+
* removed the support for objects implementing both `\Traversable` and `\ArrayAccess` in `ResizeFormListener::preSubmit()`
17+
* removed the ability to use `FormDataCollector` without the `symfony/var-dumper` component
18+
* removed passing a `ValueExporter` instance to the `FormDataExtractor::__construct()` method
19+
* removed passing guesser services ids as the fourth argument of `DependencyInjectionExtension::__construct()`
20+
* removed the ability to validate an unsubmitted form.
1621

1722
3.3.0
1823
-----

‎src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ public function preSubmit(FormEvent $event)
102102
$form = $event->getForm();
103103
$data = $event->getData();
104104

105-
if ($data instanceof \Traversable && $data instanceof \ArrayAccess) {
106-
@trigger_error('Support for objects implementing both \Traversable and \ArrayAccess is deprecated since version 3.1 and will be removed in 4.0. Use an array instead.', E_USER_DEPRECATED);
107-
}
108-
109-
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
105+
if (!is_array($data)) {
110106
$data = array();
111107
}
112108

‎src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php
+41-60Lines changed: 41 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Response;
1818
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
19-
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
2019
use Symfony\Component\Validator\ConstraintViolationInterface;
2120
use Symfony\Component\VarDumper\Caster\Caster;
2221
use Symfony\Component\VarDumper\Caster\ClassStub;
@@ -72,27 +71,23 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
7271
*/
7372
private $formsByView;
7473

75-
/**
76-
* @var ValueExporter
77-
*/
78-
private $valueExporter;
79-
8074
/**
8175
* @var ClonerInterface
8276
*/
8377
private $cloner;
8478

85-
private $hasVarDumper;
86-
8779
public function __construct(FormDataExtractorInterface $dataExtractor)
8880
{
81+
if (!class_exists(ClassStub::class)) {
82+
throw new \LogicException(sprintf('The VarDumper component is needed for using the %s class. Install symfony/var-dumper version 3.4 or above.', __CLASS__));
83+
}
84+
8985
$this->dataExtractor = $dataExtractor;
9086
$this->data = array(
9187
'forms' => array(),
9288
'forms_by_hash' => array(),
9389
'nb_errors' => 0,
9490
);
95-
$this->hasVarDumper = class_exists(ClassStub::class);
9691
}
9792

9893
/**
@@ -241,11 +236,9 @@ public function getData()
241236

242237
public function serialize()
243238
{
244-
if ($this->hasVarDumper) {
245-
foreach ($this->data['forms_by_hash'] as &$form) {
246-
if (isset($form['type_class']) && !$form['type_class'] instanceof ClassStub) {
247-
$form['type_class'] = new ClassStub($form['type_class']);
248-
}
239+
foreach ($this->data['forms_by_hash'] as &$form) {
240+
if (isset($form['type_class']) && !$form['type_class'] instanceof ClassStub) {
241+
$form['type_class'] = new ClassStub($form['type_class']);
249242
}
250243
}
251244

@@ -261,55 +254,43 @@ protected function cloneVar($var, $isClass = false)
261254
return $var;
262255
}
263256
if (null === $this->cloner) {
264-
if ($this->hasVarDumper) {
265-
$this->cloner = new VarCloner();
266-
$this->cloner->setMaxItems(-1);
267-
$this->cloner->addCasters(array(
268-
'*' => function ($v, array $a, Stub $s, $isNested) {
269-
foreach ($a as &$v) {
270-
if (is_object($v) && !$v instanceof \DateTimeInterface) {
271-
$v = new CutStub($v);
272-
}
257+
$this->cloner = new VarCloner();
258+
$this->cloner->setMaxItems(-1);
259+
$this->cloner->addCasters(array(
260+
'*' => function ($v, array $a, Stub $s, $isNested) {
261+
foreach ($a as &$v) {
262+
if (is_object($v) && !$v instanceof \DateTimeInterface) {
263+
$v = new CutStub($v);
273264
}
274-
275-
return $a;
276-
},
277-
\Exception::class => function (\Exception $e, array $a, Stub $s) {
278-
if (isset($a[$k = "\0Exception\0previous"])) {
279-
unset($a[$k]);
280-
++$s->cut;
281-
}
282-
283-
return $a;
284-
},
285-
FormInterface::class => function (FormInterface $f, array $a) {
286-
return array(
287-
Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
288-
Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())),
289-
);
290-
},
291-
ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) {
292-
return array(
293-
Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(),
294-
Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(),
295-
Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(),
296-
);
297-
},
298-
));
299-
} else {
300-
@trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since version 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), E_USER_DEPRECATED);
301-
$this->cloner = false;
302-
}
303-
}
304-
if (false !== $this->cloner) {
305-
return $this->cloner->cloneVar($var, Caster::EXCLUDE_VERBOSE);
306-
}
307-
308-
if (null === $this->valueExporter) {
309-
$this->valueExporter = new ValueExporter();
265+
}
266+
267+
return $a;
268+
},
269+
\Exception::class => function (\Exception $e, array $a, Stub $s) {
270+
if (isset($a[$k = "\0Exception\0previous"])) {
271+
unset($a[$k]);
272+
++$s->cut;
273+
}
274+
275+
return $a;
276+
},
277+
FormInterface::class => function (FormInterface $f, array $a) {
278+
return array(
279+
Caster::PREFIX_VIRTUAL.'name' => $f->getName(),
280+
Caster::PREFIX_VIRTUAL.'type_class' => new ClassStub(get_class($f->getConfig()->getType()->getInnerType())),
281+
);
282+
},
283+
ConstraintViolationInterface::class => function (ConstraintViolationInterface $v, array $a) {
284+
return array(
285+
Caster::PREFIX_VIRTUAL.'root' => $v->getRoot(),
286+
Caster::PREFIX_VIRTUAL.'path' => $v->getPropertyPath(),
287+
Caster::PREFIX_VIRTUAL.'value' => $v->getInvalidValue(),
288+
);
289+
},
290+
));
310291
}
311292

312-
return $this->valueExporter->exportValue($var);
293+
return $this->cloner->cloneVar($var, Caster::EXCLUDE_VERBOSE);
313294
}
314295

315296
private function &recursiveBuildPreliminaryFormTree(FormInterface $form, array &$outputByHash)

‎src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Form\FormInterface;
1515
use Symfony\Component\Form\FormView;
16-
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
1716
use Symfony\Component\Validator\ConstraintViolationInterface;
1817

1918
/**
@@ -23,16 +22,6 @@
2322
*/
2423
class FormDataExtractor implements FormDataExtractorInterface
2524
{
26-
/**
27-
* Constructs a new data extractor.
28-
*/
29-
public function __construct(ValueExporter $valueExporter = null, $triggerDeprecationNotice = true)
30-
{
31-
if (null !== $valueExporter && $triggerDeprecationNotice) {
32-
@trigger_error('Passing a ValueExporter instance to '.__METHOD__.'() is deprecated in version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED);
33-
}
34-
}
35-
3625
/**
3726
* {@inheritdoc}
3827
*/

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php
+1-33Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,22 @@ class DependencyInjectionExtension implements FormExtensionInterface
2424
private $typeExtensionServices;
2525
private $guesserServices;
2626

27-
// @deprecated to be removed in Symfony 4.0
28-
private $typeServiceIds;
29-
private $guesserServiceIds;
30-
3127
/**
3228
* Constructor.
3329
*
3430
* @param ContainerInterface $typeContainer
3531
* @param iterable[] $typeExtensionServices
3632
* @param iterable $guesserServices
3733
*/
38-
public function __construct(ContainerInterface $typeContainer, array $typeExtensionServices, $guesserServices, array $guesserServiceIds = null)
34+
public function __construct(ContainerInterface $typeContainer, array $typeExtensionServices, $guesserServices)
3935
{
40-
if (null !== $guesserServiceIds) {
41-
@trigger_error(sprintf('Passing four arguments to the %s::__construct() method is deprecated since Symfony 3.3 and will be disallowed in Symfony 4.0. The new constructor only accepts three arguments.', __CLASS__), E_USER_DEPRECATED);
42-
$this->guesserServiceIds = $guesserServiceIds;
43-
$this->typeServiceIds = $typeExtensionServices;
44-
$typeExtensionServices = $guesserServices;
45-
$guesserServices = $guesserServiceIds;
46-
}
47-
4836
$this->typeContainer = $typeContainer;
4937
$this->typeExtensionServices = $typeExtensionServices;
5038
$this->guesserServices = $guesserServices;
5139
}
5240

5341
public function getType($name)
5442
{
55-
if (null !== $this->guesserServiceIds) {
56-
if (!isset($this->typeServiceIds[$name])) {
57-
throw new InvalidArgumentException(sprintf('The field type "%s" is not registered in the service container.', $name));
58-
}
59-
60-
return $this->typeContainer->get($this->typeServiceIds[$name]);
61-
}
62-
6343
if (!$this->typeContainer->has($name)) {
6444
throw new InvalidArgumentException(sprintf('The field type "%s" is not registered in the service container.', $name));
6545
}
@@ -69,10 +49,6 @@ public function getType($name)
6949

7050
public function hasType($name)
7151
{
72-
if (null !== $this->guesserServiceIds) {
73-
return isset($this->typeServiceIds[$name]);
74-
}
75-
7652
return $this->typeContainer->has($name);
7753
}
7854

@@ -82,10 +58,6 @@ public function getTypeExtensions($name)
8258

8359
if (isset($this->typeExtensionServices[$name])) {
8460
foreach ($this->typeExtensionServices[$name] as $serviceId => $extension) {
85-
if (null !== $this->guesserServiceIds) {
86-
$extension = $this->typeContainer->get($serviceId = $extension);
87-
}
88-
8961
$extensions[] = $extension;
9062

9163
// validate result of getExtendedType() to ensure it is consistent with the service definition
@@ -116,10 +88,6 @@ public function getTypeGuesser()
11688
$guessers = array();
11789

11890
foreach ($this->guesserServices as $serviceId => $service) {
119-
if (null !== $this->guesserServiceIds) {
120-
$service = $this->typeContainer->get($serviceId = $service);
121-
}
122-
12391
$guessers[] = $service;
12492
}
12593

‎src/Symfony/Component/Form/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Form.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,7 @@ public function isEmpty()
736736
public function isValid()
737737
{
738738
if (!$this->submitted) {
739-
@trigger_error('Call Form::isValid() with an unsubmitted form is deprecated since version 3.2 and will throw an exception in 4.0. Use Form::isSubmitted() before Form::isValid() instead.', E_USER_DEPRECATED);
740-
741-
return false;
739+
throw new LogicException('Cannot check if an unsubmitted form is valid. Call Form::isSubmitted() before Form::isValid().');
742740
}
743741

744742
if ($this->isDisabled()) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.