Skip to content

Incorrect error with static::class #31

@siamskoi

Description

@siamskoi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions