Failed Conditions
Push — master ( a26426...65249a )
by Arnold
14:53 queued 04:44
created

Guard   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 32
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 11 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jasny\Controller;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
8
#[\Attribute]
9
abstract class Guard
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class Guard
Loading history...
10
{
11
    use Traits\Base,
12
        Traits\Header,
13
        Traits\Output,
14
        Traits\CheckRequest,
15
        Traits\CheckResponse;
16
17
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
18
     * @return void|null|ResponseInterface|$this
19
     */
20
    abstract public function process();
21
22
    /**
23
     * Invoke guard.
24
     *
25
     * @param ServerRequestInterface $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
26
     * @param ResponseInterface $response
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
27
     * @return ResponseInterface|null
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
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 */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
37
        $result = $this->process(...$args);
0 ignored issues
show
Unused Code introduced by
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;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $result === $this...getResponse() : $result could return the type Jasny\Controller\Guard which is incompatible with the type-hinted return Psr\Http\Message\ResponseInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
40
    }
41
}
42