Skip to content

Commit d8e74fc

Browse files
committed
* Deprecated calling FormErrorIterator::children() if the current element is not iterable
1 parent 49a076a commit d8e74fc

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

UPGRADE-5.4.md

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Finder
1212
* Deprecate `Comparator::setTarget()` and `Comparator::setOperator()`
1313
* Add a constructor to `Comparator` that allows setting target and operator
1414

15+
Form
16+
------
17+
18+
* Deprecate calling `FormErrorIterator::children()` if the current element is not iterable.
19+
1520
FrameworkBundle
1621
---------------
1722

UPGRADE-6.0.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Finder
6969
Form
7070
----
7171

72+
* `FormErrorIterator::children()` throws an exception if the current element is not iterable.
7273
* The default value of the `rounding_mode` option of the `PercentType` has been changed to `\NumberFormatter::ROUND_HALFUP`.
7374
* The default rounding mode of the `PercentToLocalizedStringTransformer` has been changed to `\NumberFormatter::ROUND_HALFUP`.
7475
* Added the `getIsEmptyCallback()` method to the `FormConfigInterface`.

src/Symfony/Component/Form/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
5.4
55
---
66

7+
* Deprecate calling `FormErrorIterator::children()` if the current element is not iterable.
78
* Allow to pass `TranslatableMessage` objects to the `help` option
89

910
5.3

src/Symfony/Component/Form/FormErrorIterator.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Form\Exception\BadMethodCallException;
1515
use Symfony\Component\Form\Exception\InvalidArgumentException;
16+
use Symfony\Component\Form\Exception\LogicException;
1617
use Symfony\Component\Form\Exception\OutOfBoundsException;
1718
use Symfony\Component\Validator\ConstraintViolation;
1819

@@ -213,13 +214,16 @@ public function hasChildren()
213214
}
214215

215216
/**
216-
* Alias of {@link current()}.
217-
*
218217
* @return self
219218
*/
220219
#[\ReturnTypeWillChange]
221220
public function getChildren()
222221
{
222+
if (!$this->hasChildren()) {
223+
trigger_deprecation('symfony/form', '5.4', 'Calling "%s()" if the current element is not iterable is deprecated, call "%s" to get the current element.', __METHOD__, self::class.'::current()');
224+
// throw new LogicException(sprintf('The current element is not iterable. Use "%s" to get the current element.', self::class.'::current()'));
225+
}
226+
223227
return current($this->errors);
224228
}
225229

0 commit comments

Comments
 (0)