8000 feature #42387 [Form] Deprecate calling FormErrorIterator::children()… · symfony/symfony@f0b1262 · GitHub
[go: up one dir, main page]

Skip to content

Commit f0b1262

Browse files
committed
feature #42387 [Form] Deprecate calling FormErrorIterator::children() if the current element is not iterable (W0rma)
This PR was merged into the 5.4 branch. Discussion ---------- [Form] Deprecate calling FormErrorIterator::children() if the current element is not iterable | Q | A | ------------- | --- | Branch? | 5.4 for features | Bug fix? | yes | New feature? | no | Deprecations? | yes | Tickets | #42301 (comment) | License | MIT | Doc PR | Commits ------- d8e74fc * Deprecated calling `FormErrorIterator::children()` if the current element is not iterable
2 parents a9753d7 + d8e74fc commit f0b1262

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

UPGRADE-5.4.md

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 2 deletions
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)
0