@@ -173,36 +173,36 @@ discard block |
||
173 | 173 | switch($sName) |
174 | 174 | { |
175 | 175 | // Set the separator |
176 | - case 'separator': |
|
177 | - if($xValue === '_' || $xValue === '.') |
|
178 | - { |
|
179 | - $this->sSeparator = $xValue; |
|
180 | - } |
|
181 | - break; |
|
182 | - // Set the protected methods |
|
183 | - case 'protected': |
|
184 | - if(is_array($xValue)) |
|
185 | - { |
|
186 | - $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
|
187 | - } |
|
188 | - break; |
|
189 | - // Set the methods to call before processing the request |
|
190 | - case '__before': |
|
191 | - $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
192 | - break; |
|
193 | - // Set the methods to call after processing the request |
|
194 | - case '__after': |
|
195 | - $this->setHookMethods($this->aAfterMethods, $xValue); |
|
196 | - break; |
|
197 | - // Set the attributes to inject in the callable object |
|
198 | - case '__di': |
|
199 | - $this->addDiOption($xValue); |
|
200 | - break; |
|
201 | - case 'excluded': |
|
202 | - $this->bExcluded = (bool)$xValue; |
|
203 | - break; |
|
204 | - default: |
|
205 | - break; |
|
176 | + case 'separator': |
|
177 | + if($xValue === '_' || $xValue === '.') |
|
178 | + { |
|
179 | + $this->sSeparator = $xValue; |
|
180 | + } |
|
181 | + break; |
|
182 | + // Set the protected methods |
|
183 | + case 'protected': |
|
184 | + if(is_array($xValue)) |
|
185 | + { |
|
186 | + $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
|
187 | + } |
|
188 | + break; |
|
189 | + // Set the methods to call before processing the request |
|
190 | + case '__before': |
|
191 | + $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
192 | + break; |
|
193 | + // Set the methods to call after processing the request |
|
194 | + case '__after': |
|
195 | + $this->setHookMethods($this->aAfterMethods, $xValue); |
|
196 | + break; |
|
197 | + // Set the attributes to inject in the callable object |
|
198 | + case '__di': |
|
199 | + $this->addDiOption($xValue); |
|
200 | + break; |
|
201 | + case 'excluded': |
|
202 | + $this->bExcluded = (bool)$xValue; |
|
203 | + break; |
|
204 | + default: |
|
205 | + break; |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | switch($sOptionName) |
252 | 252 | { |
253 | 253 | // For databags, all the value are merged in a single array. |
254 | - case 'bags': |
|
255 | - $this->_addJsArrayOption($sFunctionName, $sOptionName, $xOptionValue); |
|
256 | - return; |
|
257 | - // For all the other options, including callback, only the last value is kept. |
|
258 | - case 'callback': |
|
259 | - default: |
|
260 | - $this->_setJsOption($sFunctionName, $sOptionName, $xOptionValue); |
|
254 | + case 'bags': |
|
255 | + $this->_addJsArrayOption($sFunctionName, $sOptionName, $xOptionValue); |
|
256 | + return; |
|
257 | + // For all the other options, including callback, only the last value is kept. |
|
258 | + case 'callback': |
|
259 | + default: |
|
260 | + $this->_setJsOption($sFunctionName, $sOptionName, $xOptionValue); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 |
@@ -186,8 +186,7 @@ |
||
186 | 186 | if(is_array($xMethodToCall)) |
187 | 187 | { |
188 | 188 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
189 | - } |
|
190 | - elseif(is_string($xMethodToCall)) |
|
189 | + } elseif(is_string($xMethodToCall)) |
|
191 | 190 | { |
192 | 191 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
193 | 192 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | public function __construct(array $aOptions, array $aAnnotations) |
81 | 81 | { |
82 | 82 | [$bExcluded, $aAnnotationOptions, $aAnnotationProtected] = $aAnnotations; |
83 | - $this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false); |
|
84 | - if($this->bExcluded) |
|
83 | + $this->bExcluded = $bExcluded || (bool) ($aOptions['excluded'] ?? false); |
|
84 | + if ($this->bExcluded) |
|
85 | 85 | { |
86 | 86 | return; |
87 | 87 | } |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | $this->addOption('separator', $aOptions['separator']); |
90 | 90 | $this->addOption('protected', array_merge($aOptions['protected'], $aAnnotationProtected)); |
91 | 91 | |
92 | - foreach($aOptions['functions'] as $sNames => $aFunctionOptions) |
|
92 | + foreach ($aOptions['functions'] as $sNames => $aFunctionOptions) |
|
93 | 93 | { |
94 | 94 | $aFunctionNames = explode(',', $sNames); // Names are in comma-separated list. |
95 | - foreach($aFunctionNames as $sFunctionName) |
|
95 | + foreach ($aFunctionNames as $sFunctionName) |
|
96 | 96 | { |
97 | 97 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
98 | 98 | } |
99 | 99 | } |
100 | - foreach($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
100 | + foreach ($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
101 | 101 | { |
102 | 102 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
103 | 103 | } |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function setHookMethods(array &$aHookMethods, $xValue) |
173 | 173 | { |
174 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
174 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
175 | 175 | { |
176 | - if(is_array($xMethodToCall)) |
|
176 | + if (is_array($xMethodToCall)) |
|
177 | 177 | { |
178 | 178 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
179 | 179 | } |
180 | - elseif(is_string($xMethodToCall)) |
|
180 | + elseif (is_string($xMethodToCall)) |
|
181 | 181 | { |
182 | 182 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
183 | 183 | } |
@@ -202,18 +202,18 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function addOption(string $sName, $xValue) |
204 | 204 | { |
205 | - switch($sName) |
|
205 | + switch ($sName) |
|
206 | 206 | { |
207 | 207 | // Set the separator |
208 | 208 | case 'separator': |
209 | - if($xValue === '_' || $xValue === '.') |
|
209 | + if ($xValue === '_' || $xValue === '.') |
|
210 | 210 | { |
211 | 211 | $this->sSeparator = $xValue; |
212 | 212 | } |
213 | 213 | break; |
214 | 214 | // Set the protected methods |
215 | 215 | case 'protected': |
216 | - if(is_array($xValue)) |
|
216 | + if (is_array($xValue)) |
|
217 | 217 | { |
218 | 218 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
219 | 219 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $this->addDiOption($xValue); |
232 | 232 | break; |
233 | 233 | case 'excluded': |
234 | - $this->bExcluded = (bool)$xValue; |
|
234 | + $this->bExcluded = (bool) $xValue; |
|
235 | 235 | break; |
236 | 236 | default: |
237 | 237 | break; |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | */ |
248 | 248 | private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue) |
249 | 249 | { |
250 | - if(is_string($xOptionValue)) |
|
250 | + if (is_string($xOptionValue)) |
|
251 | 251 | { |
252 | 252 | $xOptionValue = [$xOptionValue]; |
253 | 253 | } |
254 | - if(!is_array($xOptionValue)) |
|
254 | + if (!is_array($xOptionValue)) |
|
255 | 255 | { |
256 | 256 | return; // Do not save. |
257 | 257 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | */ |
281 | 281 | private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue) |
282 | 282 | { |
283 | - switch($sOptionName) |
|
283 | + switch ($sOptionName) |
|
284 | 284 | { |
285 | 285 | // For databags, all the value are merged in a single array. |
286 | 286 | case 'bags': |
@@ -301,12 +301,11 @@ discard block |
||
301 | 301 | */ |
302 | 302 | private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions) |
303 | 303 | { |
304 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
304 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
305 | 305 | { |
306 | 306 | substr($sOptionName, 0, 2) === '__' ? |
307 | 307 | // Options for PHP classes. They start with "__". |
308 | - $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : |
|
309 | - // Options for javascript code. |
|
308 | + $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code. |
|
310 | 309 | $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue); |
311 | 310 | } |
312 | 311 | } |
@@ -322,12 +321,11 @@ discard block |
||
322 | 321 | $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array |
323 | 322 | // Then add the method options. |
324 | 323 | $aMethodOptions = $this->aJsOptions[$sMethodName] ?? []; |
325 | - foreach($aMethodOptions as $sOptionName => $xOptionValue) |
|
324 | + foreach ($aMethodOptions as $sOptionName => $xOptionValue) |
|
326 | 325 | { |
327 | 326 | // For databags, merge the values in a single array. |
328 | 327 | // For all the other options, including callback, keep the last value. |
329 | - $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : |
|
330 | - array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
328 | + $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
331 | 329 | } |
332 | 330 | return $aOptions; |
333 | 331 | } |
@@ -298,11 +298,11 @@ |
||
298 | 298 | $sMethod = $this->xTarget->getMethodName(); |
299 | 299 | // The hooks defined at method level are merged with those defined at class level. |
300 | 300 | $aMethods = array_merge($aHookMethods['*'] ?? [], $aHookMethods[$sMethod] ?? []); |
301 | - foreach($aMethods as $xKey => $xValue) |
|
301 | + foreach ($aMethods as $xKey => $xValue) |
|
302 | 302 | { |
303 | 303 | $sHookName = $xValue; |
304 | 304 | $aHookArgs = []; |
305 | - if(is_string($xKey)) |
|
305 | + if (is_string($xKey)) |
|
306 | 306 | { |
307 | 307 | $sHookName = $xKey; |
308 | 308 | $aHookArgs = is_array($xValue) ? $xValue : [$xValue]; |