1 | <?php |
||
21 | class PlatesStrategy extends ApplicationStrategy implements StrategyInterface |
||
22 | { |
||
23 | use LayoutAwareTrait; |
||
24 | |||
25 | /** @var PlatesEngine $viewEngine */ |
||
26 | private $viewEngine; |
||
27 | |||
28 | /** @var NotFoundDecorator $notFoundDecorator */ |
||
29 | private $notFoundDecorator; |
||
30 | |||
31 | /** @var NotAllowedDecorator $notAllowedDecorator */ |
||
32 | private $notAllowedDecorator; |
||
33 | |||
34 | /** @var bool */ |
||
35 | private $i18nEnabled = false; |
||
36 | |||
37 | /** @var array */ |
||
38 | private $supportedLocales = []; |
||
39 | |||
40 | /** |
||
41 | * PlatesStrategy constructor. |
||
42 | * @param PlatesEngine $viewEngine |
||
43 | * @param NotFoundDecorator $notFound |
||
44 | * @param NotAllowedDecorator $notAllowed |
||
45 | * @param string $layout |
||
46 | */ |
||
47 | 3 | public function __construct(PlatesEngine $viewEngine, NotFoundDecorator $notFound, NotAllowedDecorator $notAllowed, string $layout) |
|
54 | |||
55 | /** |
||
56 | * @param bool $i18nEnabled |
||
57 | */ |
||
58 | 3 | public function setI18nEnabled(bool $i18nEnabled): void |
|
62 | |||
63 | /** |
||
64 | * @param array $locales |
||
65 | */ |
||
66 | 3 | public function setSupportedLocales(array $locales): void |
|
70 | |||
71 | |||
72 | /** |
||
73 | * Invoke the route callable based on the strategy. |
||
74 | * |
||
75 | * @param \League\Route\Route $route |
||
76 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
77 | * |
||
78 | * @return \Psr\Http\Message\ResponseInterface |
||
79 | */ |
||
80 | 1 | public function invokeRouteCallable(Route $route, ServerRequestInterface $request): ResponseInterface |
|
105 | |||
106 | /** |
||
107 | * @param ResponseInterface $response |
||
108 | * @return array|mixed |
||
109 | */ |
||
110 | 1 | private function getBody(ResponseInterface $response) |
|
128 | |||
129 | /** |
||
130 | * @param ResponseInterface $response |
||
131 | * @param string $body |
||
132 | * @param int $status |
||
133 | * @return \Psr\Http\Message\MessageInterface|Response |
||
134 | */ |
||
135 | 1 | private function getResponseWithBodyAndStatus(Response $response, string $body, int $status = 200) |
|
143 | |||
144 | /** |
||
145 | * Get a middleware that will decorate a NotFoundException |
||
146 | * |
||
147 | * @param \League\Route\Http\Exception\NotFoundException $exception |
||
148 | * |
||
149 | * @return \Psr\Http\Server\MiddlewareInterface |
||
150 | */ |
||
151 | 1 | public function getNotFoundDecorator(NotFoundException $e): MiddlewareInterface |
|
155 | |||
156 | /** |
||
157 | * Get a middleware that will decorate a NotAllowedException |
||
158 | * |
||
159 | * @param \League\Route\Http\Exception\NotFoundException $e |
||
160 | * |
||
161 | * @return \Psr\Http\Server\MiddlewareInterface |
||
162 | */ |
||
163 | public function getMethodNotAllowedDecorator(MethodNotAllowedException $e): MiddlewareInterface |
||
167 | } |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.