Skip to content
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

Revert type casting because Symfony forms can return integer keys #369

Merged
merged 2 commits into from
Jun 17, 2022

Conversation

willemverspyck
Copy link
Contributor

Subject

I am targeting this branch, because BC.

Closes #368.

Changelog

### Fixed
- Added the type casting to string, because Symfony forms can return integer keys.

@jordisala1991
Copy link
Member

Build is failing, can you fix it?

nocive
nocive previously approved these changes Jun 16, 2022
@willemverspyck
Copy link
Contributor Author

willemverspyck commented Jun 16, 2022

I don't have many experience with PHP Stan. Do you know how I can solve this @jordisala1991?

@nocive
Copy link

nocive commented Jun 16, 2022

@willemverspyck in this case probably the most sane solution will be to instruct phpstan to ignore these 2 errors in particular, but I guess that's up to @jordisala1991 to say :). See here for the various ways phpstan allows you to do that, should that be the course of action taken here.

@willemverspyck
Copy link
Contributor Author

Thanks @nocive. I though there was a way to define it can also be integer, but just added the ignore comments 👍

Copy link
Member

@jordisala1991 jordisala1991 left a comment

Choose a reason for hiding this comment

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

Wdyt @VincentLanglet since you previously changed the code

@VincentLanglet
Copy link
Member

I think it's all related to phpstan/phpstan-symfony#274
And IMHO there would be more to fix in others repositories.

The issue is the following:

  • When using $form->add($foo, ...) you are only allowed to pass a string
  • This string is used as an array-key
  • When a string representation of an int is passed to an array it's automatically cast to int by php.
    So when you do $form->add('1') then you get the int 1 and you need to cast to string indeed to remove the form back.

I wonder if we should

@VincentLanglet
Copy link
Member

I opened an issue in Symfony symfony/symfony#46698

@nocive
Copy link

nocive commented Jun 17, 2022

Thanks guys! In the meantime is it possible to get this one in and release it?
This is preventing us from updating sonata dependencies without explicit pinning of form-extensions to <1.17

@VincentLanglet VincentLanglet merged commit 2030cfb into sonata-project:1.x Jun 17, 2022
@VincentLanglet
Copy link
Member

Will be solved in 6.2 by symfony/symfony#46813

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError on ResizeFormListener since 1.17.0
4 participants