-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Description
Several Yii2 classes contain inconsistent or incomplete PHPDoc annotations that affect static analysis (PHPStan/Psalm) and IDE inference.
A representative example is found in BaseYii.php:
/**
* @var \yii\console\Application|\yii\web\Application the application instance
*
* @phpstan-var \yii\console\Application|\yii\web\Application<TUserIdentity>
* @psalm-var \yii\console\Application|\yii\web\Application<TUserIdentity>
*/
public static $app;However, in many parts of the framework, $app can be null (for example, during test teardown or before bootstrap), leading to PHPStan errors like:
Property Yii::$app (yii\web\Application|yii\console\Application) does not accept null.This specific case also appears in:
tests/TestCase.php
tests/framework/console/controllers/DbMessageControllerTest.php
tests/framework/i18n/DbMessageSourceTest.php
The same pattern occurs elsewhere: properties and return types that are dynamically nullable or polymorphic, but their PHPDoc types don’t reflect that.
A review of the phpstan-baseline.neon file shows multiple suppressions related to:
null assignments to properties without null
mixed or union type mismatches
This indicates a systemic documentation/type inconsistency between runtime behavior and declared PHPDoc types.