Psalm: Use of undefined class constant is not reported when using static::

Created on 15 Jun 2019  路  4Comments  路  Source: vimeo/psalm

https://psalm.dev/r/4c99e2883e

I would expect an error to be reported for line 11.

bug

Most helpful comment

I think this is a bug - ideally Psalm should both require a present constant, and verify that descendants don鈥檛 change that constant鈥檚 type (same with static properties).

All 4 comments

There should be an error, but only if the class is final. Otherwise that constant may be defined in descendant classes.

Why are constants treated differently than variables?

For e.g. an error is thrown for static::$nonExistent. https://psalm.dev/r/a19c1bd23f

I think this is a bug - ideally Psalm should both require a present constant, and verify that descendants don鈥檛 change that constant鈥檚 type (same with static properties).

I've ensured that the missing class constant is now reported.

Was this page helpful?
0 / 5 - 0 ratings