@@ -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]; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | // The methods of the CallableClass class must not be exported |
| 112 | 112 | $xCallableClass = new ReflectionClass(CallableClass::class); |
| 113 | - foreach($xCallableClass->getMethods(ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 113 | + foreach ($xCallableClass->getMethods(ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
| 114 | 114 | { |
| 115 | 115 | $this->aProtectedMethods[] = $xMethod->getName(); |
| 116 | 116 | } |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | public function makeClassOptions(string $sClassName, array $aClassOptions, array $aDirectoryOptions): array |
| 183 | 183 | { |
| 184 | - foreach($this->aDefaultClassOptions as $sOption => $xValue) |
|
| 184 | + foreach ($this->aDefaultClassOptions as $sOption => $xValue) |
|
| 185 | 185 | { |
| 186 | - if(!isset($aClassOptions[$sOption])) |
|
| 186 | + if (!isset($aClassOptions[$sOption])) |
|
| 187 | 187 | { |
| 188 | 188 | $aClassOptions[$sOption] = $xValue; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | - $aClassOptions['excluded'] = (bool)($aClassOptions['excluded'] ?? false); // Convert to bool. |
|
| 192 | - if(is_string($aClassOptions['protected'])) |
|
| 191 | + $aClassOptions['excluded'] = (bool) ($aClassOptions['excluded'] ?? false); // Convert to bool. |
|
| 192 | + if (is_string($aClassOptions['protected'])) |
|
| 193 | 193 | { |
| 194 | 194 | $aClassOptions['protected'] = [$aClassOptions['protected']]; // Convert to array. |
| 195 | 195 | } |
@@ -200,25 +200,25 @@ discard block |
||
| 200 | 200 | $aDirectoryOptions['classes']['*'] ?? [], // Options for all classes |
| 201 | 201 | $aDirectoryOptions['classes'][$sClassName] ?? [], // Options for this specific class |
| 202 | 202 | ]; |
| 203 | - foreach($aOptionGroups as $aOptionGroup) |
|
| 203 | + foreach ($aOptionGroups as $aOptionGroup) |
|
| 204 | 204 | { |
| 205 | - if(isset($aOptionGroup['separator'])) |
|
| 205 | + if (isset($aOptionGroup['separator'])) |
|
| 206 | 206 | { |
| 207 | - $aClassOptions['separator'] = (string)$aOptionGroup['separator']; |
|
| 207 | + $aClassOptions['separator'] = (string) $aOptionGroup['separator']; |
|
| 208 | 208 | } |
| 209 | - if(isset($aOptionGroup['excluded'])) |
|
| 209 | + if (isset($aOptionGroup['excluded'])) |
|
| 210 | 210 | { |
| 211 | - $aClassOptions['excluded'] = (bool)$aOptionGroup['excluded']; |
|
| 211 | + $aClassOptions['excluded'] = (bool) $aOptionGroup['excluded']; |
|
| 212 | 212 | } |
| 213 | - if(isset($aOptionGroup['protected'])) |
|
| 213 | + if (isset($aOptionGroup['protected'])) |
|
| 214 | 214 | { |
| 215 | - if(is_string($aOptionGroup['protected'])) |
|
| 215 | + if (is_string($aOptionGroup['protected'])) |
|
| 216 | 216 | { |
| 217 | 217 | $aOptionGroup['protected'] = [$aOptionGroup['protected']]; // Convert to array. |
| 218 | 218 | } |
| 219 | 219 | $aClassOptions['protected'] = array_merge($aClassOptions['protected'], $aOptionGroup['protected']); |
| 220 | 220 | } |
| 221 | - if(isset($aOptionGroup['functions'])) |
|
| 221 | + if (isset($aOptionGroup['functions'])) |
|
| 222 | 222 | { |
| 223 | 223 | $aClassOptions['functions'] = array_merge($aClassOptions['functions'], $aOptionGroup['functions']); |
| 224 | 224 | } |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | private function getNamespaceClassOptions(string $sClassName) |
| 265 | 265 | { |
| 266 | 266 | // Find the corresponding namespace |
| 267 | - foreach($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 267 | + foreach ($this->aNamespaceOptions as $sNamespace => $aOptions) |
|
| 268 | 268 | { |
| 269 | 269 | // Check if the namespace matches the class. |
| 270 | - if(strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0) |
|
| 270 | + if (strncmp($sClassName, $sNamespace . '\\', strlen($sNamespace) + 1) === 0) |
|
| 271 | 271 | { |
| 272 | 272 | // Save the class options |
| 273 | 273 | $this->aClasses[$sClassName] = $this->makeClassOptions($sClassName, |
@@ -288,17 +288,17 @@ discard block |
||
| 288 | 288 | public function getClassOptions(string $sClassName): array |
| 289 | 289 | { |
| 290 | 290 | // Find options for a class registered with namespace. |
| 291 | - if(!isset($this->aClasses[$sClassName])) |
|
| 291 | + if (!isset($this->aClasses[$sClassName])) |
|
| 292 | 292 | { |
| 293 | 293 | $this->getNamespaceClassOptions($sClassName); |
| 294 | - if(!isset($this->aClasses[$sClassName])) |
|
| 294 | + if (!isset($this->aClasses[$sClassName])) |
|
| 295 | 295 | { |
| 296 | 296 | // Find options for a class registered without namespace. |
| 297 | 297 | // We then need to parse all classes to be able to find one. |
| 298 | 298 | $this->di->getCallableRegistry()->parseDirectories(); |
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | - if(isset($this->aClasses[$sClassName])) |
|
| 301 | + if (isset($this->aClasses[$sClassName])) |
|
| 302 | 302 | { |
| 303 | 303 | return $this->aClasses[$sClassName]; |
| 304 | 304 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | public function getCallableObjects(): array |
| 328 | 328 | { |
| 329 | 329 | $aCallableObjects = []; |
| 330 | - foreach($this->aClasses as $sClassName => $aOptions) |
|
| 330 | + foreach ($this->aClasses as $sClassName => $aOptions) |
|
| 331 | 331 | { |
| 332 | 332 | $this->di->registerCallableClass($sClassName, $aOptions); |
| 333 | 333 | $aCallableObjects[$sClassName] = $this->di->getCallableObject($sClassName); |
@@ -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,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 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public function set(string $sClass, Closure $xClosure) |
| 216 | 216 | { |
| 217 | - $this->xLibContainer->offsetSet($sClass, function() use($xClosure) { |
|
| 217 | + $this->xLibContainer->offsetSet($sClass, function() use($xClosure) { |
|
| 218 | 218 | return $xClosure($this); |
| 219 | 219 | }); |
| 220 | 220 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function val(string $sKey, $xValue) |
| 231 | 231 | { |
| 232 | - $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 232 | + $this->xLibContainer->offsetSet($sKey, $xValue); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function has(string $sClass): bool |
| 159 | 159 | { |
| 160 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 160 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 161 | 161 | { |
| 162 | 162 | return true; |
| 163 | 163 | } |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 191 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
| 192 | 192 | { |
| 193 | 193 | return $this->xAppContainer->get($sClass); |
| 194 | 194 | } |
| 195 | 195 | return $this->xLibContainer->offsetGet($sClass); |
| 196 | 196 | } |
| 197 | - catch(Exception|Throwable $e) |
|
| 197 | + catch (Exception | Throwable $e) |
|
| 198 | 198 | { |
| 199 | 199 | $xLogger = $this->g(LoggerInterface::class); |
| 200 | 200 | $xTranslator = $this->g(Translator::class); |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $xType = $xParameter->getType(); |
| 260 | 260 | // Check the parameter class first. |
| 261 | - if($xType instanceof ReflectionNamedType) |
|
| 261 | + if ($xType instanceof ReflectionNamedType) |
|
| 262 | 262 | { |
| 263 | 263 | // Check the class + the name |
| 264 | - if($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
| 264 | + if ($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
| 265 | 265 | { |
| 266 | 266 | return $this->get($xType->getName() . ' $' . $xParameter->getName()); |
| 267 | 267 | } |
| 268 | 268 | // Check the class only |
| 269 | - if($this->get($xType->getName())) |
|
| 269 | + if ($this->get($xType->getName())) |
|
| 270 | 270 | { |
| 271 | 271 | return $this->get($xType->getName()); |
| 272 | 272 | } |
@@ -286,16 +286,16 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | public function make($xClass) |
| 288 | 288 | { |
| 289 | - if(is_string($xClass)) |
|
| 289 | + if (is_string($xClass)) |
|
| 290 | 290 | { |
| 291 | 291 | $xClass = new ReflectionClass($xClass); // Create the reflection class instance |
| 292 | 292 | } |
| 293 | - if(!($xClass instanceof ReflectionClass)) |
|
| 293 | + if (!($xClass instanceof ReflectionClass)) |
|
| 294 | 294 | { |
| 295 | 295 | return null; |
| 296 | 296 | } |
| 297 | 297 | // Use the Reflection class to get the parameters of the constructor |
| 298 | - if(($constructor = $xClass->getConstructor()) === null) |
|
| 298 | + if (($constructor = $xClass->getConstructor()) === null) |
|
| 299 | 299 | { |
| 300 | 300 | return $xClass->newInstance(); |
| 301 | 301 | } |
@@ -193,8 +193,7 @@ |
||
| 193 | 193 | return $this->xAppContainer->get($sClass); |
| 194 | 194 | } |
| 195 | 195 | return $this->xLibContainer->offsetGet($sClass); |
| 196 | - } |
|
| 197 | - catch(Exception|Throwable $e) |
|
| 196 | + } catch(Exception|Throwable $e) |
|
| 198 | 197 | { |
| 199 | 198 | $xLogger = $this->g(LoggerInterface::class); |
| 200 | 199 | $xTranslator = $this->g(Translator::class); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $this->xUploadHandler = $this->di->getUploadHandler(); |
| 109 | 109 | |
| 110 | 110 | // Return true if the request plugin was already found |
| 111 | - if($this->xRequestPlugin !== null) |
|
| 111 | + if ($this->xRequestPlugin !== null) |
|
| 112 | 112 | { |
| 113 | 113 | return true; |
| 114 | 114 | } |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | // The HTTP request |
| 117 | 117 | $xRequest = $this->di->getRequest(); |
| 118 | 118 | // Find a plugin to process the request |
| 119 | - foreach($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
| 119 | + foreach ($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
| 120 | 120 | { |
| 121 | - if($sClassName::canProcessRequest($xRequest)) |
|
| 121 | + if ($sClassName::canProcessRequest($xRequest)) |
|
| 122 | 122 | { |
| 123 | 123 | $this->xRequestPlugin = $this->di->g($sClassName); |
| 124 | 124 | $this->xRequestPlugin->setTarget($xRequest); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Check if the upload plugin is enabled |
| 130 | - if($this->xUploadHandler === null) |
|
| 130 | + if ($this->xUploadHandler === null) |
|
| 131 | 131 | { |
| 132 | 132 | return false; |
| 133 | 133 | } |
@@ -149,15 +149,15 @@ discard block |
||
| 149 | 149 | // The HTTP request |
| 150 | 150 | $xRequest = $this->di->getRequest(); |
| 151 | 151 | // Process uploaded files, if the upload plugin is enabled |
| 152 | - if($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
| 152 | + if ($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
| 153 | 153 | { |
| 154 | 154 | $this->xUploadHandler->processRequest($xRequest); |
| 155 | 155 | } |
| 156 | 156 | // Process the request |
| 157 | - if(($this->xRequestPlugin)) |
|
| 157 | + if (($this->xRequestPlugin)) |
|
| 158 | 158 | { |
| 159 | 159 | $xResponse = $this->xRequestPlugin->processRequest(); |
| 160 | - if(($xResponse)) |
|
| 160 | + if (($xResponse)) |
|
| 161 | 161 | { |
| 162 | 162 | $this->xResponseManager->append($xResponse); |
| 163 | 163 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function processRequest() |
| 179 | 179 | { |
| 180 | 180 | // Check if there is a plugin to process this request |
| 181 | - if(!$this->canProcessRequest()) |
|
| 181 | + if (!$this->canProcessRequest()) |
|
| 182 | 182 | { |
| 183 | 183 | return; |
| 184 | 184 | } |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | { |
| 188 | 188 | $bEndRequest = false; |
| 189 | 189 | // Handle before processing event |
| 190 | - if(($this->xRequestPlugin)) |
|
| 190 | + if (($this->xRequestPlugin)) |
|
| 191 | 191 | { |
| 192 | 192 | $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest); |
| 193 | 193 | } |
| 194 | - if($bEndRequest) |
|
| 194 | + if ($bEndRequest) |
|
| 195 | 195 | { |
| 196 | 196 | return; |
| 197 | 197 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $this->_processRequest(); |
| 200 | 200 | |
| 201 | 201 | // Handle after processing event |
| 202 | - if(($this->xRequestPlugin)) |
|
| 202 | + if (($this->xRequestPlugin)) |
|
| 203 | 203 | { |
| 204 | 204 | $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest); |
| 205 | 205 | } |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | // An exception was thrown while processing the request. |
| 208 | 208 | // The request missed the corresponding handler function, |
| 209 | 209 | // or an error occurred while attempting to execute the handler. |
| 210 | - catch(RequestException $e) |
|
| 210 | + catch (RequestException $e) |
|
| 211 | 211 | { |
| 212 | 212 | $this->xResponseManager->error($e->getMessage()); |
| 213 | 213 | $this->xCallbackManager->onInvalid($e); |
| 214 | 214 | } |
| 215 | - catch(Exception $e) |
|
| 215 | + catch (Exception $e) |
|
| 216 | 216 | { |
| 217 | 217 | $this->xResponseManager->error($e->getMessage()); |
| 218 | 218 | $this->xCallbackManager->onError($e); |
@@ -211,8 +211,7 @@ |
||
| 211 | 211 | { |
| 212 | 212 | $this->xResponseManager->error($e->getMessage()); |
| 213 | 213 | $this->xCallbackManager->onInvalid($e); |
| 214 | - } |
|
| 215 | - catch(Exception $e) |
|
| 214 | + } catch(Exception $e) |
|
| 216 | 215 | { |
| 217 | 216 | $this->xResponseManager->error($e->getMessage()); |
| 218 | 217 | $this->xCallbackManager->onError($e); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function popBootCallbacks(): array |
| 101 | 101 | { |
| 102 | - if(empty($this->aBootCallbacks)) |
|
| 102 | + if (empty($this->aBootCallbacks)) |
|
| 103 | 103 | { |
| 104 | 104 | return []; |
| 105 | 105 | } |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | private function getExceptionCallbacks(Exception $xException): array |
| 119 | 119 | { |
| 120 | 120 | $aExceptionCallbacks = []; |
| 121 | - foreach($this->aExceptionCallbacks as $sExClass => $aCallbacks) |
|
| 121 | + foreach ($this->aExceptionCallbacks as $sExClass => $aCallbacks) |
|
| 122 | 122 | { |
| 123 | - if(is_a($xException, $sExClass)) |
|
| 123 | + if (is_a($xException, $sExClass)) |
|
| 124 | 124 | { |
| 125 | 125 | $aExceptionCallbacks = array_merge($aExceptionCallbacks, $aCallbacks); |
| 126 | 126 | } |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function error(callable $xCallable, string $sExClass = ''): CallbackManager |
| 192 | 192 | { |
| 193 | - if($sExClass === '' || $sExClass === Exception::class) |
|
| 193 | + if ($sExClass === '' || $sExClass === Exception::class) |
|
| 194 | 194 | { |
| 195 | 195 | $this->aErrorCallbacks[] = $xCallable; |
| 196 | 196 | return $this; |
| 197 | 197 | } |
| 198 | 198 | // Callback for a given exception class |
| 199 | - if(isset($this->aExceptionCallbacks[$sExClass])) |
|
| 199 | + if (isset($this->aExceptionCallbacks[$sExClass])) |
|
| 200 | 200 | { |
| 201 | 201 | $this->aExceptionCallbacks[$sExClass][] = $xCallable; |
| 202 | 202 | return $this; |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | private function executeCallback(callable $xCallback, array $aParameters) |
| 228 | 228 | { |
| 229 | 229 | $xReturn = call_user_func_array($xCallback, $aParameters); |
| 230 | - if($xReturn instanceof ResponseInterface) |
|
| 230 | + if ($xReturn instanceof ResponseInterface) |
|
| 231 | 231 | { |
| 232 | 232 | $this->xResponseManager->append($xReturn); |
| 233 | 233 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | private function executeCallbacks(array $aCallbacks, array $aParameters) |
| 243 | 243 | { |
| 244 | - foreach($aCallbacks as $xCallback) |
|
| 244 | + foreach ($aCallbacks as $xCallback) |
|
| 245 | 245 | { |
| 246 | 246 | $this->executeCallback($xCallback, $aParameters); |
| 247 | 247 | } |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | public function onBefore(Target $xTarget, bool &$bEndRequest) |
| 272 | 272 | { |
| 273 | 273 | // Call the user defined callback |
| 274 | - foreach($this->aBeforeCallbacks as $xCallback) |
|
| 274 | + foreach ($this->aBeforeCallbacks as $xCallback) |
|
| 275 | 275 | { |
| 276 | 276 | $this->executeCallback($xCallback, [$xTarget, &$bEndRequest]); |
| 277 | - if($bEndRequest) |
|
| 277 | + if ($bEndRequest) |
|
| 278 | 278 | { |
| 279 | 279 | return; |
| 280 | 280 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | { |
| 322 | 322 | $aExceptionCallbacks = $this->getExceptionCallbacks($xException); |
| 323 | 323 | $this->executeCallbacks($aExceptionCallbacks, [$xException]); |
| 324 | - if(count($aExceptionCallbacks) > 0) |
|
| 324 | + if (count($aExceptionCallbacks) > 0) |
|
| 325 | 325 | { |
| 326 | 326 | // Do not throw the exception if a custom handler is defined |
| 327 | 327 | return; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function getOutput(): string |
| 84 | 84 | { |
| 85 | - if($this->getCommandCount() === 0) |
|
| 85 | + if ($this->getCommandCount() === 0) |
|
| 86 | 86 | { |
| 87 | 87 | return '{}'; |
| 88 | 88 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function toPsr(): PsrResponseInterface |
| 153 | 153 | { |
| 154 | 154 | $xPsrResponse = $this->xPsr17Factory->createResponse(200); |
| 155 | - if($this->xRequest->getMethod() === 'GET') |
|
| 155 | + if ($this->xRequest->getMethod() === 'GET') |
|
| 156 | 156 | { |
| 157 | 157 | $xPsrResponse = $xPsrResponse |
| 158 | 158 | ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT') |
@@ -63,8 +63,7 @@ discard block |
||
| 63 | 63 | public function appendCommands(array $aCommands, bool $bBefore = false) |
| 64 | 64 | { |
| 65 | 65 | $this->aCommands = ($bBefore) ? |
| 66 | - array_merge($aCommands, $this->aCommands) : |
|
| 67 | - array_merge($this->aCommands, $aCommands); |
|
| 66 | + array_merge($aCommands, $this->aCommands) : array_merge($this->aCommands, $aCommands); |
|
| 68 | 67 | } |
| 69 | 68 | |
| 70 | 69 | /** |
@@ -107,7 +106,7 @@ discard block |
||
| 107 | 106 | public function addCommand(array $aAttributes, $mData): ResponseInterface |
| 108 | 107 | { |
| 109 | 108 | $aAttributes = array_map(function($xAttribute) { |
| 110 | - return is_integer($xAttribute) ? $xAttribute : trim((string)$xAttribute, " \t"); |
|
| 109 | + return is_integer($xAttribute) ? $xAttribute : trim((string) $xAttribute, " \t"); |
|
| 111 | 110 | }, $aAttributes); |
| 112 | 111 | return $this->addRawCommand($aAttributes, $mData); |
| 113 | 112 | } |
@@ -126,9 +125,9 @@ discard block |
||
| 126 | 125 | $mData, bool $bRemoveEmpty = false): ResponseInterface |
| 127 | 126 | { |
| 128 | 127 | $mData = is_array($mData) ? array_map(function($sData) { |
| 129 | - return trim((string)$sData, " \t\n"); |
|
| 130 | - }, $mData) : trim((string)$mData, " \t\n"); |
|
| 131 | - if($bRemoveEmpty) |
|
| 128 | + return trim((string) $sData, " \t\n"); |
|
| 129 | + }, $mData) : trim((string) $mData, " \t\n"); |
|
| 130 | + if ($bRemoveEmpty) |
|
| 132 | 131 | { |
| 133 | 132 | $aAttributes = array_filter($aAttributes, function($xValue) { |
| 134 | 133 | return $xValue === ''; |
@@ -124,17 +124,17 @@ |
||
| 124 | 124 | public function render(Call $xCall, Paginator $xPaginator, string $sWrapperId = '') |
| 125 | 125 | { |
| 126 | 126 | $aPages = $xPaginator->pages(); |
| 127 | - if(count($aPages) === 0) |
|
| 127 | + if (count($aPages) === 0) |
|
| 128 | 128 | { |
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | - if(!($xStore = $this->_render($aPages))) |
|
| 131 | + if (!($xStore = $this->_render($aPages))) |
|
| 132 | 132 | { |
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Append the page number to the parameter list, if not yet given. |
| 137 | - if(!$xCall->hasPageNumber()) |
|
| 137 | + if (!$xCall->hasPageNumber()) |
|
| 138 | 138 | { |
| 139 | 139 | $xCall->addParameter(Parameter::PAGE_NUMBER, 0); |
| 140 | 140 | } |