Issues (11)

WebPresentation/FrontController/FrontCommand.php (3 issues)

1
<?php
2
3
declare(strict_types = 1);
4
5
namespace WebPresentation\FrontController;
6
7
use WebPresentation\Forward;
8
use Psr\Http\Message\ResponseInterface as Response;
9
use Psr\Http\Message\ServerRequestInterface as ServerRequest;
10
11
abstract class FrontCommand
12
{
13
    protected ?ServerRequest $request = null;
14
15
    protected ?Response $response = null;
16
17
    abstract public function process(): void;
18
19 1
    public function init(ServerRequest $request, Response $response)
20
    {
21 1
        $this->request = $request;
22 1
        $this->response = $response;
23 1
    }
24
25 1
    public function getResponse(): Response
26
    {
27 1
        return $this->response;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->response could return the type null which is incompatible with the type-hinted return Psr\Http\Message\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
28
    }
29
30 1
    protected function forward(string $target): void
31
    {
32 1
        $f = new Forward($this->request, $this->response);
0 ignored issues
show
It seems like $this->response can also be of type null; however, parameter $response of WebPresentation\Forward::__construct() does only seem to accept Psr\Http\Message\ResponseInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

32
        $f = new Forward($this->request, /** @scrutinizer ignore-type */ $this->response);
Loading history...
It seems like $this->request can also be of type null; however, parameter $request of WebPresentation\Forward::__construct() does only seem to accept Psr\Http\Message\ServerRequestInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

32
        $f = new Forward(/** @scrutinizer ignore-type */ $this->request, $this->response);
Loading history...
33
34 1
        $this->response = $f->sendResponse($target);
35 1
    }
36
}
37