psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Missing class constant not detected by any error level

Open olleharstedt opened this issue 1 year ago • 1 comments

https://psalm.dev/r/fa2b6244a3 - no error

https://phpstan.org/r/a6ff88e7-2e26-4f3a-a7ed-9c48ef0ddf07 - properly detected by phpstan

olleharstedt avatar Apr 09 '24 15:04 olleharstedt

I found these snippets:

https://psalm.dev/r/fa2b6244a3
<?php
class A { const AA = 10; }
class B { }

class C
{
    /** @var A|B */
    var $a;
    /** @param A|B $a */
    function __construct($a) { $this->a = $a; }
    function test(): void { $this->a::AA; }
}
$c = new C(new B);
$c->test();
Psalm output (using commit ef3b018):

No issues!

psalm-github-bot[bot] avatar Apr 09 '24 15:04 psalm-github-bot[bot]