FriendsOfCake / search

CakePHP: Easy model searching
MIT License
170 stars 59 forks source link

Casting needed for Finder filter #341

Closed dereuromark closed 8 months ago

dereuromark commented 8 months ago

Currently it has the options

    'map' => [],
    'options' => [],

But I get

findUser(): Argument #2 ($uid) must be of type int, string given

With URL

/admin/profiles?uid=115

I guess the string '115' is never casted to int, the custom finder however is

public function findUser(SelectQuery $query, int $uid)

Sure, we can workaround it using

public function findUser(SelectQuery $query, int|string $uid)

But it seems a bit less clean than allowing

'cast' => [
    'field_name' => 'int',
],

or alike as additional option to cast the value accordingly before passing it on?

We cannot always control the (finder) code, or signature. Especially for BC reasons if there are types already set.