Conversation
|
Hi, I have ideas about this, but it needs a much bigger picture - I'll introduce to the whole picture in this comment :) So, there are some related bugs/feature requests:
What all of these have in common is that you need to construct a graph of nodes with relations between them - where values are written and when they are read. Psalm has some of these features and this article (https://psalm.dev/articles/better-unused-variable-detection) talks about it. I've kindly asked @arnaud-lb to work on this and right now it's in a form of this package: https://github.com/arnaud-lb/php-sema which should somehow be adopted in PHPStan. Not sure if we can use it directly, most likely we'll adapt the algorithms and apply them here. The priority for me is to get rid of the false positives about readonly properties. At the same time we should be able to detect more situations where readonly property assignment is missing or there is a risk of multiple assignments. After that is all figured out and released, we can work on the dead variable rules etc. :) Are you interested in continuing this work? Thanks :) |
|
Wow! The picture was much bigger than I thought. |
|
Oh wow, you're definitely not picking the easy stuff 😊 I'm looking forward to that too! Thank you very much. And remember - more smaller PRs is better than a single huge one 😊 |
|
Hi, I'm cleaning up old and stale PRs. I don't think we need to keep this one open :) |
Just to start with phpstan/phpstan#6402
I'm not sure all these test are solvable or not.