Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error with static::class #31

Open
siamskoi opened this issue May 9, 2020 · 5 comments
Open

Incorrect error with static::class #31

siamskoi opened this issue May 9, 2020 · 5 comments

Comments

@siamskoi
Copy link

siamskoi commented May 9, 2020

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
Copy link
Author

siamskoi commented May 9, 2020

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

@xjdata
Copy link

xjdata commented Jul 8, 2020

+1

@nfacha
Copy link

nfacha commented Aug 14, 2020

Also having this issue

@Dangetsu
Copy link

+1

1 similar comment
@NanakiRus
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants