Skip to content

Error when running PHPstan on a Model using QueriesFlaggedEnums trait #273

Closed as not planned
@pacoorozco

Description

@pacoorozco

I'm using the QueriesFlaggedEnums trait in the Badge model. I've defined a local scope which use the hasAnyFlags(). PHPstan raises an error like:

------ ---------------------------------------------------------------------------------- 
  Line   app/Models/Badge.php                                                              
 ------ ---------------------------------------------------------------------------------- 
  109    Call to an undefined method Illuminate\Database\Eloquent\Builder::hasAnyFlags().  
 ------ ---------------------------------------------------------------------------------- 

This is the Laravel code:

107:    public function scopeWithActuatorsIn(Builder $query, array $actuators): Builder
107:    {
109:        return $query
110:            ->where('active', true)
111:            ->hasAnyFlags('actuators', $actuators);
112:    }

Someone was suggesting the use of PHP generics in order to avoid the problem. I've tried this approach using an stub file but nothing has changed.

The code could be find here: https://github.com/pacoorozco/gamify-laravel

Related to: larastan/larastan#1307

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions