1 | <?php |
||
25 | class BatchEndpointAction |
||
26 | { |
||
27 | /** |
||
28 | * @var HttpKernelInterface |
||
29 | */ |
||
30 | private $kernel; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $validKeys = [ |
||
36 | 'path', |
||
37 | 'method', |
||
38 | 'headers', |
||
39 | 'body', |
||
40 | ]; |
||
41 | |||
42 | /** |
||
43 | * @param HttpKernelInterface $kernel |
||
44 | */ |
||
45 | public function __construct(HttpKernelInterface $kernel) |
||
49 | |||
50 | /** |
||
51 | * Execute multiple subrequests from batch request. |
||
52 | * |
||
53 | * @param Request $request |
||
54 | * @param array $data |
||
55 | * |
||
56 | * @return array |
||
57 | */ |
||
58 | public function __invoke(Request $request, array $data = null): array |
||
91 | |||
92 | /** |
||
93 | * Converts a response into an array. |
||
94 | * |
||
95 | * @param Response $response |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | private function convertResponse(Response $response): array |
||
107 | |||
108 | /** |
||
109 | * Validates that the keys are all correctly present. |
||
110 | * |
||
111 | * @param array $data |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | private function validateBatchData(array $data) |
||
129 | |||
130 | /** |
||
131 | * Executes a subrequest. |
||
132 | * |
||
133 | * @param int $index |
||
134 | * @param string $path |
||
135 | * @param string $method |
||
136 | * @param array $headers |
||
137 | * @param string $body |
||
138 | * |
||
139 | * @return Response |
||
140 | */ |
||
141 | private function executeSubRequest(int $index, string $path, string $method, array $headers, string $body): Response |
||
152 | } |
||
153 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.