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
Add Exception->getCode() return type provider #7390
Conversation
ede5ea6
to
cfcf70b
Compare
src/Psalm/Internal/Provider/ReturnTypeProvider/ExceptionCodeReturnTypeProvider.php
Outdated
Show resolved
Hide resolved
cfcf70b
to
1d6ae16
Compare
src/Psalm/Internal/Provider/ReturnTypeProvider/ExceptionCodeReturnTypeProvider.php
Outdated
Show resolved
Hide resolved
@orklah Seems like my return type provider is not used. Any idea why ? |
Yeah, it's because I'm a moron 😄 MethodReturnTypes are actually registered here:
|
a950b89
to
2fa0a3a
Compare
2fa0a3a
to
9f84da4
Compare
src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php
Show resolved
Hide resolved
@weirdan This will be an important change. If you take a look at test with real projects, you'll see that phpunit for example has a lot of redundant casts now. This is probably due to Psalm not being able to infer the exact type before, it pushed users into adding cast to please static analyzers, but now it will treat those as redundant. I talked with @VincentLanglet about this and suggested adding this to Psalm 5, but he made a good point mentioning this PR is the equivalent of PHPStan behaviour right now and for users that like to use both, this difference makes things difficult. (they're forced to suppress everything on one analyzer or the other because behaviour is opposed) What's your take on this? Can we release that on 4.x? |
If we marked the int type generated here with the
|
And then we could drop the flag in Psalm 5 |
Good,idea :) @VincentLanglet can you apply the changes? |
c4c11a7
to
c1201ce
Compare
c1201ce
to
9905bae
Compare
Done @orklah |
Thanks! |
You're welcome. Any plan for the next release ? |
Close #4295