Skip to content

[Form] Fix return types in form builder #42537

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
merged 1 commit into from
Aug 16, 2021

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Aug 13, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Tickets
License MIT
Doc PR

Fix return types incompatibilities found by psalm in #42511

Error: The declared return type 'Symfony\Component\EventDispatcher\EventDispatcherInterface' for Symfony\Component\Form\ButtonBuilder::getEventDispatcher is not nullable, but 'null' contains null (see https://psalm.dev/144)
Error: The declared return type 'string' for Symfony\Component\Form\ButtonBuilder::getAction is not nullable, but 'null' contains null (see https://psalm.dev/144)
Error: The declared return type 'string' for Symfony\Component\Form\ButtonBuilder::getMethod is not nullable, but 'null' contains null (see https://psalm.dev/144)
Error: The declared return type 'Symfony\Component\Form\RequestHandlerInterface' for Symfony\Component\Form\ButtonBuilder::getRequestHandler is not nullable, but 'null' contains null (see https://psalm.dev/144)
Error: The declared return type 'Symfony\Component\Form\FormFactoryInterface' for Symfony\Component\Form\FormConfigBuilder::getFormFactory is not nullable, but 'Symfony\Component\Form\FormFactoryInterface|null' contains null (see https://psalm.dev/144)
Error: The declared return type 'string' for Symfony\Component\Form\FormConfigBuilder::getAction is not nullable, but 'null|string' contains null (see https://psalm.dev/144)

@@ -88,11 +88,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
private $formFactory;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be made non-nullable, unitialized in 6.0

*/
private $action;

private $action = '';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be safe and mean the same thing. it's only used in the template where both null and '' are treated the same.

@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Aug 16, 2021
@nicolas-grekas
Copy link
Member

Thank you @Tobion.

@nicolas-grekas nicolas-grekas merged commit b1115f9 into symfony:5.4 Aug 16, 2021
@Tobion Tobion deleted the fix-form-builder-types branch August 16, 2021 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants