vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.49k stars 655 forks source link

Excessive `static` in types #3218

Open SCIF opened 4 years ago

SCIF commented 4 years ago

I'm expecting to see C2&B<C2> in L39 https://psalm.dev/r/741c0756dd

psalm-github-bot[bot] commented 4 years ago

I found these snippets:

https://psalm.dev/r/741c0756dd ```php &self */ public function b() {} } class A2 { /** * @return B&static */ public function b() {} } class C extends A {} class C2 extends A2 {} /** * @template T */ Class B { /** * @return T&B */ public function some() {} } $a = new C(); /** @psalm-trace $b */ $b = $a->b(); /** @psalm-trace $t */ $t = $b->some(); $a = new C2(); /** @psalm-trace $b */ $b = $a->b(); /** @psalm-trace $t */ $t = $b->some(); ``` ``` Psalm output (using commit e1c6fcc): INFO: Trace - 32:1 - $b: B&A INFO: Trace - 34:1 - $t: A&B INFO: Trace - 39:1 - $b: B&C2 INFO: Trace - 41:1 - $t: C2&B>&B INFO: UnusedVariable - 34:1 - Variable $t is never referenced INFO: UnusedVariable - 41:1 - Variable $t is never referenced ERROR: InvalidReturnType - 5:15 - No return statements were found for method A::b but return type 'B&A' was expected ERROR: InvalidReturnType - 12:15 - No return statements were found for method A2::b but return type 'B' was expected ERROR: InvalidReturnType - 25:15 - No return statements were found for method B::some but return type 'T' was expected ```
orklah commented 1 year ago

@SCIF output changed, could you have a look and tell us if it behaves better now?