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

Sign up
Appearance settings

Fix InputBagDynamicReturnTypeExtension #93

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

Closed

Conversation

Copy link
Contributor

@raalderink raalderink commented Aug 14, 2020

For the InputBag::get, if you add a default string parameter, it will always return a string. This is new in Symfony 5.0.

Fixes issue #91

composer.json Outdated
"symfony/console": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/http-foundation": "^4.0",
"symfony/http-foundation": "^4.0|^5.0",
Copy link
Member

@ondrejmirtes ondrejmirtes Aug 14, 2020

Choose a reason for hiding this comment

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

Why this change? Doesn't seem related to the rest.

Copy link
Contributor Author

@raalderink raalderink Aug 14, 2020

Choose a reason for hiding this comment

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

The InputBag is new in Symfony 5, didn't exist in 4 yet, so to run the tests we need Symfony 5

Copy link
Member

@ondrejmirtes ondrejmirtes Aug 14, 2020

Choose a reason for hiding this comment

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

There currently isn't a nice way to test it in a 3rd party package, so you can delete the file tests/Type/Symfony/input_bag_get.php which isn't very useful currently.

Copy link
Contributor Author

@raalderink raalderink Aug 14, 2020
edited
Loading

Choose a reason for hiding this comment

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

Okay, fair, so just delete the test altogether?

Copy link
Member

@ondrejmirtes ondrejmirtes Aug 14, 2020

Choose a reason for hiding this comment

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

Oh sorry, I haven't noticed there's actually a way here in phpstan-symfony with the ExtensionTestCase :) I just thought you create the file input_bag_get.php and let PHPStan analyse it, but right now you're actually checking the return types which is great :) So feel free to add some tests that fail with mixed, string|null etc. and see how my suggested logic fixes that :)

Copy link
Contributor Author

@raalderink raalderink Aug 14, 2020

Choose a reason for hiding this comment

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

I'm not quite sure what you want me too add there? The $default parameter can technically be mixed, however, anything other than a string will throw a deprecation notice. Besides, falling back on default will say string|null either way, no matter what you put in $default, so I'm not sure if it would matter. I'm fine with adding other types to the test but the result will be the same :P

Copy link
Member

@ondrejmirtes ondrejmirtes Aug 14, 2020

Choose a reason for hiding this comment

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

mixed means that it can be a string or null and we can't be sure, so the return type also has to be string|null. I just want to test the extension for mixed and string|null types as the second parameter.

Copy link
Contributor Author

@raalderink raalderink Aug 14, 2020

Choose a reason for hiding this comment

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

PR updated, I think that's what you were looking for?

Copy link
Member

@ondrejmirtes ondrejmirtes Aug 14, 2020

Choose a reason for hiding this comment

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

Approximately :) Thanks.

Copy link
Member

@ondrejmirtes ondrejmirtes Aug 14, 2020

Choose a reason for hiding this comment

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

Copy link
Contributor

ruudk commented Oct 20, 2020

@raalderink Anything I can do to help this PR get merged? I'm having the same issue while upgrading to Symfony 5.

Copy link
Contributor

ruudk commented Oct 20, 2020

Created a PR on your fork to get rid of the failing test. raalderink#1

Copy link
Contributor Author

@ruudk Thanks, I had lost track of this as I went on holiday

ruudk reacted with laugh emoji

Copy link
Member

Hi, the logic in the extension is solid but:

  1. I don't get the change in composer.json.
  2. The build failed.

Copy link
Contributor

ruudk commented Oct 21, 2020

@raalderink Are you going to fix this or should I take it over?

Copy link
Contributor

ruudk commented Oct 21, 2020

@ondrejmirtes @raalderink Let's continue in #107 which is ✅ and ready to merge 🎉

raalderink reacted with thumbs up emoji

@raalderink raalderink deleted the fix-input-bag-synamic-return-type branch October 22, 2020 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /