Completed
Push — master ( 187043...48cde4 )
by
unknown
01:30
created

src/Exceptions/InvalidFilterQuery.php (1 issue)

mismatching argument types.

Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Spatie\QueryBuilder\Exceptions;
4
5
use Illuminate\Http\Response;
6
use Illuminate\Support\Collection;
7
8
class InvalidFilterQuery extends InvalidQuery
9
{
10
    /** @var \Illuminate\Support\Collection */
11
    public $unknownFilters;
12
13
    /** @var \Illuminate\Support\Collection */
14
    public $allowedFilters;
15
16
    public function __construct(Collection $unknownFilters, Collection $allowedFilters)
17
    {
18
        $this->unknownFilters = $unknownFilters;
19
        $this->allowedFilters = $allowedFilters;
20
21
        $unknownFilters = $this->unknownFilters->implode(', ');
22
        $allowedFilters = $this->allowedFilters->implode(', ');
23
        $message = "Requested filter(s) `{$unknownFilters}` are not allowed. Allowed filter(s) are `{$allowedFilters}`.";
24
25
        parent::__construct(Response::HTTP_BAD_REQUEST, $message);
26
    }
27
28
    public static function filtersNotAllowed(Collection $unknownFilters, Collection $allowedFilters)
29
    {
30
        return new static(...func_get_args());
0 ignored issues
show
func_get_args() is of type array, but the function expects a object<Illuminate\Support\Collection>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31
    }
32
}
33