1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the API Platform project. |
||
5 | * |
||
6 | * (c) Kévin Dunglas <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace ApiPlatform\Core\Bridge\Doctrine\Orm\Filter; |
||
15 | |||
16 | use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface; |
||
17 | use Doctrine\ORM\QueryBuilder; |
||
18 | |||
19 | abstract class AbstractContextAwareFilter extends AbstractFilter implements ContextAwareFilterInterface |
||
20 | { |
||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null, array $context = []) |
||
25 | { |
||
26 | if (!isset($context['filters']) || !\is_array($context['filters'])) { |
||
27 | parent::apply($queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context); |
||
28 | |||
29 | return; |
||
30 | } |
||
31 | |||
32 | foreach ($context['filters'] as $property => $value) { |
||
33 | $this->filterProperty($this->denormalizePropertyName($property), $value, $queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | } |
||
36 | } |
||
37 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.