proget-hq / phpstan-yii2

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

Incorrect error with static::class #31

Open siamskoi opened 4 years ago

siamskoi commented 4 years ago

PHPStan crashing when I use static type in relation, for example: recursive category with same parent type:

class` Category extends ActiveRecord
{
    public function getParent(): ActiveQuery
    {
        return $this->hasOne(static::class, ['id' => 'parent_id']);
    }
}

And I got error:

 Line   common/components/category/models/Category.php                
 ------ -------------------------------------------------------------- 
         Internal error: Invalid argument provided to method hasOne    
         Hint: You should use ::class instead of ::className()         
         Run PHPStan with --debug option and post the stack trace to:  
         https://github.com/phpstan/phpstan/issues/new  

 -- ------------------------------------------------------------------------------------------------- 
     Error                                                                                            
 -- ------------------------------------------------------------------------------------------------- 
     Error message "Internal error: Invalid argument provided to method hasOne                        
     Hint: You should use ::class instead of ::className()                                            
     Run PHPStan with --debug option and post the stack trace to:                                     
     https://github.com/phpstan/phpstan/issues/new" cannot be ignored, use excludes_analyse instead.  
 -- ------------------------------------------------------------------------------------------------- 

 [ERROR] Found 1 errors

I use last version of proget-hq/phpstan-yii2 on current date.

siamskoi commented 4 years ago

And / @phpstan-ignore-next-line / doesn't work with this error.

xjdata commented 4 years ago

+1

nfacha commented 4 years ago

Also having this issue

Dangetsu commented 4 years ago

+1

NanakiRus commented 2 years ago

+1