Skip to content

Navigation Menu

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

[Form] Deprecate calling FormErrorIterator::children() if the current element is not iterable #42387

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
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
5 changes: 5 additions & 0 deletions 5 UPGRADE-5.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Finder
* Deprecate `Comparator::setTarget()` and `Comparator::setOperator()`
* Add a constructor to `Comparator` that allows setting target and operator

Form
------

* Deprecate calling `FormErrorIterator::children()` if the current element is not iterable.

FrameworkBundle
---------------

Expand Down
1 change: 1 addition & 0 deletions 1 UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Finder
Form
----

* `FormErrorIterator::children()` throws an exception if the current element is not iterable.
* The default value of the `rounding_mode` option of the `PercentType` has been changed to `\NumberFormatter::ROUND_HALFUP`.
* The default rounding mode of the `PercentToLocalizedStringTransformer` has been changed to `\NumberFormatter::ROUND_HALFUP`.
* Added the `getIsEmptyCallback()` method to the `FormConfigInterface`.
Expand Down
1 change: 1 addition & 0 deletions 1 src/Symfony/Component/Form/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
5.4
---

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

5.3
Expand Down
8 changes: 6 additions & 2 deletions 8 src/Symfony/Component/Form/FormErrorIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\Exception\InvalidArgumentException;
use Symfony\Component\Form\Exception\LogicException;
use Symfony\Component\Form\Exception\OutOfBoundsException;
use Symfony\Component\Validator\ConstraintViolation;

Expand Down Expand Up @@ -213,13 +214,16 @@ public function hasChildren()
}

/**
* Alias of {@link current()}.
*
* @return self
*/
#[\ReturnTypeWillChange]
public function getChildren()
{
if (!$this->hasChildren()) {
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()');
derrabus marked this conversation as resolved.
Show resolved Hide resolved
// throw new LogicException(sprintf('The current element is not iterable. Use "%s" to get the current element.', self::class.'::current()'));
}

return current($this->errors);
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.