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
Amend type hint to match default value #451
Conversation
There are more cases (even in the same controller) that suffer from this. I can resolve all of them. I just want to point onto this and listen whether this is a needed and viable fix for the other cases. |
IMHO the null default doesn't make sense why allow null on the framework level and then having to handle null in userland? Also shouldn't this be catchable by static analysis? as the if block is unreachable, would be nice to prevent this issues in the future |
I agree. You use psalm, don't you? I can imagine psalm is catching this. |
probably not on the low level, we have set up 🙈 |
If one remove the check in the userland should I add a uuid check on id instead? |
PhpStan has an UnreachableIfBranchRule, that should be activated but somehow misses this, probably because an empty string would also be falsy |
52eb2eb
to
58fcfcb
Compare
I applied the requested changes |
Hello, thank you for creating this pull request. Please use this issue to track the state of your pull request. |
@JoshuaBehrens can you please resolve the conflicts here 🙂 ? |
I put it on my TODO 👍 👀 |
✔️ |
The TravisCI is finally working again 🚀 but it looks like some test are failing Sunny regards |
Hi @JoshuaBehrens Sunny regards |
I can retry testing it but the last time I tried my tests were not working because of a missing google client dependency. |
742e6f5
to
0219577
Compare
Hi @JoshuaBehrens, are those changes not the same as in this PR: https://github.com/shopware/platform/pull/471/files besides the route annotations? Best regards |
@tobiasberge @JoshuaBehrens I guess there are a few commits to much 😉 needs a clean-up |
Damn it I guess I rebased onto the wrong branch :D |
@JoshuaBehrens Do you still have issues with the Google client dependency? |
I resolved it on the boostday 😁 |
Hi @JoshuaBehrens, there are still the changes from the other PR (EntityCollection class) in this branch. Best regards |
Sorry for delaying. I try to get it into my schedule ASAP |
Hey @tobiasberge I tidied things a bit up |
Thanks for merging 👍 💙 |
Hi @JoshuaBehrens , |
1. Why is this change necessary?
The phpdocs for the route defaults does not match the typehint in the arguments. This results in an an exception on the php side as the type constraint is not fulfilled. So the validity check whether the parameter is ok is never reached and no readable exception is thrown/logged.
2. What does this change do, exactly?
Loosen up the typehint by adding nullability.
3. Describe each step to reproduce the issue or behaviour.
Uncaught PHP Exception TypeError: "Argument 1 passed to Shopware\Storefront\Controller\CmsController::page() must be of the type string, null given
Parameter "Parameter id missing" is missing.
MissingRequestParameterException
4. Checklist