1 | <?php |
||
11 | abstract class AbstractResource |
||
12 | { |
||
13 | /** |
||
14 | * @var Request |
||
15 | */ |
||
16 | protected $request; |
||
17 | |||
18 | /** |
||
19 | * @var ActionCollection |
||
20 | */ |
||
21 | protected $actions = []; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $childResources = []; |
||
27 | |||
28 | /** |
||
29 | * AbstractResource constructor. |
||
30 | * @param Request $request |
||
31 | */ |
||
32 | 5 | public function __construct(Request $request) |
|
33 | { |
||
34 | 5 | $this->request = $request; |
|
35 | 5 | $this->actions = new ActionCollection(); |
|
36 | 5 | } |
|
37 | |||
38 | /** |
||
39 | * @param string $action |
||
40 | * @return ActionInterface |
||
41 | * @throws ClientException |
||
42 | */ |
||
43 | 133 | public function getAction(string $action): ActionInterface |
|
44 | { |
||
45 | 133 | return $this->actions->get($action); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return Request |
||
50 | */ |
||
51 | 1 | public function getRequest() |
|
55 | |||
56 | /** |
||
57 | * @param string $action |
||
58 | * @return bool |
||
59 | */ |
||
60 | 17 | public function hasAction(string $action): bool |
|
68 | |||
69 | /** |
||
70 | * @return array |
||
71 | */ |
||
72 | 5 | public function getChildResources(): array |
|
76 | |||
77 | /** |
||
78 | * @param string $action |
||
79 | * @param float|null $parentId |
||
80 | * @param float|null $childId |
||
81 | * @param float|null $childChildId |
||
82 | * @param array|null $parameters |
||
83 | * @return array|bool |
||
84 | */ |
||
85 | 133 | protected function request( |
|
102 | |||
103 | /** |
||
104 | * @param Action $action |
||
105 | * @param float|null $parentId |
||
106 | * @param float|null $childId |
||
107 | * @param float|null $childChildId |
||
108 | * @return string |
||
109 | * @throws ClientException |
||
110 | */ |
||
111 | 130 | protected function getEndpoint( |
|
119 | |||
120 | /** |
||
121 | * @param Action $action |
||
122 | * @param array $parameters |
||
123 | * @return array |
||
124 | */ |
||
125 | 130 | private function getRequestOptions(Action $action, array $parameters): array |
|
138 | |||
139 | /** |
||
140 | * @param string $method |
||
141 | * @param array|null $arguments |
||
142 | * @return array|bool |
||
143 | */ |
||
144 | 133 | public function __call(string $method, array $arguments = []) |
|
154 | |||
155 | /** |
||
156 | * @param array $arguments |
||
157 | * @return float|null |
||
158 | */ |
||
159 | 133 | private function getParentId(array $arguments) |
|
171 | |||
172 | /** |
||
173 | * @param array $arguments |
||
174 | * @return float|null |
||
175 | */ |
||
176 | 133 | private function getChildId(array $arguments) |
|
188 | |||
189 | /** |
||
190 | * @param array $arguments |
||
191 | * @return float|null |
||
192 | */ |
||
193 | 133 | private function getChildChildId(array $arguments) |
|
205 | |||
206 | /** |
||
207 | * @param array $arguments |
||
208 | * @return array |
||
209 | */ |
||
210 | 133 | private function getParameters(array $arguments): array |
|
220 | } |
||
221 |
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.