1 | <?php |
||
17 | class Router implements \SplObserver |
||
18 | { |
||
19 | /** |
||
20 | * @const ERR_TARGET_NOT_DECLARED : Error code if the target has not |
||
21 | * been declared |
||
22 | */ |
||
23 | const ERR_TARGET_NOT_DECLARED = 2001001; |
||
24 | |||
25 | /** |
||
26 | * @var \BFW\Module $module The bfw module instance for this module |
||
27 | */ |
||
28 | protected $module; |
||
29 | |||
30 | /** |
||
31 | * @var \BFW\Config $config The bfw config instance for this module |
||
32 | */ |
||
33 | protected $config; |
||
34 | |||
35 | /** |
||
36 | * @var \stdClass|null $ctrlRouterInfos The context object passed to |
||
37 | * subject for the action "searchRoute". |
||
38 | */ |
||
39 | protected $ctrlRouterInfos; |
||
40 | |||
41 | /** |
||
42 | * @var \FastRoute\Dispatcher $dispatcher FastRoute dispatcher |
||
43 | */ |
||
44 | protected $dispatcher; |
||
45 | |||
46 | /** |
||
47 | * Constructor |
||
48 | * Get config and linker instance |
||
49 | * Call fastRoute dispatcher |
||
50 | * |
||
51 | * @param \BFW\Module $module |
||
52 | */ |
||
53 | public function __construct(\BFW\Module $module) |
||
63 | |||
64 | /** |
||
65 | * Getter accessor for module property |
||
66 | * |
||
67 | * @return \BFW\Module |
||
68 | */ |
||
69 | public function getModule() |
||
73 | |||
74 | /** |
||
75 | * Getter accessor for config property |
||
76 | * |
||
77 | * @return \BFW\Config |
||
78 | */ |
||
79 | public function getConfig() |
||
83 | |||
84 | /** |
||
85 | * Getter accessor for ctrlRouterInfos property |
||
86 | * |
||
87 | * @return \stdClass |
||
88 | */ |
||
89 | public function getCtrlRouterInfos() |
||
93 | |||
94 | /** |
||
95 | * Getter accessor for dispatcher property |
||
96 | * |
||
97 | * @return \FastRoute\Dispatcher |
||
98 | */ |
||
99 | public function getDispatcher() |
||
103 | |||
104 | /** |
||
105 | * Observer update method |
||
106 | * Call obtainCurrentRoute method on action "apprun_loadAllAppModules". |
||
107 | * |
||
108 | * @param \SplSubject $subject |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | public function update(\SplSubject $subject) |
||
128 | |||
129 | /** |
||
130 | * Set the property ctrlRouterInfos with the context object obtain linked |
||
131 | * to the subject. |
||
132 | * Allow override to get only some part. And used for unit test. |
||
133 | * |
||
134 | * @param \BFW\Subject $subject |
||
135 | * |
||
136 | * @return void |
||
137 | */ |
||
138 | protected function obtainCtrlRouterInfos($subject) |
||
142 | |||
143 | /** |
||
144 | * Call by dispatcher; Add route in config to fastRoute router |
||
145 | * |
||
146 | * @param FastRoute\RouteCollector $router FastRoute router |
||
147 | * |
||
148 | * @return void |
||
149 | */ |
||
150 | public function addRoutesToCollector(FastRoute\RouteCollector $router) |
||
170 | |||
171 | /** |
||
172 | * Obtain informations about the current route from fastRoute dispatcher |
||
173 | * |
||
174 | * @return void |
||
175 | */ |
||
176 | protected function searchRoute() |
||
214 | |||
215 | /** |
||
216 | * Get http status for response from dispatcher |
||
217 | * |
||
218 | * @param int $routeStatus : Route status send by dispatcher for request |
||
219 | * |
||
220 | * @return int |
||
221 | */ |
||
222 | protected function checkStatus($routeStatus) |
||
234 | |||
235 | /** |
||
236 | * Update ctrlRouterInfos properties isFound and forWho |
||
237 | * |
||
238 | * @return void |
||
239 | */ |
||
240 | protected function addInfosToCtrlRouter() |
||
248 | |||
249 | /** |
||
250 | * Obtains route informations from config file and send this informations |
||
251 | * to the controller/router linker |
||
252 | * |
||
253 | * @param array $routeInfos : Route information from config file |
||
254 | * |
||
255 | * @return void |
||
256 | * |
||
257 | * @throws \Exception If target not define in config file |
||
258 | */ |
||
259 | protected function addTargetToCtrlRouter(array $routeInfos) |
||
270 | |||
271 | /** |
||
272 | * Add datas into a superglobal var |
||
273 | * |
||
274 | * @param string $globalVarName : Name of the superglobal var |
||
275 | * @param array $datasToAdd : Datas to add to $_GET var |
||
276 | * |
||
277 | * @return void |
||
278 | */ |
||
279 | protected function addToSuperglobalVar($globalVarName, array $datasToAdd) |
||
284 | |||
285 | /** |
||
286 | * If property 'get' has been declared into current route config, add |
||
287 | * them into superglobal $_GET . |
||
288 | * |
||
289 | * @param array $routeInfos route informations declared in config |
||
290 | * |
||
291 | * @return void |
||
292 | */ |
||
293 | protected function addDatasToGetVar(array $routeInfos) |
||
299 | } |
||
300 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: