Fix #134 by marking Enum::__callStatic as @psalm-pure#138
Conversation
To achieve proper static analysis coverage: * `vimeo/psalm` has been updated * a new `static-analysis` dir has been added (to test static analysis properties **only**) * impure `$this` usages in `Enum` have been ignored in static analysis checks * PHP version support has been upgraded from `>=7.1` to `^7.3 || ^8.0` * PHPUnit version has been upgraded to its latest and greatest Fixes myclabs#134
| * @param mixed $value | ||
| * | ||
| * @psalm-param static<T>|T $value | ||
| * @psalm-param T $value |
There was a problem hiding this comment.
This was changed because:
- psalm does not understand this union type
new MyEnum(new MyEnum('foo'))makes no sense anyway
There was a problem hiding this comment.
new MyEnum(new MyEnum('foo')) is a supported use case though 🤔
But your change only prevents that from happening explicitly, through static analysis. So after all this change makes sense I think.
|
I thought about it in my other PR: #136 and, based on https://psalm.dev/articles/immutability-and-beyond#mutation-free-methods article, I think we should replace some |
|
@drealecs nack: |
|
@Ocramius , yes, totally agree. |
mnapoli
left a comment
There was a problem hiding this comment.
Looking good, I'm not able to have an opinion on the Psalm thing. Are you both saying you're happy with the current state of the PR?
Or is there still a question to resolve?
| * @param mixed $value | ||
| * | ||
| * @psalm-param static<T>|T $value | ||
| * @psalm-param T $value |
There was a problem hiding this comment.
new MyEnum(new MyEnum('foo')) is a supported use case though 🤔
But your change only prevents that from happening explicitly, through static analysis. So after all this change makes sense I think.
Yes, but at type level, I don't expect anyone to actually use it anyway, so people that use EDIT: this was also discussed in private with @michaelpetri, who worked on #135. This also fixes #137 |
|
Perfect thanks! |
To achieve proper static analysis coverage:
vimeo/psalmhas been updatedstatic-analysisdir has been added (to test static analysis properties only)$thisusages inEnumhave been ignored in static analysis checks>=7.1to^7.3 || ^8.0Fixes #134