1 | <?php |
||
22 | class PlatesStrategy extends ApplicationStrategy implements StrategyInterface |
||
23 | { |
||
24 | use LayoutAwareTrait; |
||
25 | |||
26 | /** @var PlatesEngine $viewEngine */ |
||
27 | private $viewEngine; |
||
28 | |||
29 | /** @var NotFoundDecorator $notFoundDecorator */ |
||
30 | private $notFoundDecorator; |
||
31 | |||
32 | /** @var NotAllowedDecorator $notAllowedDecorator */ |
||
33 | private $notAllowedDecorator; |
||
34 | |||
35 | /** @var bool */ |
||
36 | private $i18nEnabled = false; |
||
37 | |||
38 | /** @var array */ |
||
39 | private $supportedLocales = []; |
||
40 | |||
41 | /** |
||
42 | * PlatesStrategy constructor. |
||
43 | * @param PlatesEngine $viewEngine |
||
44 | * @param NotFoundDecorator $notFound |
||
45 | * @param NotAllowedDecorator $notAllowed |
||
46 | * @param string $layout |
||
47 | */ |
||
48 | 9 | public function __construct(PlatesEngine $viewEngine, NotFoundDecorator $notFound, NotAllowedDecorator $notAllowed, string $layout) |
|
55 | |||
56 | /** |
||
57 | * @param bool $i18nEnabled |
||
58 | */ |
||
59 | 8 | public function setI18nEnabled(bool $i18nEnabled): void |
|
63 | |||
64 | /** |
||
65 | * @param array $locales |
||
66 | */ |
||
67 | 8 | public function setSupportedLocales(array $locales): void |
|
71 | |||
72 | |||
73 | /** |
||
74 | * Invoke the route callable based on the strategy. |
||
75 | * |
||
76 | * @param \League\Route\Route $route |
||
77 | * @param \Psr\Http\Message\ServerRequestInterface $request |
||
78 | * |
||
79 | * @return \Psr\Http\Message\ResponseInterface |
||
80 | */ |
||
81 | 4 | public function invokeRouteCallable(Route $route, ServerRequestInterface $request): ResponseInterface |
|
110 | |||
111 | /** |
||
112 | * @param ResponseInterface $response |
||
113 | * @param string $body |
||
114 | * @param int $status |
||
115 | * @return \Psr\Http\Message\MessageInterface|Response |
||
116 | */ |
||
117 | 3 | private function getResponseWithBodyAndStatus(Response $response, string $body, int $status = 200) |
|
125 | |||
126 | /** |
||
127 | * Get a middleware that will decorate a NotFoundException |
||
128 | * |
||
129 | * @param \League\Route\Http\Exception\NotFoundException $exception |
||
130 | * |
||
131 | * @return \Psr\Http\Server\MiddlewareInterface |
||
132 | */ |
||
133 | 1 | public function getNotFoundDecorator(NotFoundException $e): MiddlewareInterface |
|
137 | |||
138 | /** |
||
139 | * Get a middleware that will decorate a NotAllowedException |
||
140 | * |
||
141 | * @param \League\Route\Http\Exception\NotFoundException $e |
||
142 | * |
||
143 | * @return \Psr\Http\Server\MiddlewareInterface |
||
144 | */ |
||
145 | 1 | public function getMethodNotAllowedDecorator(MethodNotAllowedException $e): MiddlewareInterface |
|
149 | } |
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.