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
Introduce InvalidTypesInUnionRule #2763
Introduce InvalidTypesInUnionRule #2763
Conversation
I love it, thank you very much! |
Nice, thx @paulbalandan ! |
|
||
namespace InvalidUnionWithMixed; | ||
|
||
class Foo |
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.
what about applying the same rules for phpdoc types?
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.
We'd have to give it some more thought, thanks to type normalization mixed|null
is totally fine in PHPDocs, I don't want to mark that as an error.
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.
a special rule only for phpdocs invalid types maybe, maybe hidden behind bleeding edge? hmm
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.
Invalid types in PHPDocs like string&int
are already reported. If you think there is some scenario that isn't covered, open a new feature requests, thanks.
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.
As mentioned before, we have phpstan/phpstan#6720 already, so it might be a special thing for void mostly :)
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.
Void in return types should be transformed into null after a call.
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.
would you say only for phpdoc or in general? currently thinking were the best place is to transform types 🤔
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.
In MutatingScope::resolveType where MethodCall/StaticCall/FuncCall are handled.
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.
Ok thx, I did exactly that already 😊 looked mostly good with a couple of question marks. Will open a PR when ready.
Closes phpstan/phpstan#9185