Using static analysis with Yii

Not sure how many of you know about Psalm: https://psalm.dev/

Project lead were friendly enough to merge my PR, which will make Psalm more usable for Yii projects (since absolutely everything in Yii2 implements __call one way or the other).

The PR includes a new setting: sealAllMethods. Using this, Psalm will assume all methods are either implemented or defined with @method class annotation. Code like this will then report an error:

$query = new \yii\db\Query();
$query->undefinedmethod();  // Error: No such method

Details can be found here: https://github.com/vimeo/psalm/pull/3578

2 Likes

That’s awesome. Thank you for handling it!