@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function checkOptions(string $sCallable, $xOptions): array |
135 | 135 | { |
136 | - if(!$this->xValidator->validateClass(trim($sCallable))) |
|
136 | + if (!$this->xValidator->validateClass(trim($sCallable))) |
|
137 | 137 | { |
138 | 138 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
139 | 139 | } |
140 | - if(is_string($xOptions)) |
|
140 | + if (is_string($xOptions)) |
|
141 | 141 | { |
142 | 142 | $xOptions = ['include' => $xOptions]; |
143 | 143 | } |
144 | - elseif(!is_array($xOptions)) |
|
144 | + elseif (!is_array($xOptions)) |
|
145 | 145 | { |
146 | 146 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
147 | 147 | } |
@@ -186,16 +186,16 @@ discard block |
||
186 | 186 | $sCode = ''; |
187 | 187 | $aJsClasses = []; |
188 | 188 | $aNamespaces = $this->xRepository->getNamespaces(); |
189 | - foreach($aNamespaces as $sNamespace) |
|
189 | + foreach ($aNamespaces as $sNamespace) |
|
190 | 190 | { |
191 | 191 | $offset = 0; |
192 | 192 | $sJsNamespace = str_replace('\\', '.', $sNamespace); |
193 | 193 | $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
194 | - while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
194 | + while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
195 | 195 | { |
196 | 196 | $sJsClass = substr($sJsNamespace, 0, $dotPosition); |
197 | 197 | // Generate code for this object |
198 | - if(!isset($aJsClasses[$sJsClass])) |
|
198 | + if (!isset($aJsClasses[$sJsClass])) |
|
199 | 199 | { |
200 | 200 | $sCode .= $this->sPrefix . "$sJsClass = {};\n"; |
201 | 201 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | private function getCallableScript(string $sClassName, CallableObject $xCallableObject): string |
218 | 218 | { |
219 | - if($xCallableObject->excluded()) |
|
219 | + if ($xCallableObject->excluded()) |
|
220 | 220 | { |
221 | 221 | return ''; |
222 | 222 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | }); |
245 | 245 | |
246 | 246 | $sCode = $this->getNamespacesScript(); |
247 | - foreach($aCallableObjects as $sClassName => $xCallableObject) |
|
247 | + foreach ($aCallableObjects as $sClassName => $xCallableObject) |
|
248 | 248 | { |
249 | 249 | $sCode .= $this->getCallableScript($sClassName, $xCallableObject); |
250 | 250 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public static function canProcessRequest(ServerRequestInterface $xRequest): bool |
258 | 258 | { |
259 | 259 | $aBody = $xRequest->getParsedBody(); |
260 | - if(is_array($aBody)) |
|
260 | + if (is_array($aBody)) |
|
261 | 261 | { |
262 | 262 | return isset($aBody['jxncls']) && isset($aBody['jxnmthd']); |
263 | 263 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | public function setTarget(ServerRequestInterface $xRequest) |
272 | 272 | { |
273 | 273 | $aBody = $xRequest->getParsedBody(); |
274 | - if(is_array($aBody)) |
|
274 | + if (is_array($aBody)) |
|
275 | 275 | { |
276 | 276 | $this->xTarget = Target::makeClass(trim($aBody['jxncls']), trim($aBody['jxnmthd'])); |
277 | 277 | return; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $sMethodName = $this->xTarget->getMethodName(); |
291 | 291 | $this->xTarget->setMethodArgs($this->xParameterReader->args()); |
292 | 292 | |
293 | - if(!$this->xValidator->validateClass($sClassName) || !$this->xValidator->validateMethod($sMethodName)) |
|
293 | + if (!$this->xValidator->validateClass($sClassName) || !$this->xValidator->validateMethod($sMethodName)) |
|
294 | 294 | { |
295 | 295 | // Unable to find the requested object or method |
296 | 296 | throw new RequestException($this->xTranslator->trans('errors.objects.invalid', |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $xCallableObject = $this->xRegistry->getCallableObject($sClassName); |
304 | 304 | return $xCallableObject->call($this->xTarget); |
305 | 305 | } |
306 | - catch(ReflectionException|SetupException $e) |
|
306 | + catch (ReflectionException | SetupException $e) |
|
307 | 307 | { |
308 | 308 | // Unable to find the requested class or method |
309 | 309 | $this->di->getLogger()->error($e->getMessage()); |
@@ -140,8 +140,7 @@ discard block |
||
140 | 140 | if(is_string($xOptions)) |
141 | 141 | { |
142 | 142 | $xOptions = ['include' => $xOptions]; |
143 | - } |
|
144 | - elseif(!is_array($xOptions)) |
|
143 | + } elseif(!is_array($xOptions)) |
|
145 | 144 | { |
146 | 145 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
147 | 146 | } |
@@ -302,8 +301,7 @@ discard block |
||
302 | 301 | { |
303 | 302 | $xCallableObject = $this->xRegistry->getCallableObject($sClassName); |
304 | 303 | return $xCallableObject->call($this->xTarget); |
305 | - } |
|
306 | - catch(ReflectionException|SetupException $e) |
|
304 | + } catch(ReflectionException|SetupException $e) |
|
307 | 305 | { |
308 | 306 | // Unable to find the requested class or method |
309 | 307 | $this->di->getLogger()->error($e->getMessage()); |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | */ |
193 | 193 | private function setHookMethods(array &$aHookMethods, $xValue) |
194 | 194 | { |
195 | - foreach($xValue as $sCalledMethod => $xMethodToCall) |
|
195 | + foreach ($xValue as $sCalledMethod => $xMethodToCall) |
|
196 | 196 | { |
197 | - if(is_array($xMethodToCall)) |
|
197 | + if (is_array($xMethodToCall)) |
|
198 | 198 | { |
199 | 199 | $aHookMethods[$sCalledMethod] = $xMethodToCall; |
200 | 200 | } |
201 | - elseif(is_string($xMethodToCall)) |
|
201 | + elseif (is_string($xMethodToCall)) |
|
202 | 202 | { |
203 | 203 | $aHookMethods[$sCalledMethod] = [$xMethodToCall]; |
204 | 204 | } |
@@ -215,18 +215,18 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function configure(string $sName, $xValue) |
217 | 217 | { |
218 | - switch($sName) |
|
218 | + switch ($sName) |
|
219 | 219 | { |
220 | 220 | // Set the separator |
221 | 221 | case 'separator': |
222 | - if($xValue === '_' || $xValue === '.') |
|
222 | + if ($xValue === '_' || $xValue === '.') |
|
223 | 223 | { |
224 | 224 | $this->sSeparator = $xValue; |
225 | 225 | } |
226 | 226 | break; |
227 | 227 | // Set the protected methods |
228 | 228 | case 'protected': |
229 | - if(is_array($xValue)) |
|
229 | + if (is_array($xValue)) |
|
230 | 230 | { |
231 | 231 | $this->aProtectedMethods = array_merge($this->aProtectedMethods, $xValue); |
232 | 232 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $this->aAttributes = array_merge($this->aAttributes, $xValue); |
245 | 245 | break; |
246 | 246 | case 'excluded': |
247 | - $this->bExcluded = (bool)$xValue; |
|
247 | + $this->bExcluded = (bool) $xValue; |
|
248 | 248 | break; |
249 | 249 | default: |
250 | 250 | break; |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | // $aMethods = $aHookMethods[$sMethod] ?? $aHookMethods['*'] ?? []; |
367 | 367 | // The hooks defined at method level are merged with those defined at class level. |
368 | 368 | $aMethods = array_merge($aHookMethods['*'] ?? [], $aHookMethods[$sMethod] ?? []); |
369 | - foreach($aMethods as $xKey => $xValue) |
|
369 | + foreach ($aMethods as $xKey => $xValue) |
|
370 | 370 | { |
371 | 371 | $sHookName = $xValue; |
372 | 372 | $aHookArgs = []; |
373 | - if(is_string($xKey)) |
|
373 | + if (is_string($xKey)) |
|
374 | 374 | { |
375 | 375 | $sHookName = $xKey; |
376 | 376 | $aHookArgs = is_array($xValue) ? $xValue : [$xValue]; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | // $aAttributes = $this->aAttributes[$sMethod] ?? $this->aAttributes['*'] ?? []; |
412 | 412 | // The attributes defined at method level are merged with those defined at class level. |
413 | 413 | $aAttributes = array_merge($this->aAttributes['*'] ?? [], $this->aAttributes[$sMethod] ?? []); |
414 | - foreach($aAttributes as $sName => $sClass) |
|
414 | + foreach ($aAttributes as $sName => $sClass) |
|
415 | 415 | { |
416 | 416 | // Set the protected attributes of the object |
417 | 417 | $cSetter = function($c) use($sName, $sClass) { |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Set the Jaxon request target in the helper |
426 | - if($this->xRegisteredObject instanceof CallableClass) |
|
426 | + if ($this->xRegisteredObject instanceof CallableClass) |
|
427 | 427 | { |
428 | 428 | // Set the protected attributes of the object |
429 | 429 | $cSetter = function() use($xTarget) { |