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

[Form] Return value must be of type Symfony\Component\Form\FormError|Symfony\Component\Form\FormErrorIterator, bool returned #45867

Copy link
Copy link
Closed
@ProteanCode

Description

@ProteanCode
Issue body actions

Symfony version(s) affected

6.0.6

Description

When I do create a Form and execute the following code:

$parsedErrors = [];

$errors = $form->getErrors(true);
while($errors->current() !== null) {
  $parsedErrors[] = $errors->current();
  $errors->next();
}

It crashes with following message

Return value must be of type Symfony\Component\Form\FormError|Symfony\Component\Form\FormErrorIterator, bool returned

How to reproduce

Aside note: my project is an API

Inside a project create a Form and send to it an invalid data with a POST request so the error bad will be filled and the $form->getErrors(true) should not be empty.

Then run code that looks like this:

$parsedErrors = [];

$errors = $form->getErrors(true);
while($errors->current() !== null) {
  $parsedErrors[] = $errors->current();
  $errors->next();
}

And web server will throw a 502 http code with critical log at PHP FPM container (I do use docker)

Possible Solution

For newer version of PHP there are union types, in PHP8 they works like that

    public function x(): int|float
    {
        return [
            5, 1.2
        ][rand(0,1)];
    }

So adding an bool to the return type of Symfony\Component\Form\FormErrorIterator::current() should be sufficient

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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