for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of slick/mvc package
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Slick\Mvc\Service\Entity\QueryFilter;
use Slick\Common\Base;
use Slick\Mvc\Service\Entity\QueryFilterInterface;
use Slick\Orm\Repository\QueryObject\QueryObjectInterface;
* Search Filter
* @package Slick\Mvc\Service\Entity\QueryFilter
* @author Filipe Silva <[email protected]>
* @property string $pattern
* @property string[] $fields
class SearchFilter extends Base implements QueryFilterInterface
{
* @readwrite
* @var string
protected $pattern;
* @var string[]
protected $fields = [];
* Applies the filter to the provided query
* @param QueryObjectInterface $query
* @return $this|self|QueryFilterInterface
public function apply(QueryObjectInterface $query)
if (empty($this->fields)) {
return $this;
}
$query->where(
[
array($this->getQueryCon... "%{$this->pattern}%"))
array<string,array<string,?>>
string
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->getQueryCondition() => [
':pattern' => "%{$this->pattern}%"
]
);
* Gets the query condition for provided fields
* @return string
protected function getQueryCondition()
$parts = [];
foreach ($this->fields as $field) {
$parts[] = "{$field} LIKE :pattern";
return implode(' AND ', $parts);
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: