@@ -231,19 +231,19 @@ discard block |
||
231 | 231 | switch($sName) |
232 | 232 | { |
233 | 233 | // Set the methods to call before processing the request |
234 | - case '__before': |
|
235 | - $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
236 | - break; |
|
237 | - // Set the methods to call after processing the request |
|
238 | - case '__after': |
|
239 | - $this->setHookMethods($this->aAfterMethods, $xValue); |
|
240 | - break; |
|
241 | - // Set the attributes to inject in the callable object |
|
242 | - case '__di': |
|
243 | - $this->addDiOption($xValue); |
|
244 | - break; |
|
245 | - default: |
|
246 | - break; |
|
234 | + case '__before': |
|
235 | + $this->setHookMethods($this->aBeforeMethods, $xValue); |
|
236 | + break; |
|
237 | + // Set the methods to call after processing the request |
|
238 | + case '__after': |
|
239 | + $this->setHookMethods($this->aAfterMethods, $xValue); |
|
240 | + break; |
|
241 | + // Set the attributes to inject in the callable object |
|
242 | + case '__di': |
|
243 | + $this->addDiOption($xValue); |
|
244 | + break; |
|
245 | + default: |
|
246 | + break; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | { |
292 | 292 | switch($sOptionName) |
293 | 293 | { |
294 | - case 'excluded': |
|
295 | - if((bool)$xOptionValue) |
|
296 | - { |
|
297 | - $this->addProtectedMethods($sFunctionName); |
|
298 | - } |
|
299 | - break; |
|
300 | - // For databags, all the value are merged in a single array. |
|
301 | - case 'bags': |
|
302 | - $this->_addJsArrayOption($sFunctionName, $sOptionName, $xOptionValue); |
|
303 | - return; |
|
304 | - // For all the other options, including callback, only the last value is kept. |
|
305 | - case 'callback': |
|
306 | - default: |
|
307 | - $this->_setJsOption($sFunctionName, $sOptionName, $xOptionValue); |
|
294 | + case 'excluded': |
|
295 | + if((bool)$xOptionValue) |
|
296 | + { |
|
297 | + $this->addProtectedMethods($sFunctionName); |
|
298 | + } |
|
299 | + break; |
|
300 | + // For databags, all the value are merged in a single array. |
|
301 | + case 'bags': |
|
302 | + $this->_addJsArrayOption($sFunctionName, $sOptionName, $xOptionValue); |
|
303 | + return; |
|
304 | + // For all the other options, including callback, only the last value is kept. |
|
305 | + case 'callback': |
|
306 | + default: |
|
307 | + $this->_setJsOption($sFunctionName, $sOptionName, $xOptionValue); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 |
@@ -81,29 +81,29 @@ discard block |
||
81 | 81 | public function __construct(array $aOptions, array $aAnnotations) |
82 | 82 | { |
83 | 83 | [$bExcluded, $aAnnotationOptions, $aAnnotationProtected] = $aAnnotations; |
84 | - $this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false); |
|
85 | - if($this->bExcluded) |
|
84 | + $this->bExcluded = $bExcluded || (bool) ($aOptions['excluded'] ?? false); |
|
85 | + if ($this->bExcluded) |
|
86 | 86 | { |
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | 90 | $sSeparator = $aOptions['separator']; |
91 | - if($sSeparator === '_' || $sSeparator === '.') |
|
91 | + if ($sSeparator === '_' || $sSeparator === '.') |
|
92 | 92 | { |
93 | 93 | $this->sSeparator = $sSeparator; |
94 | 94 | } |
95 | 95 | $this->addProtectedMethods($aOptions['protected']); |
96 | 96 | $this->addProtectedMethods($aAnnotationProtected); |
97 | 97 | |
98 | - foreach($aOptions['functions'] as $sNames => $aFunctionOptions) |
|
98 | + foreach ($aOptions['functions'] as $sNames => $aFunctionOptions) |
|
99 | 99 | { |
100 | 100 | $aFunctionNames = explode(',', $sNames); // Names are in comma-separated list. |
101 | - foreach($aFunctionNames as $sFunctionName) |
|
101 | + foreach ($aFunctionNames as $sFunctionName) |
|
102 | 102 | { |
103 | 103 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
104 | 104 | } |
105 | 105 | } |
106 | - foreach($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
106 | + foreach ($aAnnotationOptions as $sFunctionName => $aFunctionOptions) |
|
107 | 107 | { |
108 | 108 | $this->addFunctionOptions($sFunctionName, $aFunctionOptions); |
109 | 109 | } |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | */ |
117 | 117 | private function addProtectedMethods($xMethods) |
118 | 118 | { |
119 | - if(!is_array($xMethods)) |
|
119 | + if (!is_array($xMethods)) |
|
120 | 120 | { |
121 | - $this->aProtectedMethods[trim((string)$xMethods)] = true; |
|
121 | + $this->aProtectedMethods[trim((string) $xMethods)] = true; |
|
122 | 122 | return; |
123 | 123 | } |
124 | - foreach($xMethods as $sMethod) |
|
124 | + foreach ($xMethods as $sMethod) |
|
125 | 125 | { |
126 | - $this->aProtectedMethods[trim((string)$sMethod)] = true; |
|
126 | + $this->aProtectedMethods[trim((string) $sMethod)] = true; |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function setHookMethods(array &$aHookMethods, $xValue) |
199 | 199 | { |
200 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
200 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
201 | 201 | { |
202 | - if(is_array($xMethodToCall)) |
|
202 | + if (is_array($xMethodToCall)) |
|
203 | 203 | { |
204 | 204 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
205 | 205 | } |
206 | - elseif(is_string($xMethodToCall)) |
|
206 | + elseif (is_string($xMethodToCall)) |
|
207 | 207 | { |
208 | 208 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
209 | 209 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | private function addOption(string $sName, $xValue) |
230 | 230 | { |
231 | - switch($sName) |
|
231 | + switch ($sName) |
|
232 | 232 | { |
233 | 233 | // Set the methods to call before processing the request |
234 | 234 | case '__before': |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | */ |
257 | 257 | private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue) |
258 | 258 | { |
259 | - if(is_string($xOptionValue)) |
|
259 | + if (is_string($xOptionValue)) |
|
260 | 260 | { |
261 | 261 | $xOptionValue = [$xOptionValue]; |
262 | 262 | } |
263 | - if(!is_array($xOptionValue)) |
|
263 | + if (!is_array($xOptionValue)) |
|
264 | 264 | { |
265 | 265 | return; // Do not save. |
266 | 266 | } |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | */ |
290 | 290 | private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue) |
291 | 291 | { |
292 | - switch($sOptionName) |
|
292 | + switch ($sOptionName) |
|
293 | 293 | { |
294 | 294 | case 'excluded': |
295 | - if((bool)$xOptionValue) |
|
295 | + if ((bool) $xOptionValue) |
|
296 | 296 | { |
297 | 297 | $this->addProtectedMethods($sFunctionName); |
298 | 298 | } |
@@ -316,12 +316,11 @@ discard block |
||
316 | 316 | */ |
317 | 317 | private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions) |
318 | 318 | { |
319 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
319 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
320 | 320 | { |
321 | 321 | substr($sOptionName, 0, 2) === '__' ? |
322 | 322 | // Options for PHP classes. They start with "__". |
323 | - $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : |
|
324 | - // Options for javascript code. |
|
323 | + $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code. |
|
325 | 324 | $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue); |
326 | 325 | } |
327 | 326 | } |
@@ -337,12 +336,11 @@ discard block |
||
337 | 336 | $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array |
338 | 337 | // Then add the method options. |
339 | 338 | $aMethodOptions = $this->aJsOptions[$sMethodName] ?? []; |
340 | - foreach($aMethodOptions as $sOptionName => $xOptionValue) |
|
339 | + foreach ($aMethodOptions as $sOptionName => $xOptionValue) |
|
341 | 340 | { |
342 | 341 | // For databags, merge the values in a single array. |
343 | 342 | // For all the other options, including callback, keep the last value. |
344 | - $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : |
|
345 | - array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
343 | + $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
346 | 344 | } |
347 | 345 | return $aOptions; |
348 | 346 | } |