@@ -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); |
@@ -234,7 +234,7 @@ |
||
234 | 234 | */ |
235 | 235 | public function val(string $sKey, $xValue) |
236 | 236 | { |
237 | - $this->xLibContainer->offsetSet($sKey, $xValue); |
|
237 | + $this->xLibContainer->offsetSet($sKey, $xValue); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function has(string $sClass): bool |
160 | 160 | { |
161 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
161 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
162 | 162 | { |
163 | 163 | return true; |
164 | 164 | } |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | { |
190 | 190 | try |
191 | 191 | { |
192 | - if($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
192 | + if ($this->xAppContainer != null && $this->xAppContainer->has($sClass)) |
|
193 | 193 | { |
194 | 194 | return $this->xAppContainer->get($sClass); |
195 | 195 | } |
196 | 196 | return $this->xLibContainer->offsetGet($sClass); |
197 | 197 | } |
198 | - catch(Exception|Throwable $e) |
|
198 | + catch (Exception | Throwable $e) |
|
199 | 199 | { |
200 | 200 | $xLogger = $this->g(LoggerInterface::class); |
201 | 201 | $xTranslator = $this->g(Translator::class); |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | { |
264 | 264 | $xType = $xParameter->getType(); |
265 | 265 | // Check the parameter class first. |
266 | - if($xType instanceof ReflectionNamedType) |
|
266 | + if ($xType instanceof ReflectionNamedType) |
|
267 | 267 | { |
268 | 268 | // Check the class + the name |
269 | - if($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
269 | + if ($this->has($xType->getName() . ' $' . $xParameter->getName())) |
|
270 | 270 | { |
271 | 271 | return $this->get($xType->getName() . ' $' . $xParameter->getName()); |
272 | 272 | } |
273 | 273 | // Check the class only |
274 | - if($this->has($xType->getName())) |
|
274 | + if ($this->has($xType->getName())) |
|
275 | 275 | { |
276 | 276 | return $this->get($xType->getName()); |
277 | 277 | } |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function make($xClass) |
293 | 293 | { |
294 | - if(is_string($xClass)) |
|
294 | + if (is_string($xClass)) |
|
295 | 295 | { |
296 | 296 | $xClass = new ReflectionClass($xClass); // Create the reflection class instance |
297 | 297 | } |
298 | - if(!($xClass instanceof ReflectionClass)) |
|
298 | + if (!($xClass instanceof ReflectionClass)) |
|
299 | 299 | { |
300 | 300 | return null; |
301 | 301 | } |
302 | 302 | // Use the Reflection class to get the parameters of the constructor |
303 | - if(($constructor = $xClass->getConstructor()) === null) |
|
303 | + if (($constructor = $xClass->getConstructor()) === null) |
|
304 | 304 | { |
305 | 305 | return $xClass->newInstance(); |
306 | 306 | } |
@@ -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); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $this->xUploadHandler = $this->di->getUploadHandler(); |
108 | 108 | |
109 | 109 | // Return true if the request plugin was already found |
110 | - if($this->xRequestPlugin !== null) |
|
110 | + if ($this->xRequestPlugin !== null) |
|
111 | 111 | { |
112 | 112 | return true; |
113 | 113 | } |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | // The HTTP request |
116 | 116 | $xRequest = $this->di->getRequest(); |
117 | 117 | // Find a plugin to process the request |
118 | - foreach($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
118 | + foreach ($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
119 | 119 | { |
120 | - if($sClassName::canProcessRequest($xRequest)) |
|
120 | + if ($sClassName::canProcessRequest($xRequest)) |
|
121 | 121 | { |
122 | 122 | $this->xRequestPlugin = $this->di->g($sClassName); |
123 | 123 | $this->xRequestPlugin->setTarget($xRequest); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // Check if the upload plugin is enabled |
129 | - if($this->xUploadHandler === null) |
|
129 | + if ($this->xUploadHandler === null) |
|
130 | 130 | { |
131 | 131 | return false; |
132 | 132 | } |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | // The HTTP request |
149 | 149 | $xRequest = $this->di->getRequest(); |
150 | 150 | // Process uploaded files, if the upload plugin is enabled |
151 | - if($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
151 | + if ($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
152 | 152 | { |
153 | 153 | $this->xUploadHandler->processRequest($xRequest); |
154 | 154 | } |
155 | 155 | // Process the request |
156 | - if(($this->xRequestPlugin)) |
|
156 | + if (($this->xRequestPlugin)) |
|
157 | 157 | { |
158 | 158 | $xResponse = $this->xRequestPlugin->processRequest(); |
159 | - if(($xResponse)) |
|
159 | + if (($xResponse)) |
|
160 | 160 | { |
161 | 161 | $this->xResponseManager->setResponse($xResponse); |
162 | 162 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public function processRequest() |
178 | 178 | { |
179 | 179 | // Check if there is a plugin to process this request |
180 | - if(!$this->canProcessRequest()) |
|
180 | + if (!$this->canProcessRequest()) |
|
181 | 181 | { |
182 | 182 | return; |
183 | 183 | } |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | { |
187 | 187 | $bEndRequest = false; |
188 | 188 | // Handle before processing event |
189 | - if(($this->xRequestPlugin)) |
|
189 | + if (($this->xRequestPlugin)) |
|
190 | 190 | { |
191 | 191 | $this->xCallbackManager->onBefore($this->xRequestPlugin->getTarget(), $bEndRequest); |
192 | 192 | } |
193 | - if($bEndRequest) |
|
193 | + if ($bEndRequest) |
|
194 | 194 | { |
195 | 195 | return; |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $this->_processRequest(); |
199 | 199 | |
200 | 200 | // Handle after processing event |
201 | - if(($this->xRequestPlugin)) |
|
201 | + if (($this->xRequestPlugin)) |
|
202 | 202 | { |
203 | 203 | $this->xCallbackManager->onAfter($this->xRequestPlugin->getTarget(), $bEndRequest); |
204 | 204 | } |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | // An exception was thrown while processing the request. |
207 | 207 | // The request missed the corresponding handler function, |
208 | 208 | // or an error occurred while attempting to execute the handler. |
209 | - catch(RequestException $e) |
|
209 | + catch (RequestException $e) |
|
210 | 210 | { |
211 | 211 | $this->xResponseManager->error($e->getMessage()); |
212 | 212 | $this->xCallbackManager->onInvalid($e); |
213 | 213 | } |
214 | - catch(Exception $e) |
|
214 | + catch (Exception $e) |
|
215 | 215 | { |
216 | 216 | $this->xResponseManager->error($e->getMessage()); |
217 | 217 | $this->xCallbackManager->onError($e); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | private function checkDirectory(string $sDirectory): string |
81 | 81 | { |
82 | 82 | $sDirectory = rtrim(trim($sDirectory), '/\\'); |
83 | - if(!is_dir($sDirectory)) |
|
83 | + if (!is_dir($sDirectory)) |
|
84 | 84 | { |
85 | 85 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
86 | 86 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function checkOptions(string $sCallable, $xOptions): array |
95 | 95 | { |
96 | - if(is_string($xOptions)) |
|
96 | + if (is_string($xOptions)) |
|
97 | 97 | { |
98 | 98 | $xOptions = ['namespace' => $xOptions]; |
99 | 99 | } |
100 | - if(!is_array($xOptions)) |
|
100 | + if (!is_array($xOptions)) |
|
101 | 101 | { |
102 | 102 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
103 | 103 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $xOptions['directory'] = $this->checkDirectory($sCallable); |
106 | 106 | // Check the namespace |
107 | 107 | $sNamespace = $xOptions['namespace'] ?? ''; |
108 | - if(!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
108 | + if (!($xOptions['namespace'] = trim($sNamespace, ' \\'))) |
|
109 | 109 | { |
110 | 110 | $xOptions['namespace'] = ''; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Change the keys in $xOptions to have "\" as separator |
114 | 114 | $_aOptions = []; |
115 | - foreach($xOptions as $sName => $aOption) |
|
115 | + foreach ($xOptions as $sName => $aOption) |
|
116 | 116 | { |
117 | 117 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
118 | 118 | $_aOptions[$sName] = $aOption; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function register(string $sType, string $sCallable, array $aOptions): bool |
127 | 127 | { |
128 | - if(($aOptions['namespace'])) |
|
128 | + if (($aOptions['namespace'])) |
|
129 | 129 | { |
130 | 130 | $this->xRegistry->addNamespace($aOptions['namespace'], $aOptions); |
131 | 131 | return true; |
@@ -2,18 +2,18 @@ |
||
2 | 2 | <?php |
3 | 3 | // An exported PHP class can have the same name as a subdir in the same parent dir. |
4 | 4 | // So, we must make sure that embedded js objects do not already exist, before we create them. |
5 | -if(strpos($sJsClass, '.') !== false): ?> |
|
5 | +if (strpos($sJsClass, '.') !== false): ?> |
|
6 | 6 | if(<?php echo $sJsClass ?> === undefined) { |
7 | 7 | <?php echo $sJsClass ?> = {}; |
8 | 8 | } |
9 | 9 | <?php else: ?> |
10 | 10 | <?php echo $sJsClass ?> = {}; |
11 | 11 | <?php endif ?> |
12 | -<?php foreach($this->aMethods as $aMethod): ?> |
|
12 | +<?php foreach ($this->aMethods as $aMethod): ?> |
|
13 | 13 | <?php echo $sJsClass ?>.<?php echo $aMethod['name'] ?> = function() { |
14 | 14 | return jaxon.request({ jxncls: '<?php echo $this->sClass ?>', jxnmthd: '<?php |
15 | 15 | echo $aMethod['name'] ?>' }, { parameters: arguments<?php |
16 | - foreach($aMethod['config'] as $sKey => $sValue): ?>, <?php |
|
16 | + foreach ($aMethod['config'] as $sKey => $sValue): ?>, <?php |
|
17 | 17 | echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> }); |
18 | 18 | }; |
19 | 19 | <?php endforeach; |
@@ -6,7 +6,8 @@ discard block |
||
6 | 6 | if(<?php echo $sJsClass ?> === undefined) { |
7 | 7 | <?php echo $sJsClass ?> = {}; |
8 | 8 | } |
9 | -<?php else: ?> |
|
9 | +<?php else { |
|
10 | + : ?> |
|
10 | 11 | <?php echo $sJsClass ?> = {}; |
11 | 12 | <?php endif ?> |
12 | 13 | <?php foreach($this->aMethods as $aMethod): ?> |
@@ -17,3 +18,4 @@ discard block |
||
17 | 18 | echo $sKey ?>: <?php echo $sValue ?><?php endforeach ?> }); |
18 | 19 | }; |
19 | 20 | <?php endforeach; |
21 | +} |
@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | public function __get(string $sAttribute): JsExpr |
62 | 62 | { |
63 | - return $this->_expr()->__get( $sAttribute); |
|
63 | + return $this->_expr()->__get($sAttribute); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * @link https://github.com/jaxon-php/jaxon-core |
15 | 15 | */ |
16 | 16 | |
17 | - use Jaxon\App\Dialog\DialogManager; |
|
17 | + use Jaxon\App\Dialog\DialogManager; |
|
18 | 18 | |
19 | 19 | class JxnCall extends AbstractCall |
20 | 20 | { |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function func(): ?Func |
93 | 93 | { |
94 | - foreach($this->aCalls as $xCall) |
|
94 | + foreach ($this->aCalls as $xCall) |
|
95 | 95 | { |
96 | - if(is_a($xCall, Func::class)) |
|
96 | + if (is_a($xCall, Func::class)) |
|
97 | 97 | { |
98 | 98 | return $xCall; |
99 | 99 | } |
@@ -442,21 +442,21 @@ discard block |
||
442 | 442 | $aCalls = array_map(function(JsonSerializable $xCall) { |
443 | 443 | return $xCall->jsonSerialize(); |
444 | 444 | }, $this->aCalls); |
445 | - if($this->bToInt) |
|
445 | + if ($this->bToInt) |
|
446 | 446 | { |
447 | 447 | $aCalls[] = $this->toIntCall(); |
448 | 448 | } |
449 | 449 | |
450 | 450 | $aJsExpr = ['_type' => $this->getType(), 'calls' => $aCalls]; |
451 | - if(($this->aConfirm)) |
|
451 | + if (($this->aConfirm)) |
|
452 | 452 | { |
453 | 453 | $aJsExpr['question'] = $this->aConfirm; |
454 | 454 | } |
455 | - if(($this->aCondition)) |
|
455 | + if (($this->aCondition)) |
|
456 | 456 | { |
457 | 457 | $aJsExpr['condition'] = $this->aCondition; |
458 | 458 | } |
459 | - if(($this->aMessage)) |
|
459 | + if (($this->aMessage)) |
|
460 | 460 | { |
461 | 461 | $aJsExpr['message'] = $this->aMessage; |
462 | 462 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $sName = trim($sPath) ?: 'this'; |
33 | 33 | $this->aCall = ['_type' => 'select', '_name' => $sName, 'mode' => $sMode]; |
34 | - if(($sPath) && ($xContext)) |
|
34 | + if (($sPath) && ($xContext)) |
|
35 | 35 | { |
36 | 36 | $this->aCall['context'] = is_a($xContext, JsonSerializable::class) ? |
37 | 37 | $xContext->jsonSerialize() : $xContext; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | private function getPathAsStr(string $sPath, string $sMode, $xContext) |
53 | 53 | { |
54 | - if(!$xContext) |
|
54 | + if (!$xContext) |
|
55 | 55 | { |
56 | 56 | return $sMode === 'jq' ? "jaxon.jq('$sPath')" : $sPath; |
57 | 57 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function jsonSerialize(): array |
68 | 68 | { |
69 | - if(isset($this->aValue['value'])) |
|
69 | + if (isset($this->aValue['value'])) |
|
70 | 70 | { |
71 | 71 | $this->aValue['value'] = $this->aValue['value']->jsonSerialize(); |
72 | 72 | } |
@@ -80,7 +80,6 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function __toString(): string |
82 | 82 | { |
83 | - return !isset($this->aValue['value']) ? $this->aValue['_name'] : |
|
84 | - $this->aValue['_name'] . ' = ' . $this->aValue['value']->__toString(); |
|
83 | + return !isset($this->aValue['value']) ? $this->aValue['_name'] : $this->aValue['_name'] . ' = ' . $this->aValue['value']->__toString(); |
|
85 | 84 | } |
86 | 85 | } |