-
Notifications
You must be signed in to change notification settings - Fork 95
Dynamically type getters and hassers for parameters #152
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I love this! This is well thought out and I found only a single minor problem :) I wish that more people like you contributed to PHPStan :) Thank you.
Alright: a586e24
I'm gonna squash this and release it :)
Thank you!
@Kocal 👍 👏 Just tested your branch on our project and it found the following:
(all of them are valid reports which need to be fixed in our code - all are related to request parameter)
Offset 0 does not exist on array<string>|string|null.Cannot cast array<string>|string|null to int.(at(int) $rawAmount)Parameter #1 $input of method FooBar::fromString() expects string|null, array<string>|string|null given.(when passing a$request->query->all()['amount'])Parameter #1 $parameters of method BarBaz::filterParameters() expects array<string>, array<string, array<string>|string> givenwhen passing$request->query->all()
Enjoy it in phpstan-symfony 0.12.29 :)
Nice! :D
Uh oh!
There was an error while loading. Please reload this page.
Hi!
This is a proposal for #127.
I've re-used the same logic for services:
ParameterMapwhich contains all parametersDynamic return types have been implemented for:
ParameterBagInterface#getandParameterBagInterface#hasContainerInterface#getParameterandContainerInterface#hasParameterAbstractController#getParameterandController#getParameter(削除) However, I'm not able to do the same forAbstractController#getParameterandController#getParameterwhen using$this->getParameter('...')inside aAbstractControllerandController. It always use the return type fromAbstractController#getParameter. Is this a limitation from PHPStan or I did something wrong @ondrejmirtes? (削除ここまで)(削除) Also in Symfony 4.0 (lowest deps), there is no methodAbstractController#getParameter()and it make the tests failing. What is the best way to support lowest and highest Symfony version in tests and extension? What about using Symfony 4.4 as minimal requirements and droppingControllerusage? This is the only 4.x supported version right now. (削除ここまで)EDIT: Nevermind I fixed in c2d3f79 by using 4.4 as lowest version for
symfony/framework-bundle, and manually create the default type if a parameter does not exist.