Return value must be of type Cake\ORM\SelectQuery on TablePolicy

In my workers controller I added a function to List all workers.

$query = $this->Workers->find();
$query = $this->Authorization->applyScope($query);
$workers = $this->paginate($query);

and in WorkersTablePolicy

public function scopeListClients(IdentityInterface $user,  $query): SelectQuery
    {
        return $query->where(['Workers.rolde_id' => 2]);
    }

But when I call this method, I will get an error from Authorization.

App\Policy\WorkersTablePolicy::scopeListClients(): Return value must be of type Cake\ORM\SelectQuery, Cake\ORM\Query\SelectQuery returned

What is going wrong?

There is no such thing as a Cake\ORM\SelectQuery

Only Cake\ORM\Query\SelectQuery exists so fix your use statement at the top of your class.

Hey thanks for help.
I am wondering but this table policy was created by cake bake function.
I changed it and it works now

Oh ok, then this is a bug in the auth repo. Will get that fixed

2 Likes