@@ -300,8 +300,7 @@ |
||
300 | 300 | $this->xResponseManager->error($e->getMessage()); |
301 | 301 | $this->onInvalid($e); |
302 | 302 | throw $e; |
303 | - } |
|
304 | - catch(Exception $e) |
|
303 | + } catch(Exception $e) |
|
305 | 304 | { |
306 | 305 | $this->xResponseManager->error($e->getMessage()); |
307 | 306 | $this->onError($e); |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | { |
112 | 112 | $xTarget = $this->xRequestPlugin->getTarget(); |
113 | 113 | // Call the user defined callback |
114 | - foreach($this->xCallbackManager->getBeforeCallbacks() as $xCallback) |
|
114 | + foreach ($this->xCallbackManager->getBeforeCallbacks() as $xCallback) |
|
115 | 115 | { |
116 | 116 | $xReturn = call_user_func_array($xCallback, [$xTarget, &$bEndRequest]); |
117 | - if($xReturn instanceof ResponseInterface) |
|
117 | + if ($xReturn instanceof ResponseInterface) |
|
118 | 118 | { |
119 | 119 | $this->xResponseManager->append($xReturn); |
120 | 120 | } |
121 | - if($bEndRequest) |
|
121 | + if ($bEndRequest) |
|
122 | 122 | { |
123 | 123 | return; |
124 | 124 | } |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function onAfter(bool $bEndRequest) |
135 | 135 | { |
136 | - foreach($this->xCallbackManager->getAfterCallbacks() as $xCallback) |
|
136 | + foreach ($this->xCallbackManager->getAfterCallbacks() as $xCallback) |
|
137 | 137 | { |
138 | 138 | $xReturn = call_user_func_array($xCallback, |
139 | 139 | [$this->xRequestPlugin->getTarget(), $bEndRequest]); |
140 | - if($xReturn instanceof ResponseInterface) |
|
140 | + if ($xReturn instanceof ResponseInterface) |
|
141 | 141 | { |
142 | 142 | $this->xResponseManager->append($xReturn); |
143 | 143 | } |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function onInvalid(RequestException $xException) |
156 | 156 | { |
157 | - foreach($this->xCallbackManager->getInvalidCallbacks() as $xCallback) |
|
157 | + foreach ($this->xCallbackManager->getInvalidCallbacks() as $xCallback) |
|
158 | 158 | { |
159 | 159 | $xReturn = call_user_func($xCallback, $xException); |
160 | - if($xReturn instanceof ResponseInterface) |
|
160 | + if ($xReturn instanceof ResponseInterface) |
|
161 | 161 | { |
162 | 162 | $this->xResponseManager->append($xReturn); |
163 | 163 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function onError(Exception $xException) |
176 | 176 | { |
177 | - foreach($this->xCallbackManager->getErrorCallbacks() as $xCallback) |
|
177 | + foreach ($this->xCallbackManager->getErrorCallbacks() as $xCallback) |
|
178 | 178 | { |
179 | 179 | $xReturn = call_user_func($xCallback, $xException); |
180 | - if($xReturn instanceof ResponseInterface) |
|
180 | + if ($xReturn instanceof ResponseInterface) |
|
181 | 181 | { |
182 | 182 | $this->xResponseManager->append($xReturn); |
183 | 183 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->xUploadHandler = $this->di->getUploadHandler(); |
197 | 197 | |
198 | 198 | // Return true if the request plugin was already found |
199 | - if($this->xRequestPlugin !== null) |
|
199 | + if ($this->xRequestPlugin !== null) |
|
200 | 200 | { |
201 | 201 | return true; |
202 | 202 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | // The HTTP request |
205 | 205 | $xRequest = $this->di->getRequest(); |
206 | 206 | // Find a plugin to process the request |
207 | - foreach($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
207 | + foreach ($this->xPluginManager->getRequestHandlers() as $sClassName) |
|
208 | 208 | { |
209 | - if($sClassName::canProcessRequest($xRequest)) |
|
209 | + if ($sClassName::canProcessRequest($xRequest)) |
|
210 | 210 | { |
211 | 211 | $this->xRequestPlugin = $this->di->g($sClassName); |
212 | 212 | $this->xRequestPlugin->setTarget($xRequest); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | // Check if the upload plugin is enabled |
218 | - if($this->xUploadHandler === null) |
|
218 | + if ($this->xUploadHandler === null) |
|
219 | 219 | { |
220 | 220 | return false; |
221 | 221 | } |
@@ -237,15 +237,15 @@ discard block |
||
237 | 237 | // The HTTP request |
238 | 238 | $xRequest = $this->di->getRequest(); |
239 | 239 | // Process uploaded files, if the upload plugin is enabled |
240 | - if($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
240 | + if ($this->xUploadHandler !== null && $this->xUploadHandler->canProcessRequest($xRequest)) |
|
241 | 241 | { |
242 | 242 | $this->xUploadHandler->processRequest($xRequest); |
243 | 243 | } |
244 | 244 | // Process the request |
245 | - if(($this->xRequestPlugin)) |
|
245 | + if (($this->xRequestPlugin)) |
|
246 | 246 | { |
247 | 247 | $xResponse = $this->xRequestPlugin->processRequest(); |
248 | - if(($xResponse)) |
|
248 | + if (($xResponse)) |
|
249 | 249 | { |
250 | 250 | $this->xResponseManager->append($xResponse); |
251 | 251 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | public function processRequest() |
267 | 267 | { |
268 | 268 | // Check if there is a plugin to process this request |
269 | - if(!$this->canProcessRequest()) |
|
269 | + if (!$this->canProcessRequest()) |
|
270 | 270 | { |
271 | 271 | return; |
272 | 272 | } |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | { |
276 | 276 | $bEndRequest = false; |
277 | 277 | // Handle before processing event |
278 | - if(($this->xRequestPlugin)) |
|
278 | + if (($this->xRequestPlugin)) |
|
279 | 279 | { |
280 | 280 | $this->onBefore($bEndRequest); |
281 | 281 | } |
282 | - if($bEndRequest) |
|
282 | + if ($bEndRequest) |
|
283 | 283 | { |
284 | 284 | return; |
285 | 285 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $this->_processRequest(); |
288 | 288 | |
289 | 289 | // Handle after processing event |
290 | - if(($this->xRequestPlugin)) |
|
290 | + if (($this->xRequestPlugin)) |
|
291 | 291 | { |
292 | 292 | $this->onAfter($bEndRequest); |
293 | 293 | } |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | // An exception was thrown while processing the request. |
296 | 296 | // The request missed the corresponding handler function, |
297 | 297 | // or an error occurred while attempting to execute the handler. |
298 | - catch(RequestException $e) |
|
298 | + catch (RequestException $e) |
|
299 | 299 | { |
300 | 300 | $this->xResponseManager->error($e->getMessage()); |
301 | 301 | $this->onInvalid($e); |
302 | 302 | throw $e; |
303 | 303 | } |
304 | - catch(Exception $e) |
|
304 | + catch (Exception $e) |
|
305 | 305 | { |
306 | 306 | $this->xResponseManager->error($e->getMessage()); |
307 | 307 | $this->onError($e); |
@@ -110,8 +110,7 @@ discard block |
||
110 | 110 | if(isset($aServerParams['CONTENT_TYPE'])) |
111 | 111 | { |
112 | 112 | $sContentType = $aServerParams['CONTENT_TYPE']; |
113 | - } |
|
114 | - elseif(isset($aServerParams['HTTP_CONTENT_TYPE'])) |
|
113 | + } elseif(isset($aServerParams['HTTP_CONTENT_TYPE'])) |
|
115 | 114 | { |
116 | 115 | $sContentType = $aServerParams['HTTP_CONTENT_TYPE']; |
117 | 116 | } |
@@ -142,20 +141,17 @@ discard block |
||
142 | 141 | $this->cUtf8Decoder = function($sStr) use($sEncoding) { |
143 | 142 | return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr); |
144 | 143 | }; |
145 | - } |
|
146 | - elseif(function_exists('mb_convert_encoding')) |
|
144 | + } elseif(function_exists('mb_convert_encoding')) |
|
147 | 145 | { |
148 | 146 | $this->cUtf8Decoder = function($sStr) use($sEncoding) { |
149 | 147 | return mb_convert_encoding($sStr, $sEncoding, "UTF-8"); |
150 | 148 | }; |
151 | - } |
|
152 | - elseif($sEncoding === "ISO-8859-1") |
|
149 | + } elseif($sEncoding === "ISO-8859-1") |
|
153 | 150 | { |
154 | 151 | $this->cUtf8Decoder = function($sStr) { |
155 | 152 | return utf8_decode($sStr); |
156 | 153 | }; |
157 | - } |
|
158 | - else |
|
154 | + } else |
|
159 | 155 | { |
160 | 156 | throw new RequestException($this->xTranslator->trans('errors.request.conversion')); |
161 | 157 | } |
@@ -251,8 +247,7 @@ discard block |
||
251 | 247 | { |
252 | 248 | $aParams = $aBody['jxnargs']; |
253 | 249 | } |
254 | - } |
|
255 | - else |
|
250 | + } else |
|
256 | 251 | { |
257 | 252 | $aParams = $xRequest->getQueryParams(); |
258 | 253 | if(isset($aParams['jxnargs'])) |
@@ -196,15 +196,15 @@ |
||
196 | 196 | $sValue = substr($sValue, 1); |
197 | 197 | switch($cType) |
198 | 198 | { |
199 | - case 'S': |
|
200 | - return $sValue; |
|
201 | - case 'B': |
|
202 | - return $this->convertStringToBool($sValue); |
|
203 | - case 'N': |
|
204 | - return ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue); |
|
205 | - case '*': |
|
206 | - default: |
|
207 | - return null; |
|
199 | + case 'S': |
|
200 | + return $sValue; |
|
201 | + case 'B': |
|
202 | + return $this->convertStringToBool($sValue); |
|
203 | + case 'N': |
|
204 | + return ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue); |
|
205 | + case '*': |
|
206 | + default: |
|
207 | + return null; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | // Parameters are url encoded when uploading files |
108 | 108 | $aServerParams = $this->di->getRequest()->getServerParams(); |
109 | 109 | $sContentType = ''; |
110 | - if(isset($aServerParams['CONTENT_TYPE'])) |
|
110 | + if (isset($aServerParams['CONTENT_TYPE'])) |
|
111 | 111 | { |
112 | 112 | $sContentType = $aServerParams['CONTENT_TYPE']; |
113 | 113 | } |
114 | - elseif(isset($aServerParams['HTTP_CONTENT_TYPE'])) |
|
114 | + elseif (isset($aServerParams['HTTP_CONTENT_TYPE'])) |
|
115 | 115 | { |
116 | 116 | $sContentType = $aServerParams['HTTP_CONTENT_TYPE']; |
117 | 117 | } |
118 | 118 | $sType = 'multipart/form-data'; |
119 | - if(strncmp($sContentType, $sType, strlen($sType)) !== 0) |
|
119 | + if (strncmp($sContentType, $sType, strlen($sType)) !== 0) |
|
120 | 120 | { |
121 | 121 | $this->cParamDecoder = function($sParam) { return $sParam; }; |
122 | 122 | return; |
@@ -137,19 +137,19 @@ discard block |
||
137 | 137 | return $sStr; |
138 | 138 | }; |
139 | 139 | $sEncoding = $this->xConfigManager->getOption('core.encoding', ''); |
140 | - if(function_exists('iconv')) |
|
140 | + if (function_exists('iconv')) |
|
141 | 141 | { |
142 | 142 | $this->cUtf8Decoder = function($sStr) use($sEncoding) { |
143 | 143 | return iconv("UTF-8", $sEncoding . '//TRANSLIT', $sStr); |
144 | 144 | }; |
145 | 145 | } |
146 | - elseif(function_exists('mb_convert_encoding')) |
|
146 | + elseif (function_exists('mb_convert_encoding')) |
|
147 | 147 | { |
148 | 148 | $this->cUtf8Decoder = function($sStr) use($sEncoding) { |
149 | 149 | return mb_convert_encoding($sStr, $sEncoding, "UTF-8"); |
150 | 150 | }; |
151 | 151 | } |
152 | - elseif($sEncoding === "ISO-8859-1") |
|
152 | + elseif ($sEncoding === "ISO-8859-1") |
|
153 | 153 | { |
154 | 154 | $this->cUtf8Decoder = function($sStr) { |
155 | 155 | return utf8_decode($sStr); |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | */ |
171 | 171 | private function convertStringToBool(string $sValue): bool |
172 | 172 | { |
173 | - if(strcasecmp($sValue, 'true') === 0) |
|
173 | + if (strcasecmp($sValue, 'true') === 0) |
|
174 | 174 | { |
175 | 175 | return true; |
176 | 176 | } |
177 | - if(strcasecmp($sValue, 'false') === 0) |
|
177 | + if (strcasecmp($sValue, 'false') === 0) |
|
178 | 178 | { |
179 | 179 | return false; |
180 | 180 | } |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | { |
195 | 195 | $cType = substr($sValue, 0, 1); |
196 | 196 | $sValue = substr($sValue, 1); |
197 | - switch($cType) |
|
197 | + switch ($cType) |
|
198 | 198 | { |
199 | 199 | case 'S': |
200 | 200 | return $sValue; |
201 | 201 | case 'B': |
202 | 202 | return $this->convertStringToBool($sValue); |
203 | 203 | case 'N': |
204 | - return ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue); |
|
204 | + return ($sValue == floor($sValue) ? (int) $sValue : (float) $sValue); |
|
205 | 205 | case '*': |
206 | 206 | default: |
207 | 207 | return null; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | private function decodeRequestParameter(string $sParam) |
219 | 219 | { |
220 | - if($sParam === '') |
|
220 | + if ($sParam === '') |
|
221 | 221 | { |
222 | 222 | return $sParam; |
223 | 223 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $sParam = call_user_func($this->cParamDecoder, $sParam); |
226 | 226 | |
227 | 227 | $xJson = json_decode($sParam, true); |
228 | - if($xJson !== null && $sParam != $xJson) |
|
228 | + if ($xJson !== null && $sParam != $xJson) |
|
229 | 229 | { |
230 | 230 | return $xJson; |
231 | 231 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | $aParams = []; |
241 | 241 | $xRequest = $this->di->getRequest(); |
242 | 242 | $aBody = $xRequest->getParsedBody(); |
243 | - if(is_array($aBody)) |
|
243 | + if (is_array($aBody)) |
|
244 | 244 | { |
245 | - if(isset($aBody['jxnargs'])) |
|
245 | + if (isset($aBody['jxnargs'])) |
|
246 | 246 | { |
247 | 247 | $aParams = $aBody['jxnargs']; |
248 | 248 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | else |
251 | 251 | { |
252 | 252 | $aParams = $xRequest->getQueryParams(); |
253 | - if(isset($aParams['jxnargs'])) |
|
253 | + if (isset($aParams['jxnargs'])) |
|
254 | 254 | { |
255 | 255 | $aParams = $aParams['jxnargs']; |
256 | 256 | } |
257 | 257 | } |
258 | 258 | return array_map(function($sParam) { |
259 | - return $this->decodeRequestParameter((string)$sParam); |
|
259 | + return $this->decodeRequestParameter((string) $sParam); |
|
260 | 260 | }, $aParams); |
261 | 261 | } |
262 | 262 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | private function decodeUtf8Parameter($xValue) |
271 | 271 | { |
272 | - if(is_string($xValue)) |
|
272 | + if (is_string($xValue)) |
|
273 | 273 | { |
274 | 274 | return call_user_func($this->cUtf8Decoder, $xValue); |
275 | 275 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | private function decodeUtf8Parameters(array $aParams): array |
290 | 290 | { |
291 | 291 | $aValues = []; |
292 | - foreach($aParams as $sKey => $xValue) |
|
292 | + foreach ($aParams as $sKey => $xValue) |
|
293 | 293 | { |
294 | 294 | // Decode the key |
295 | 295 | $sKey = call_user_func($this->cUtf8Decoder, $sKey); |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | { |
311 | 311 | $this->setParamDecoder(); |
312 | 312 | $aParams = $this->getRequestParameters(); |
313 | - if(!$this->xConfigManager->getOption('core.decode_utf8')) |
|
313 | + if (!$this->xConfigManager->getOption('core.decode_utf8')) |
|
314 | 314 | { |
315 | 315 | return $aParams; |
316 | 316 | } |
@@ -125,8 +125,7 @@ |
||
125 | 125 | if(is_string($xOptions)) |
126 | 126 | { |
127 | 127 | $xOptions = ['include' => $xOptions]; |
128 | - } |
|
129 | - elseif(!is_array($xOptions)) |
|
128 | + } elseif(!is_array($xOptions)) |
|
130 | 129 | { |
131 | 130 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
132 | 131 | } |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function checkOptions(string $sCallable, $xOptions): array |
130 | 130 | { |
131 | - if(!$this->xValidator->validateFunction(trim($sCallable))) |
|
131 | + if (!$this->xValidator->validateFunction(trim($sCallable))) |
|
132 | 132 | { |
133 | 133 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
134 | 134 | } |
135 | - if(is_string($xOptions)) |
|
135 | + if (is_string($xOptions)) |
|
136 | 136 | { |
137 | 137 | $xOptions = ['include' => $xOptions]; |
138 | 138 | } |
139 | - elseif(!is_array($xOptions)) |
|
139 | + elseif (!is_array($xOptions)) |
|
140 | 140 | { |
141 | 141 | throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
142 | 142 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | $sPhpFunction = trim($sCallable); |
158 | 158 | $sFunction = $sPhpFunction; |
159 | 159 | // Check if an alias is defined |
160 | - if(isset($aOptions['alias'])) |
|
160 | + if (isset($aOptions['alias'])) |
|
161 | 161 | { |
162 | - $sFunction = (string)$aOptions['alias']; |
|
162 | + $sFunction = (string) $aOptions['alias']; |
|
163 | 163 | unset($aOptions['alias']); |
164 | 164 | } |
165 | 165 | $this->aFunctions[$sFunction] = $sPhpFunction; |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | public function getCallable(string $sCallable) |
182 | 182 | { |
183 | 183 | $sFunction = trim($sCallable); |
184 | - if(!isset($this->aFunctions[$sFunction])) |
|
184 | + if (!isset($this->aFunctions[$sFunction])) |
|
185 | 185 | { |
186 | 186 | return null; |
187 | 187 | } |
188 | 188 | $xCallable = new CallableFunction($this->di, $sFunction, |
189 | 189 | $this->sPrefix . $sFunction, $this->aFunctions[$sFunction]); |
190 | - foreach($this->aOptions[$sFunction] as $sName => $sValue) |
|
190 | + foreach ($this->aOptions[$sFunction] as $sName => $sValue) |
|
191 | 191 | { |
192 | 192 | $xCallable->configure($sName, $sValue); |
193 | 193 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function getScript(): string |
217 | 217 | { |
218 | 218 | $code = ''; |
219 | - foreach(array_keys($this->aFunctions) as $sFunction) |
|
219 | + foreach (array_keys($this->aFunctions) as $sFunction) |
|
220 | 220 | { |
221 | 221 | $xFunction = $this->getCallable($sFunction); |
222 | 222 | $code .= $this->getCallableScript($xFunction); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public static function canProcessRequest(ServerRequestInterface $xRequest): bool |
231 | 231 | { |
232 | 232 | $aBody = $xRequest->getParsedBody(); |
233 | - if(is_array($aBody)) |
|
233 | + if (is_array($aBody)) |
|
234 | 234 | { |
235 | 235 | return isset($aBody['jxnfun']); |
236 | 236 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | public function setTarget(ServerRequestInterface $xRequest) |
245 | 245 | { |
246 | 246 | $aBody = $xRequest->getParsedBody(); |
247 | - if(is_array($aBody)) |
|
247 | + if (is_array($aBody)) |
|
248 | 248 | { |
249 | 249 | $this->xTarget = Target::makeFunction(trim($aBody['jxnfun'])); |
250 | 250 | return; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $sRequestedFunction = $this->xTarget->getFunctionName(); |
263 | 263 | |
264 | 264 | // Security check: make sure the requested function was registered. |
265 | - if(!$this->xValidator->validateFunction($sRequestedFunction) || |
|
265 | + if (!$this->xValidator->validateFunction($sRequestedFunction) || |
|
266 | 266 | !isset($this->aFunctions[$sRequestedFunction])) |
267 | 267 | { |
268 | 268 | // Unable to find the requested function |
@@ -114,15 +114,15 @@ |
||
114 | 114 | { |
115 | 115 | switch($sName) |
116 | 116 | { |
117 | - case 'class': // The user function is a method in the given class |
|
118 | - $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
|
119 | - break; |
|
120 | - case 'include': |
|
121 | - $this->sInclude = $sValue; |
|
122 | - break; |
|
123 | - default: |
|
124 | - $this->aOptions[$sName] = $sValue; |
|
125 | - break; |
|
117 | + case 'class': // The user function is a method in the given class |
|
118 | + $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
|
119 | + break; |
|
120 | + case 'include': |
|
121 | + $this->sInclude = $sValue; |
|
122 | + break; |
|
123 | + default: |
|
124 | + $this->aOptions[$sName] = $sValue; |
|
125 | + break; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function configure(string $sName, string $sValue) |
125 | 125 | { |
126 | - switch($sName) |
|
126 | + switch ($sName) |
|
127 | 127 | { |
128 | 128 | case 'class': // The user function is a method in the given class |
129 | 129 | $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function call(array $aArgs = []) |
149 | 149 | { |
150 | - if(($this->sInclude)) |
|
150 | + if (($this->sInclude)) |
|
151 | 151 | { |
152 | 152 | require_once $this->sInclude; |
153 | 153 | } |
154 | 154 | // If the function is an alias for a class method, then instantiate the class |
155 | - if(is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0])) |
|
155 | + if (is_array($this->xPhpFunction) && is_string($this->xPhpFunction[0])) |
|
156 | 156 | { |
157 | 157 | $sClassName = $this->xPhpFunction[0]; |
158 | 158 | $this->xPhpFunction[0] = $this->di->h($sClassName) ? |
@@ -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; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function setDataBag() |
41 | 41 | { |
42 | - if($this->xDataBag !== null) |
|
42 | + if ($this->xDataBag !== null) |
|
43 | 43 | { |
44 | 44 | return; |
45 | 45 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | $aBody = $xRequest->getParsedBody(); |
49 | 49 | $aParams = $xRequest->getQueryParams(); |
50 | 50 | $aData = is_array($aBody) ? |
51 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
52 | - $this->readData($aParams['jxnbags'] ?? []); |
|
51 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
53 | 52 | $this->xDataBag = new DataBag($aData); |
54 | 53 | } |
55 | 54 | |
@@ -69,7 +68,7 @@ discard block |
||
69 | 68 | private function readData($xData): array |
70 | 69 | { |
71 | 70 | // Todo: clean input data. |
72 | - if(is_string($xData)) |
|
71 | + if (is_string($xData)) |
|
73 | 72 | { |
74 | 73 | return json_decode($xData, true) ?: []; |
75 | 74 | } |
@@ -105,7 +104,7 @@ discard block |
||
105 | 104 | public function writeCommand() |
106 | 105 | { |
107 | 106 | $this->setDataBag(); |
108 | - if($this->xDataBag->touched()) |
|
107 | + if ($this->xDataBag->touched()) |
|
109 | 108 | { |
110 | 109 | $this->addCommand(['cmd' => 'bags.set'], $this->xDataBag->getAll()); |
111 | 110 | } |
@@ -126,7 +126,7 @@ |
||
126 | 126 | */ |
127 | 127 | private function getLibraries(): array |
128 | 128 | { |
129 | - if($this->aLibraries === null) |
|
129 | + if ($this->aLibraries === null) |
|
130 | 130 | { |
131 | 131 | $this->aLibraries = $this->xLibraryManager->getLibraries(); |
132 | 132 | } |
@@ -85,28 +85,28 @@ discard block |
||
85 | 85 | private function updateContainer(Config $xConfig) |
86 | 86 | { |
87 | 87 | $aOptions = $xConfig->getOption('container.set', []); |
88 | - foreach($aOptions as $xKey => $xValue) |
|
88 | + foreach ($aOptions as $xKey => $xValue) |
|
89 | 89 | { |
90 | 90 | // The key is the class name. It must be a string. |
91 | - $this->di->set((string)$xKey, $xValue); |
|
91 | + $this->di->set((string) $xKey, $xValue); |
|
92 | 92 | } |
93 | 93 | $aOptions = $xConfig->getOption('container.val', []); |
94 | - foreach($aOptions as $xKey => $xValue) |
|
94 | + foreach ($aOptions as $xKey => $xValue) |
|
95 | 95 | { |
96 | 96 | // The key is the class name. It must be a string. |
97 | - $this->di->val((string)$xKey, $xValue); |
|
97 | + $this->di->val((string) $xKey, $xValue); |
|
98 | 98 | } |
99 | 99 | $aOptions = $xConfig->getOption('container.auto', []); |
100 | - foreach($aOptions as $xValue) |
|
100 | + foreach ($aOptions as $xValue) |
|
101 | 101 | { |
102 | 102 | // The key is the class name. It must be a string. |
103 | - $this->di->auto((string)$xValue); |
|
103 | + $this->di->auto((string) $xValue); |
|
104 | 104 | } |
105 | 105 | $aOptions = $xConfig->getOption('container.alias', []); |
106 | - foreach($aOptions as $xKey => $xValue) |
|
106 | + foreach ($aOptions as $xKey => $xValue) |
|
107 | 107 | { |
108 | 108 | // The key is the class name. It must be a string. |
109 | - $this->di->alias((string)$xKey, (string)$xValue); |
|
109 | + $this->di->alias((string) $xKey, (string) $xValue); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | */ |
122 | 122 | private function registerCallables(array $aOptions, string $sCallableType) |
123 | 123 | { |
124 | - foreach($aOptions as $xKey => $xValue) |
|
124 | + foreach ($aOptions as $xKey => $xValue) |
|
125 | 125 | { |
126 | - if(is_integer($xKey) && is_string($xValue)) |
|
126 | + if (is_integer($xKey) && is_string($xValue)) |
|
127 | 127 | { |
128 | 128 | // Register a function without options |
129 | 129 | $this->xPluginManager->registerCallable($sCallableType, $xValue); |
130 | 130 | } |
131 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
131 | + elseif (is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
132 | 132 | { |
133 | 133 | // Register a function with options |
134 | 134 | $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue); |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | { |
172 | 172 | // $this->aPackages contains packages config file paths. |
173 | 173 | $aLibOptions = $sClassName::config(); |
174 | - if(is_string($aLibOptions)) |
|
174 | + if (is_string($aLibOptions)) |
|
175 | 175 | { |
176 | 176 | // A string is supposed to be the path to a config file. |
177 | 177 | $aLibOptions = $this->xConfigManager->read($aLibOptions); |
178 | 178 | } |
179 | - elseif(!is_array($aLibOptions)) |
|
179 | + elseif (!is_array($aLibOptions)) |
|
180 | 180 | { |
181 | 181 | // Otherwise, anything else than an array is not accepted. |
182 | 182 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | public function registerPackage(string $sClassName, array $aUserOptions) |
198 | 198 | { |
199 | 199 | $sClassName = trim($sClassName, '\\ '); |
200 | - if(!is_subclass_of($sClassName, Package::class)) |
|
200 | + if (!is_subclass_of($sClassName, Package::class)) |
|
201 | 201 | { |
202 | 202 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
203 | 203 | throw new SetupException($sMessage); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | // Register packages |
243 | 243 | $aPackageConfig = $xAppConfig->getOption('packages', []); |
244 | - foreach($aPackageConfig as $sClassName => $aPkgOptions) |
|
244 | + foreach ($aPackageConfig as $sClassName => $aPkgOptions) |
|
245 | 245 | { |
246 | 246 | $this->registerPackage($sClassName, $aPkgOptions); |
247 | 247 | } |
@@ -127,8 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | // Register a function without options |
129 | 129 | $this->xPluginManager->registerCallable($sCallableType, $xValue); |
130 | - } |
|
131 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
130 | + } elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
132 | 131 | { |
133 | 132 | // Register a function with options |
134 | 133 | $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue); |
@@ -175,8 +174,7 @@ discard block |
||
175 | 174 | { |
176 | 175 | // A string is supposed to be the path to a config file. |
177 | 176 | $aLibOptions = $this->xConfigManager->read($aLibOptions); |
178 | - } |
|
179 | - elseif(!is_array($aLibOptions)) |
|
177 | + } elseif(!is_array($aLibOptions)) |
|
180 | 178 | { |
181 | 179 | // Otherwise, anything else than an array is not accepted. |
182 | 180 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -62,12 +62,12 @@ |
||
62 | 62 | public function request(string $sClassName = ''): ?RequestFactory |
63 | 63 | { |
64 | 64 | $sClassName = trim($sClassName); |
65 | - if(!$sClassName) |
|
65 | + if (!$sClassName) |
|
66 | 66 | { |
67 | 67 | // There is a single request factory for all callable functions. |
68 | 68 | return $this->xRequestFactory->noPrefix(false); |
69 | 69 | } |
70 | - if($sClassName === '.') |
|
70 | + if ($sClassName === '.') |
|
71 | 71 | { |
72 | 72 | // The request factory is for a js function, not a Jaxon call. |
73 | 73 | return $this->xRequestFactory->noPrefix(true); |