Support value-of<BackedEnum>#1082
Conversation
|
this part of the initial issue
sounds like a missing rule-check somewhere... I think this can be fixed in a separate PR (which I can work on after this)? |
|
(sorry for trial and error.. have no php 8.1 setup yet locally) build error is unrelated |
ondrejmirtes
left a comment
There was a problem hiding this comment.
Please also add a case to NodeScopeResolverTest that tests what value-of resolves to inside a method body.
|
About this:
Yeah, let's discuss this separately in another PR. The issue here is that phpstan-src/src/PhpDoc/TypeNodeResolver.php Line 460 in 14cb258 |
1ca0150 to
90851b1
Compare
ddd20b4 to
95d480b
Compare
|
Please add NodeScopeResolverTest case to verify it works as expected. |
d1ab145 to
2a920cf
Compare
done |
ondrejmirtes
left a comment
There was a problem hiding this comment.
Obviously the implementation in TypeNodeResolver needs to change. Please iterate over ClassReflection::getEnumCases() to get to actual scalar values.
There was a problem hiding this comment.
Require is not needed here, make sure to run composer dump locally first.
There was a problem hiding this comment.
I checked it locally.. the tests do not work without this require line.
even if I run composer dump beforehand
There was a problem hiding this comment.
ahh.. I need to /my/php8.1 composer dump and then it works
There was a problem hiding this comment.
This isn't good enough, right? Should be 'The Netherlands'|'United States' really.
There was a problem hiding this comment.
It's also why that bug isn't report in CallMethodsRuleTest.
There was a problem hiding this comment.
fixed it. good catch.
0f82164 to
d9bed9f
Compare
768c2a3 to
2759d26
Compare
| function doFooArray() { | ||
| $this->hello(CountryNo::NL); | ||
|
|
||
| // 'abc' does not match value-of<Country> |
There was a problem hiding this comment.
as expected, we now see errors here.
|
Thank you. |
as requested in phpstan/phpstan#6841 (comment)
closes phpstan/phpstan#6775