Issues (4)

src/Guard.php (1 issue)

1
<?php
2
3
namespace Jasny\Controller;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
8
#[\Attribute]
9
abstract class Guard
10
{
11
    use Traits\Base,
12
        Traits\Header,
13
        Traits\Output,
14
        Traits\CheckRequest,
15
        Traits\CheckResponse;
16
17
    /**
18
     * @return void|null|ResponseInterface|$this
19
     */
20
    abstract public function process();
21
22
    /**
23
     * Invoke guard.
24
     *
25
     * @param ServerRequestInterface $request
26
     * @param ResponseInterface $response
27
     * @return ResponseInterface|null
28
     */
29
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ?ResponseInterface
30
    {
31
        $this->request = $request;
32
        $this->response = $response;
33
34
        $args = $this->getFunctionArgs(new \ReflectionMethod($this, 'process'));
35
36
        /** @noinspection PhpMethodParametersCountMismatchInspection */
37
        $result = $this->process(...$args);
0 ignored issues
show
The call to Jasny\Controller\Guard::process() has too many arguments starting with $args. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        /** @scrutinizer ignore-call */ 
38
        $result = $this->process(...$args);

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.

Loading history...
38
39
        return $result === $this ? $this->getResponse() : $result;
40
    }
41
}
42