@@ -103,28 +103,28 @@ discard block |
||
103 | 103 | private function updateContainer(Config $xConfig) |
104 | 104 | { |
105 | 105 | $aOptions = $xConfig->getOption('container.set', []); |
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->set((string)$xKey, $xValue); |
|
109 | + $this->di->set((string) $xKey, $xValue); |
|
110 | 110 | } |
111 | 111 | $aOptions = $xConfig->getOption('container.val', []); |
112 | - foreach($aOptions as $xKey => $xValue) |
|
112 | + foreach ($aOptions as $xKey => $xValue) |
|
113 | 113 | { |
114 | 114 | // The key is the class name. It must be a string. |
115 | - $this->di->val((string)$xKey, $xValue); |
|
115 | + $this->di->val((string) $xKey, $xValue); |
|
116 | 116 | } |
117 | 117 | $aOptions = $xConfig->getOption('container.auto', []); |
118 | - foreach($aOptions as $xValue) |
|
118 | + foreach ($aOptions as $xValue) |
|
119 | 119 | { |
120 | 120 | // The key is the class name. It must be a string. |
121 | - $this->di->auto((string)$xValue); |
|
121 | + $this->di->auto((string) $xValue); |
|
122 | 122 | } |
123 | 123 | $aOptions = $xConfig->getOption('container.alias', []); |
124 | - foreach($aOptions as $xKey => $xValue) |
|
124 | + foreach ($aOptions as $xKey => $xValue) |
|
125 | 125 | { |
126 | 126 | // The key is the class name. It must be a string. |
127 | - $this->di->alias((string)$xKey, (string)$xValue); |
|
127 | + $this->di->alias((string) $xKey, (string) $xValue); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function registerCallables(array $aOptions, string $sCallableType) |
141 | 141 | { |
142 | - foreach($aOptions as $xKey => $xValue) |
|
142 | + foreach ($aOptions as $xKey => $xValue) |
|
143 | 143 | { |
144 | - if(is_integer($xKey) && is_string($xValue)) |
|
144 | + if (is_integer($xKey) && is_string($xValue)) |
|
145 | 145 | { |
146 | 146 | // Register a function without options |
147 | 147 | $this->xPluginManager->registerCallable($sCallableType, $xValue); |
148 | 148 | } |
149 | - elseif(is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
149 | + elseif (is_string($xKey) && (is_array($xValue) || is_string($xValue))) |
|
150 | 150 | { |
151 | 151 | // Register a function with options |
152 | 152 | $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | private function registerExceptionHandlers(Config $xConfig) |
165 | 165 | { |
166 | - foreach($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler) |
|
166 | + foreach ($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler) |
|
167 | 167 | { |
168 | 168 | $this->xCallbackManager->error($xExHandler, is_string($sExClass) ? $sExClass : ''); |
169 | 169 | } |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | { |
207 | 207 | // $this->aPackages contains packages config file paths. |
208 | 208 | $aLibOptions = $sClassName::config(); |
209 | - if(is_string($aLibOptions)) |
|
209 | + if (is_string($aLibOptions)) |
|
210 | 210 | { |
211 | 211 | // A string is supposed to be the path to a config file. |
212 | 212 | $aLibOptions = $this->xConfigManager->read($aLibOptions); |
213 | 213 | } |
214 | - elseif(!is_array($aLibOptions)) |
|
214 | + elseif (!is_array($aLibOptions)) |
|
215 | 215 | { |
216 | 216 | // Otherwise, anything else than an array is not accepted. |
217 | 217 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | { |
235 | 235 | $xOptionsProvider = $aUserOptions['provider'] ?? null; |
236 | 236 | // The user can provide a callable that returns the package options. |
237 | - if(is_callable($xOptionsProvider)) |
|
237 | + if (is_callable($xOptionsProvider)) |
|
238 | 238 | { |
239 | 239 | $aUserOptions = $xOptionsProvider($aUserOptions); |
240 | 240 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public function registerPackage(string $sClassName, array $aUserOptions) |
254 | 254 | { |
255 | 255 | $sClassName = trim($sClassName, '\\ '); |
256 | - if(!is_subclass_of($sClassName, Package::class)) |
|
256 | + if (!is_subclass_of($sClassName, Package::class)) |
|
257 | 257 | { |
258 | 258 | $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]); |
259 | 259 | throw new SetupException($sMessage); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | // Register packages |
299 | 299 | $aPackageConfig = $xAppConfig->getOption('packages', []); |
300 | - foreach($aPackageConfig as $sClassName => $aPkgOptions) |
|
300 | + foreach ($aPackageConfig as $sClassName => $aPkgOptions) |
|
301 | 301 | { |
302 | 302 | $this->registerPackage($sClassName, $aPkgOptions); |
303 | 303 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | private function setDiAttributes($xRegisteredObject, array $aDiOptions) |
35 | 35 | { |
36 | - foreach($aDiOptions as $sName => $sClass) |
|
36 | + foreach ($aDiOptions as $sName => $sClass) |
|
37 | 37 | { |
38 | 38 | // Set the protected attributes of the object |
39 | 39 | $cSetter = function($xInjectedObject) use($sName) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->setDiAttributes($xRegisteredObject, $aDiOptions); |
64 | 64 | |
65 | 65 | // Set the Jaxon request target in the helper |
66 | - if($xRegisteredObject instanceof CallableClass) |
|
66 | + if ($xRegisteredObject instanceof CallableClass) |
|
67 | 67 | { |
68 | 68 | // Set the protected attributes of the object |
69 | 69 | $cSetter = function() use($xTarget) { |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | $sReflectionClass = $sClassName . '_ReflectionClass'; |
92 | 92 | |
93 | 93 | // Prevent duplication |
94 | - if($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
94 | + if ($this->h($sReflectionClass)) // It's important not to use the class name here. |
|
95 | 95 | { |
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Make sure the registered class exists |
100 | - if(isset($aOptions['include'])) |
|
100 | + if (isset($aOptions['include'])) |
|
101 | 101 | { |
102 | 102 | require_once($aOptions['include']); |
103 | 103 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $this->val($sReflectionClass, new ReflectionClass($sClassName)); |
108 | 108 | } |
109 | - catch(ReflectionException $e) |
|
109 | + catch (ReflectionException $e) |
|
110 | 110 | { |
111 | 111 | $xTranslator = $this->g(Translator::class); |
112 | 112 | $sMessage = $xTranslator->trans('errors.class.invalid', ['name' => $sClassName]); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | }); |
131 | 131 | |
132 | 132 | // Register the user class, but only if the user didn't already. |
133 | - if(!$this->h($sClassName)) |
|
133 | + if (!$this->h($sClassName)) |
|
134 | 134 | { |
135 | 135 | $this->set($sClassName, function($di) use($sReflectionClass) { |
136 | 136 | return $this->make($di->g($sReflectionClass)); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // Initialize the user class instance |
140 | 140 | $this->xLibContainer->extend($sClassName, function($xRegisteredObject) |
141 | 141 | use($sCallableObject, $sClassName) { |
142 | - if($xRegisteredObject instanceof CallableClass) |
|
142 | + if ($xRegisteredObject instanceof CallableClass) |
|
143 | 143 | { |
144 | 144 | $cSetter = function($di) use($sClassName) { |
145 | 145 | // Set the protected attributes of the object |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $sPkgConfigKey = $this->getPackageConfigKey($sClassName); |
213 | 213 | $this->val($sPkgConfigKey, $xPkgConfig); |
214 | 214 | // Register the user class, but only if the user didn't already. |
215 | - if(!$this->h($sClassName)) |
|
215 | + if (!$this->h($sClassName)) |
|
216 | 216 | { |
217 | 217 | $this->set($sClassName, function() use($sClassName) { |
218 | 218 | return $this->make($sClassName); |
@@ -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; |