These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\PathResolver; |
||
15 | |||
16 | use ApiPlatform\Core\Api\OperationTypeDeprecationHelper; |
||
17 | |||
18 | /** |
||
19 | * Resolves the custom operations path. |
||
20 | * |
||
21 | * @author Guilhem N. <[email protected]> |
||
22 | */ |
||
23 | final class CustomOperationPathResolver implements OperationPathResolverInterface |
||
24 | { |
||
25 | private $deferred; |
||
26 | |||
27 | public function __construct(OperationPathResolverInterface $deferred) |
||
28 | { |
||
29 | $this->deferred = $deferred; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function resolveOperationPath(string $resourceShortName, array $operation, $operationType/*, string $operationName = null*/): string |
||
36 | { |
||
37 | View Code Duplication | if (func_num_args() >= 4) { |
|
38 | $operationName = func_get_arg(3); |
||
39 | } else { |
||
40 | @trigger_error(sprintf('Method %s() will have a 4th `string $operationName` argument in version 3.0. Not defining it is deprecated since 2.1.', __METHOD__), E_USER_DEPRECATED); |
||
41 | |||
42 | $operationName = null; |
||
43 | } |
||
44 | |||
45 | if (isset($operation['path'])) { |
||
46 | return $operation['path']; |
||
47 | } |
||
48 | |||
49 | return $this->deferred->resolveOperationPath($resourceShortName, $operation, OperationTypeDeprecationHelper::getOperationType($operationType), $operationName); |
||
0 ignored issues
–
show
|
|||
50 | } |
||
51 | } |
||
52 |
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.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.