1 | <?php |
||
25 | class HttpCore extends Component implements HttpInterface |
||
26 | { |
||
27 | use BenchmarkTrait, MiddlewaresTrait; |
||
28 | |||
29 | /** |
||
30 | * @var EmitterInterface |
||
31 | */ |
||
32 | private $emitter = null; |
||
33 | |||
34 | /** |
||
35 | * Dispatcher endpoint. |
||
36 | * |
||
37 | * @var string|callable|null |
||
38 | */ |
||
39 | private $endpoint = null; |
||
40 | |||
41 | /** |
||
42 | * @invisible |
||
43 | * @var ContainerInterface |
||
44 | */ |
||
45 | protected $container = null; |
||
46 | |||
47 | /** |
||
48 | * @param callable|null|string $endpoint Default endpoint, Router in HttpDispatcher. |
||
49 | * @param array $middlewares Set of http middlewares to run on every request. |
||
50 | * @param ContainerInterface $container Https requests are executed in a container scopes. |
||
51 | */ |
||
52 | public function __construct( |
||
61 | |||
62 | /** |
||
63 | * @param EmitterInterface $emitter |
||
64 | * |
||
65 | * @return $this|self |
||
66 | */ |
||
67 | public function setEmitter(EmitterInterface $emitter): HttpCore |
||
73 | |||
74 | /** |
||
75 | * Set endpoint as callable function or invokable class name (will be resolved using container). |
||
76 | * |
||
77 | * @param callable|string $endpoint |
||
78 | * |
||
79 | * @return $this|self |
||
80 | */ |
||
81 | public function setEndpoint($endpoint): HttpCore |
||
87 | |||
88 | /** |
||
89 | * Pass request thought all http middlewares to appropriate endpoint. Default endpoint will be |
||
90 | * used as fallback. Can thrown an exception happen in internal code. |
||
91 | * |
||
92 | * @param Request $request |
||
93 | * @param Response $response |
||
94 | * |
||
95 | * @return Response |
||
96 | * |
||
97 | * @throws HttpException |
||
98 | */ |
||
99 | public function perform(Request $request, Response $response = null): Response |
||
126 | |||
127 | /** |
||
128 | * Running spiral as middleware. |
||
129 | * |
||
130 | * @param Request $request |
||
131 | * @param Response $response |
||
132 | * @param callable $next |
||
133 | * |
||
134 | * @return Response |
||
135 | * |
||
136 | * @throws HttpException |
||
137 | */ |
||
138 | public function __invoke(Request $request, Response $response, callable $next): Response |
||
156 | |||
157 | /** |
||
158 | * Dispatch response to client. |
||
159 | * |
||
160 | * @param Response $response |
||
161 | * |
||
162 | * @return null Specifically. |
||
163 | */ |
||
164 | public function dispatch(Response $response) |
||
174 | |||
175 | /** |
||
176 | * Create instance of initial response. |
||
177 | * |
||
178 | * @return Response |
||
179 | */ |
||
180 | protected function initResponse(): Response |
||
184 | |||
185 | /** |
||
186 | * Default endpoint. |
||
187 | * |
||
188 | * @return callable|null |
||
189 | */ |
||
190 | protected function getEndpoint() |
||
204 | } |
||
205 |
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.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.