proget-hq / phpstan-yii2

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

Parameter #1 $condition of method yii\db\Query::where() expects array, string given. #16

Closed EtienneBruines closed 3 years ago

EtienneBruines commented 5 years ago

This might just be an awkward bug of phpstan itself, but I thought I'd mention it here first.

        $file = Files::find()
            ->select('name')
            ->where('id = :id', [':id' => $fileId])
            ->one();

Here it complains that the where method wants an array and never a string. This is because the original \yii\db\Query class includes {@inheritdoc} for the where method, and the original \yii\db\QueryInterface interface only allows for array.

That the \yii\db\Query class "overrided" the parameter (to allow also string and ExpressionInterface) does not matter to phpstan.

Should this be worked around in phpstan-yii2 or should this thing be fixed in phpstan itself?


phpstan 0.11.15
level 5
EtienneBruines commented 5 years ago

According to https://github.com/phpstan/phpstan/issues/670#issuecomment-349265176 the developer won't be supporting this @inheritdoc usage by Yii though.

ghost commented 5 years ago

We currently ignore that error in our projects. You are always welcome to submit a PR supporting this :)

marmichalski commented 3 years ago

This seems to be working with latest master version. Could you verify?