Bug report
A trait can be used in different contexts, so it does different things in different ways, depending on that context. I understand a trait is analyzed in specific contexts (which is great about Phpstan!), but sometimes Phpstan's conclusions are silly.
I might be misusing traits or php here, but it's perfectly valid code, and phpstan understands 99% of it. Sometimes a trait's used constant is truthy, and sometimes it's falsy, depending on the class it's used in: self::TRANSLATION.
It's a shame Phpstan Playground doesn't show "in context of" for traits.
Code snippet that reproduces the problem
https://phpstan.org/r/b5608f0c-7a9c-4523-b183-1522542df383
Expected output
Zero errors, because the trait is reused, so sometimes that line is 'always' true, and sometimes it's 'always' false.
I've no idea how Phpstan would even be smarter about this. Maybe don't make any assumptions about a constant that's defined outside the trait?
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
A trait can be used in different contexts, so it does different things in different ways, depending on that context. I understand a trait is analyzed in specific contexts (which is great about Phpstan!), but sometimes Phpstan's conclusions are silly.
I might be misusing traits or php here, but it's perfectly valid code, and phpstan understands 99% of it. Sometimes a trait's used constant is truthy, and sometimes it's falsy, depending on the class it's used in:
self::TRANSLATION.It's a shame Phpstan Playground doesn't show "in context of" for traits.
Code snippet that reproduces the problem
https://phpstan.org/r/b5608f0c-7a9c-4523-b183-1522542df383
Expected output
Zero errors, because the trait is reused, so sometimes that line is 'always' true, and sometimes it's 'always' false.
I've no idea how Phpstan would even be smarter about this. Maybe don't make any assumptions about a constant that's defined outside the trait?
Did PHPStan help you today? Did it make you happy in any way?
No response