proget-hq / phpstan-yii2

Yii2 extension for PHPStan
MIT License
52 stars 17 forks source link

Update phpstan to 0.11 #13

Closed ghost closed 5 years ago

ghost commented 5 years ago

@ondrejmirtes

Is chaining of extensions intentional?

  Line   tests/Yii/MyController.php                                               
 ------ ------------------------------------------------------------------------- 
  40     Access to an undefined property                                          
         Proget\Tests\PHPStan\Yii2\Yii\MyUserActiveRecord|yii\web\User::$username.

The line is: \Yii::$app->user->username;

Yii declares it's properties in annotations (https://github.com/yiisoft/yii2/blob/master/framework/web/Application.php#L24): * @property User $user which can be overriden in config file (https://github.com/proget-hq/phpstan-yii2/pull/13/files#diff-78c0996a3bf818da34eb82c4fc2a6976R10). Our custom extension parses those overrides, but phpstan is chaining this extension with annotation property extension, resulting in an error.

Is there any way to solve it or are we doing something wrong?

ondrejmirtes commented 5 years ago

Hi, can you isolate that problem so I can debug it? Create a branch, or a repository and tell me what exactly I need to run to reproduce it. It seems peculiar to me that obviously $app->user is "Proget\Tests\PHPStan\Yii2\Yii\MyUserActiveRecord|yii\web\User" but it should only be "Proget\Tests\PHPStan\Yii2\Yii\MyUserActiveRecord".