for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\QueryBuilder\Exceptions;
use Illuminate\Http\Response;
use Illuminate\Support\Collection;
class InvalidFilterQuery extends InvalidQuery
{
/** @var \Illuminate\Support\Collection */
public $unknownFilters;
public $allowedFilters;
public function __construct(Collection $unknownFilters, Collection $allowedFilters)
$this->unknownFilters = $unknownFilters;
$this->allowedFilters = $allowedFilters;
$unknownFilters = $this->unknownFilters->implode(', ');
$allowedFilters = $this->allowedFilters->implode(', ');
$message = "Requested filter(s) `{$unknownFilters}` are not allowed. Allowed filter(s) are `{$allowedFilters}`.";
parent::__construct(Response::HTTP_BAD_REQUEST, $message);
}
public static function filtersNotAllowed(Collection $unknownFilters, Collection $allowedFilters)
$unknownFilters
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$allowedFilters
return new static(...func_get_args());
InvalidFilterQuery::__construct()
This check looks for function calls that miss required arguments.
func_get_args()
array
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);
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.