@@ -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,17 +197,17 @@ 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(!isset($aHookMethods[$sCalledMethod])) |
|
| 202 | + if (!isset($aHookMethods[$sCalledMethod])) |
|
| 203 | 203 | { |
| 204 | 204 | $aHookMethods[$sCalledMethod] = []; |
| 205 | 205 | } |
| 206 | - if(is_array($xMethodToCall)) |
|
| 206 | + if (is_array($xMethodToCall)) |
|
| 207 | 207 | { |
| 208 | 208 | $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall); |
| 209 | 209 | } |
| 210 | - elseif(is_string($xMethodToCall)) |
|
| 210 | + elseif (is_string($xMethodToCall)) |
|
| 211 | 211 | { |
| 212 | 212 | $aHookMethods[$sCalledMethod][] = $xMethodToCall; |
| 213 | 213 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | private function addOption(string $sName, $xValue) |
| 234 | 234 | { |
| 235 | - switch($sName) |
|
| 235 | + switch ($sName) |
|
| 236 | 236 | { |
| 237 | 237 | // Set the methods to call before processing the request |
| 238 | 238 | case '__before': |
@@ -260,11 +260,11 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue) |
| 262 | 262 | { |
| 263 | - if(is_string($xOptionValue)) |
|
| 263 | + if (is_string($xOptionValue)) |
|
| 264 | 264 | { |
| 265 | 265 | $xOptionValue = [$xOptionValue]; |
| 266 | 266 | } |
| 267 | - if(!is_array($xOptionValue)) |
|
| 267 | + if (!is_array($xOptionValue)) |
|
| 268 | 268 | { |
| 269 | 269 | return; // Do not save. |
| 270 | 270 | } |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue) |
| 295 | 295 | { |
| 296 | - switch($sOptionName) |
|
| 296 | + switch ($sOptionName) |
|
| 297 | 297 | { |
| 298 | 298 | case 'excluded': |
| 299 | - if((bool)$xOptionValue) |
|
| 299 | + if ((bool) $xOptionValue) |
|
| 300 | 300 | { |
| 301 | 301 | $this->addProtectedMethods($sFunctionName); |
| 302 | 302 | } |
@@ -320,12 +320,11 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions) |
| 322 | 322 | { |
| 323 | - foreach($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 323 | + foreach ($aFunctionOptions as $sOptionName => $xOptionValue) |
|
| 324 | 324 | { |
| 325 | 325 | substr($sOptionName, 0, 2) === '__' ? |
| 326 | 326 | // Options for PHP classes. They start with "__". |
| 327 | - $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : |
|
| 328 | - // Options for javascript code. |
|
| 327 | + $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code. |
|
| 329 | 328 | $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue); |
| 330 | 329 | } |
| 331 | 330 | } |
@@ -341,12 +340,11 @@ discard block |
||
| 341 | 340 | $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array |
| 342 | 341 | // Then add the method options. |
| 343 | 342 | $aMethodOptions = $this->aJsOptions[$sMethodName] ?? []; |
| 344 | - foreach($aMethodOptions as $sOptionName => $xOptionValue) |
|
| 343 | + foreach ($aMethodOptions as $sOptionName => $xOptionValue) |
|
| 345 | 344 | { |
| 346 | 345 | // For databags, merge the values in a single array. |
| 347 | 346 | // For all the other options, including callback, keep the last value. |
| 348 | - $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : |
|
| 349 | - array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
| 347 | + $aOptions[$sOptionName] = $sOptionName !== 'bags' ? $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue)); |
|
| 350 | 348 | } |
| 351 | 349 | return $aOptions; |
| 352 | 350 | } |
@@ -206,8 +206,7 @@ |
||
| 206 | 206 | if(is_array($xMethodToCall)) |
| 207 | 207 | { |
| 208 | 208 | $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall); |
| 209 | - } |
|
| 210 | - elseif(is_string($xMethodToCall)) |
|
| 209 | + } elseif(is_string($xMethodToCall)) |
|
| 211 | 210 | { |
| 212 | 211 | $aHookMethods[$sCalledMethod][] = $xMethodToCall; |
| 213 | 212 | } |