Completed
Push — master ( 0a9499...367e0c )
by Thierry
01:37
created
src/Request/Factory/Parameter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function make($xValue)
107 107
     {
108
-        if($xValue instanceof Contracts\Parameter)
108
+        if ($xValue instanceof Contracts\Parameter)
109 109
         {
110 110
             return $xValue;
111 111
         }
112
-        elseif(is_numeric($xValue))
112
+        elseif (is_numeric($xValue))
113 113
         {
114 114
             return new Parameter(self::NUMERIC_VALUE, $xValue);
115 115
         }
116
-        elseif(is_string($xValue))
116
+        elseif (is_string($xValue))
117 117
         {
118 118
             return new Parameter(self::QUOTED_VALUE, $xValue);
119 119
         }
120
-        elseif(is_bool($xValue))
120
+        elseif (is_bool($xValue))
121 121
         {
122 122
             return new Parameter(self::BOOL_VALUE, $xValue);
123 123
         }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     public function getScript()
162 162
     {
163 163
         $sJsCode = '';
164
-        switch($this->sType)
164
+        switch ($this->sType)
165 165
         {
166 166
         case self::FORM_VALUES:
167 167
             $sJsCode = $this->getJsCall('getFormValues', $this->xValue);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             $sJsCode = (string)$this->xValue;
189 189
             break;
190 190
         case self::JS_VALUE:
191
-            if(is_array($this->xValue) || is_object($this->xValue))
191
+            if (is_array($this->xValue) || is_object($this->xValue))
192 192
             {
193 193
                 // Unable to use double quotes here because they cannot be handled on client side.
194 194
                 // So we are using simple quotes even if the Json standard recommends double quotes.
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,20 +108,16 @@  discard block
 block discarded – undo
108 108
         if($xValue instanceof Contracts\Parameter)
109 109
         {
110 110
             return $xValue;
111
-        }
112
-        elseif(is_numeric($xValue))
111
+        } elseif(is_numeric($xValue))
113 112
         {
114 113
             return new Parameter(self::NUMERIC_VALUE, $xValue);
115
-        }
116
-        elseif(is_string($xValue))
114
+        } elseif(is_string($xValue))
117 115
         {
118 116
             return new Parameter(self::QUOTED_VALUE, $xValue);
119
-        }
120
-        elseif(is_bool($xValue))
117
+        } elseif(is_bool($xValue))
121 118
         {
122 119
             return new Parameter(self::BOOL_VALUE, $xValue);
123
-        }
124
-        else // if(is_array($xValue) || is_object($xValue))
120
+        } else // if(is_array($xValue) || is_object($xValue))
125 121
         {
126 122
             return new Parameter(self::JS_VALUE, $xValue);
127 123
         }
@@ -193,8 +189,7 @@  discard block
 block discarded – undo
193 189
                 // Unable to use double quotes here because they cannot be handled on client side.
194 190
                 // So we are using simple quotes even if the Json standard recommends double quotes.
195 191
                 $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT));
196
-            }
197
-            else
192
+            } else
198 193
             {
199 194
                 $sJsCode = (string)$this->xValue;
200 195
             }
Please login to merge, or discard this patch.
src/Request/Factory/JsCall.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -154,9 +154,9 @@
 block discarded – undo
154 154
      */
155 155
     public function addParameters(array $aParameters)
156 156
     {
157
-        foreach($aParameters as $xParameter)
157
+        foreach ($aParameters as $xParameter)
158 158
         {
159
-            if($xParameter instanceof JsCall)
159
+            if ($xParameter instanceof JsCall)
160 160
             {
161 161
                 $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}');
162 162
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -159,8 +159,7 @@
 block discarded – undo
159 159
             if($xParameter instanceof JsCall)
160 160
             {
161 161
                 $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}');
162
-            }
163
-            else
162
+            } else
164 163
             {
165 164
                 $this->pushParameter(Parameter::make($xParameter));
166 165
             }
Please login to merge, or discard this patch.
src/Request/Support/CallableFunction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function configure($sName, $sValue)
86 86
     {
87
-        switch($sName)
87
+        switch ($sName)
88 88
         {
89 89
         case 'class': // The user function is a method in the given class
90 90
             $this->xCallableFunction = [$sValue, $this->xCallableFunction];
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function call($aArgs = [])
141 141
     {
142
-        if(($this->sInclude))
142
+        if (($this->sInclude))
143 143
         {
144 144
             require_once $this->sInclude;
145 145
         }
146 146
 
147 147
         // If the function is an alias for a class method, then instanciate the class
148
-        if(is_array($this->xCallableFunction) && is_string($this->xCallableFunction[0]))
148
+        if (is_array($this->xCallableFunction) && is_string($this->xCallableFunction[0]))
149 149
         {
150 150
             $sClassName = $this->xCallableFunction[0];
151 151
             $this->xCallableFunction[0] = new $sClassName;
Please login to merge, or discard this patch.
src/Request/Support/CallableRepository.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         // Set the composer autoloader
86 86
         $sAutoloadFile = __DIR__ . '/../../../../../autoload.php';
87
-        if(file_exists($sAutoloadFile))
87
+        if (file_exists($sAutoloadFile))
88 88
         {
89 89
             $this->xAutoloader = require($sAutoloadFile);
90 90
         }
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
     private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = [])
116 116
     {
117 117
         $aOptions = $aDefaultOptions;
118
-        if(key_exists('separator', $aDirectoryOptions))
118
+        if (key_exists('separator', $aDirectoryOptions))
119 119
         {
120 120
             $aOptions['separator'] = $aDirectoryOptions['separator'];
121 121
         }
122
-        if(key_exists('protected', $aDirectoryOptions))
122
+        if (key_exists('protected', $aDirectoryOptions))
123 123
         {
124 124
             $aOptions['protected'] = $aDirectoryOptions['protected'];
125 125
         }
126
-        if(key_exists('*', $aDirectoryOptions))
126
+        if (key_exists('*', $aDirectoryOptions))
127 127
         {
128 128
             $aOptions = array_merge($aOptions, $aDirectoryOptions['*']);
129 129
         }
130
-        if(key_exists($sClassName, $aDirectoryOptions))
130
+        if (key_exists($sClassName, $aDirectoryOptions))
131 131
         {
132 132
             $aOptions = array_merge($aOptions, $aDirectoryOptions[$sClassName]);
133 133
         }
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
         $itDir = new RecursiveDirectoryIterator($sDirectory);
148 148
         $itFile = new RecursiveIteratorIterator($itDir);
149 149
         // Iterate on dir content
150
-        foreach($itFile as $xFile)
150
+        foreach ($itFile as $xFile)
151 151
         {
152 152
             // skip everything except PHP files
153
-            if(!$xFile->isFile() || $xFile->getExtension() != 'php')
153
+            if (!$xFile->isFile() || $xFile->getExtension() != 'php')
154 154
             {
155 155
                 continue;
156 156
             }
157 157
 
158 158
             $aClassOptions = [];
159 159
             // No more classmap autoloading. The file will be included when needed.
160
-            if(($aOptions['autoload']))
160
+            if (($aOptions['autoload']))
161 161
             {
162 162
                 $aClassOptions['include'] = $xFile->getPathname();
163 163
             }
@@ -178,26 +178,26 @@  discard block
 block discarded – undo
178 178
     public function addNamespace($sNamespace, array $aOptions)
179 179
     {
180 180
         // Separator default value
181
-        if(!key_exists('separator', $aOptions))
181
+        if (!key_exists('separator', $aOptions))
182 182
         {
183 183
             $aOptions['separator'] = '.';
184 184
         }
185 185
         $aOptions['separator'] = trim($aOptions['separator']);
186
-        if(!in_array($aOptions['separator'], ['.', '_']))
186
+        if (!in_array($aOptions['separator'], ['.', '_']))
187 187
         {
188 188
             $aOptions['separator'] = '.';
189 189
         }
190
-        if($aOptions['separator'] == '_')
190
+        if ($aOptions['separator'] == '_')
191 191
         {
192 192
             $this->bUsingUnderscore = true;
193 193
         }
194 194
         // Set the autoload option default value
195
-        if(!key_exists('autoload', $aOptions))
195
+        if (!key_exists('autoload', $aOptions))
196 196
         {
197 197
             $aOptions['autoload'] = true;
198 198
         }
199 199
         // Register the dir with PSR4 autoloading
200
-        if(($aOptions['autoload']) && $this->xAutoloader != null)
200
+        if (($aOptions['autoload']) && $this->xAutoloader != null)
201 201
         {
202 202
             $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']);
203 203
         }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     private function getOptionsFromClass($sClassName)
216 216
     {
217
-        if(!key_exists($sClassName, $this->aClassOptions))
217
+        if (!key_exists($sClassName, $this->aClassOptions))
218 218
         {
219 219
             return null; // Class not registered
220 220
         }
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
     private function getOptionsFromNamespace($sClassName, $sNamespace = null)
233 233
     {
234 234
         // Find the corresponding namespace
235
-        if($sNamespace === null)
235
+        if ($sNamespace === null)
236 236
         {
237
-            foreach(array_keys($this->aNamespaceOptions) as $_sNamespace)
237
+            foreach (array_keys($this->aNamespaceOptions) as $_sNamespace)
238 238
             {
239
-                if(substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\')
239
+                if (substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\')
240 240
                 {
241 241
                     $sNamespace = $_sNamespace;
242 242
                     break;
243 243
                 }
244 244
             }
245 245
         }
246
-        if($sNamespace === null)
246
+        if ($sNamespace === null)
247 247
         {
248 248
             return null; // Class not registered
249 249
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         // Get the class options
252 252
         $aOptions = $this->aNamespaceOptions[$sNamespace];
253 253
         $aDefaultOptions = ['namespace' => $sNamespace];
254
-        if(key_exists('separator', $aOptions))
254
+        if (key_exists('separator', $aOptions))
255 255
         {
256 256
             $aDefaultOptions['separator'] = $aOptions['separator'];
257 257
         }
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
     protected function _getCallableObject($sClassName, array $aOptions)
270 270
     {
271 271
         // Make sure the registered class exists
272
-        if(key_exists('include', $aOptions))
272
+        if (key_exists('include', $aOptions))
273 273
         {
274 274
             require_once($aOptions['include']);
275 275
         }
276
-        if(!class_exists($sClassName))
276
+        if (!class_exists($sClassName))
277 277
         {
278 278
             return null;
279 279
         }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
         // Create the callable object
282 282
         $xCallableObject = new CallableObject($sClassName);
283 283
         $this->aCallableOptions[$sClassName] = [];
284
-        foreach($aOptions as $sName => $xValue)
284
+        foreach ($aOptions as $sName => $xValue)
285 285
         {
286
-            if(in_array($sName, ['separator', 'namespace', 'protected']))
286
+            if (in_array($sName, ['separator', 'namespace', 'protected']))
287 287
             {
288 288
                 $xCallableObject->configure($sName, $xValue);
289 289
             }
290
-            elseif(is_array($xValue) && $sName != 'include')
290
+            elseif (is_array($xValue) && $sName != 'include')
291 291
             {
292 292
                 // These options are to be included in javascript code.
293 293
                 $this->aCallableOptions[$sClassName][$sName] = $xValue;
@@ -324,22 +324,22 @@  discard block
 block discarded – undo
324 324
         // at the beginning and the end of the class name.
325 325
         $sClassName = (string)$sClassName;
326 326
         $sClassName = trim(str_replace('.', '\\', $sClassName), '\\');
327
-        if($this->bUsingUnderscore)
327
+        if ($this->bUsingUnderscore)
328 328
         {
329 329
             $sClassName = trim(str_replace('_', '\\', $sClassName), '\\');
330 330
         }
331 331
 
332
-        if(key_exists($sClassName, $this->aCallableObjects))
332
+        if (key_exists($sClassName, $this->aCallableObjects))
333 333
         {
334 334
             return $this->aCallableObjects[$sClassName];
335 335
         }
336 336
 
337 337
         $aOptions = $this->getOptionsFromClass($sClassName);
338
-        if($aOptions === null)
338
+        if ($aOptions === null)
339 339
         {
340 340
             $aOptions = $this->getOptionsFromNamespace($sClassName);
341 341
         }
342
-        if($aOptions === null)
342
+        if ($aOptions === null)
343 343
         {
344 344
             return null;
345 345
         }
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
     public function createCallableObjects()
356 356
     {
357 357
         // Create callable objects for registered classes
358
-        foreach($this->aClassOptions as $sClassName => $aClassOptions)
358
+        foreach ($this->aClassOptions as $sClassName => $aClassOptions)
359 359
         {
360
-            if(!key_exists($sClassName, $this->aCallableObjects))
360
+            if (!key_exists($sClassName, $this->aCallableObjects))
361 361
             {
362 362
                 $this->_getCallableObject($sClassName, $aClassOptions);
363 363
             }
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 
366 366
         // Create callable objects for registered namespaces
367 367
         $sDS = DIRECTORY_SEPARATOR;
368
-        foreach($this->aNamespaceOptions as $sNamespace => $aOptions)
368
+        foreach ($this->aNamespaceOptions as $sNamespace => $aOptions)
369 369
         {
370
-            if(key_exists($sNamespace, $this->aNamespaces))
370
+            if (key_exists($sNamespace, $this->aNamespaces))
371 371
             {
372 372
                 continue;
373 373
             }
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
             $sDirectory = $aOptions['directory'];
379 379
             $itDir = new RecursiveDirectoryIterator($sDirectory);
380 380
             $itFile = new RecursiveIteratorIterator($itDir);
381
-            foreach($itFile as $xFile)
381
+            foreach ($itFile as $xFile)
382 382
             {
383 383
                 // skip everything except PHP files
384
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
384
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
385 385
                 {
386 386
                     continue;
387 387
                 }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                 $sClassPath = $sNamespace;
391 391
                 $sRelativePath = substr($xFile->getPath(), strlen($sDirectory));
392 392
                 $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\');
393
-                if($sRelativePath != '')
393
+                if ($sRelativePath != '')
394 394
                 {
395 395
                     $sClassPath .= '\\' . $sRelativePath;
396 396
                 }
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
                 $this->aNamespaces[$sClassPath] = ['separator' => $aOptions['separator']];
399 399
                 $sClassName = $sClassPath . '\\' . $xFile->getBasename('.php');
400 400
 
401
-                if(!key_exists($sClassName, $this->aCallableObjects))
401
+                if (!key_exists($sClassName, $this->aCallableObjects))
402 402
                 {
403 403
                     $aClassOptions = $this->getOptionsFromNamespace($sClassName, $sNamespace);
404
-                    if($aClassOptions !== null)
404
+                    if ($aClassOptions !== null)
405 405
                     {
406 406
                         $this->_getCallableObject($sClassName, $aClassOptions);
407 407
                     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -286,8 +286,7 @@
 block discarded – undo
286 286
             if(in_array($sName, ['separator', 'namespace', 'protected']))
287 287
             {
288 288
                 $xCallableObject->configure($sName, $xValue);
289
-            }
290
-            elseif(is_array($xValue) && $sName != 'include')
289
+            } elseif(is_array($xValue) && $sName != 'include')
291 290
             {
292 291
                 // These options are to be included in javascript code.
293 292
                 $this->aCallableOptions[$sClassName][$sName] = $xValue;
Please login to merge, or discard this patch.
src/Request/Support/CallableObject.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -138,29 +138,29 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function configure($sName, $sValue)
140 140
     {
141
-        switch($sName)
141
+        switch ($sName)
142 142
         {
143 143
         // Set the separator
144 144
         case 'separator':
145
-            if($sValue == '_' || $sValue == '.')
145
+            if ($sValue == '_' || $sValue == '.')
146 146
             {
147 147
                 $this->sSeparator = $sValue;
148 148
             }
149 149
             break;
150 150
         // Set the namespace
151 151
         case 'namespace':
152
-            if(is_string($sValue))
152
+            if (is_string($sValue))
153 153
             {
154 154
                 $this->sNamespace = $sValue;
155 155
             }
156 156
             break;
157 157
         // Set the protected methods
158 158
         case 'protected':
159
-            if(is_array($sValue))
159
+            if (is_array($sValue))
160 160
             {
161 161
                 $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
162 162
             }
163
-            elseif(is_string($sValue))
163
+            elseif (is_string($sValue))
164 164
             {
165 165
                 $this->aProtectedMethods[] = $sValue;
166 166
             }
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
     public function getMethods()
179 179
     {
180 180
         $aMethods = [];
181
-        foreach($this->xReflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
181
+        foreach ($this->xReflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
182 182
         {
183 183
             $sMethodName = $xMethod->getShortName();
184 184
             // Don't take magic __call, __construct, __destruct methods
185
-            if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
185
+            if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
186 186
             {
187 187
                 continue;
188 188
             }
189 189
             // Don't take excluded methods
190
-            if(in_array($sMethodName, $this->aProtectedMethods))
190
+            if (in_array($sMethodName, $this->aProtectedMethods))
191 191
             {
192 192
                 continue;
193 193
             }
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function getRegisteredObject()
205 205
     {
206
-        if($this->xRegisteredObject == null)
206
+        if ($this->xRegisteredObject == null)
207 207
         {
208 208
             $di = jaxon()->di();
209 209
             // Use the Reflection class to get the parameters of the constructor
210
-            if(($constructor = $this->xReflectionClass->getConstructor()) != null)
210
+            if (($constructor = $this->xReflectionClass->getConstructor()) != null)
211 211
             {
212 212
                 $parameters = $constructor->getParameters();
213 213
                 $parameterInstances = [];
214
-                foreach($parameters as $parameter)
214
+                foreach ($parameters as $parameter)
215 215
                 {
216 216
                     // Get the parameter instance from the DI
217 217
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             }
225 225
 
226 226
             // Initialize the object
227
-            if($this->xRegisteredObject instanceof \Jaxon\CallableClass)
227
+            if ($this->xRegisteredObject instanceof \Jaxon\CallableClass)
228 228
             {
229 229
                 $this->xRegisteredObject->response = jaxon()->getResponse();
230 230
             }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function call($sMethod, $aArgs)
256 256
     {
257
-        if(!$this->hasMethod($sMethod))
257
+        if (!$this->hasMethod($sMethod))
258 258
         {
259 259
             return;
260 260
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,8 +159,7 @@  discard block
 block discarded – undo
159 159
             if(is_array($sValue))
160 160
             {
161 161
                 $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
162
-            }
163
-            elseif(is_string($sValue))
162
+            } elseif(is_string($sValue))
164 163
             {
165 164
                 $this->aProtectedMethods[] = $sValue;
166 165
             }
@@ -217,8 +216,7 @@  discard block
 block discarded – undo
217 216
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
218 217
                 }
219 218
                 $this->xRegisteredObject = $this->xReflectionClass->newInstanceArgs($parameterInstances);
220
-            }
221
-            else
219
+            } else
222 220
             {
223 221
                 $this->xRegisteredObject = $this->xReflectionClass->newInstance();
224 222
             }
Please login to merge, or discard this patch.
src/Request/Handler/Callback.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function before($xCallable = null)
53 53
     {
54
-        if($xCallable === null)
54
+        if ($xCallable === null)
55 55
         {
56 56
             return $this->xBeforeCallback;
57 57
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function after($xCallable = null)
69 69
     {
70
-        if($xCallable === null)
70
+        if ($xCallable === null)
71 71
         {
72 72
             return $this->xAfterCallback;
73 73
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function invalid($xCallable = null)
85 85
     {
86
-        if($xCallable === null)
86
+        if ($xCallable === null)
87 87
         {
88 88
             return $this->xInvalidCallback;
89 89
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function error($xCallable = null)
101 101
     {
102
-        if($xCallable === null)
102
+        if ($xCallable === null)
103 103
         {
104 104
             return $this->xErrorCallback;
105 105
         }
Please login to merge, or discard this patch.
src/Request/Plugin/CallableDir.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -68,47 +68,47 @@
 block discarded – undo
68 68
     public function register($sType, $sDirectory, $aOptions)
69 69
     {
70 70
         $sType = trim($sType);
71
-        if($sType != $this->getName())
71
+        if ($sType != $this->getName())
72 72
         {
73 73
             return false;
74 74
         }
75 75
 
76
-        if(!is_string($sDirectory) || !is_dir($sDirectory))
76
+        if (!is_string($sDirectory) || !is_dir($sDirectory))
77 77
         {
78 78
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
79 79
         }
80
-        if(is_string($aOptions))
80
+        if (is_string($aOptions))
81 81
         {
82 82
             $aOptions = ['namespace' => $aOptions];
83 83
         }
84
-        if(!is_array($aOptions))
84
+        if (!is_array($aOptions))
85 85
         {
86 86
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
87 87
         }
88 88
 
89 89
         $sDirectory = rtrim(trim($sDirectory), '/\\');
90
-        if(!is_dir($sDirectory))
90
+        if (!is_dir($sDirectory))
91 91
         {
92 92
             return false;
93 93
         }
94 94
         $aOptions['directory'] = realpath($sDirectory);
95 95
 
96 96
         $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : '';
97
-        if(!($sNamespace = trim($sNamespace, ' \\')))
97
+        if (!($sNamespace = trim($sNamespace, ' \\')))
98 98
         {
99 99
             $sNamespace = '';
100 100
         }
101 101
 
102 102
         // Change the keys in $aOptions to have "\" as separator
103 103
         $_aOptions = [];
104
-        foreach($aOptions as $sName => $aOption)
104
+        foreach ($aOptions as $sName => $aOption)
105 105
         {
106 106
             $sName = trim(str_replace('.', '\\', $sName), ' \\');
107 107
             $_aOptions[$sName] = $aOption;
108 108
         }
109 109
         $aOptions = $_aOptions;
110 110
 
111
-        if(($sNamespace))
111
+        if (($sNamespace))
112 112
         {
113 113
             $this->xRepository->addNamespace($sNamespace, $aOptions);
114 114
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@
 block discarded – undo
111 111
         if(($sNamespace))
112 112
         {
113 113
             $this->xRepository->addNamespace($sNamespace, $aOptions);
114
-        }
115
-        else
114
+        } else
116 115
         {
117 116
             $this->xRepository->addDirectory($sDirectory, $aOptions);
118 117
         }
Please login to merge, or discard this patch.
src/Request/Plugin/CallableClass.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $this->xRepository = $xRepository;
66 66
 
67
-        if(!empty($_GET['jxncls']))
67
+        if (!empty($_GET['jxncls']))
68 68
         {
69 69
             $this->sRequestedClass = trim($_GET['jxncls']);
70 70
         }
71
-        if(!empty($_GET['jxnmthd']))
71
+        if (!empty($_GET['jxnmthd']))
72 72
         {
73 73
             $this->sRequestedMethod = trim($_GET['jxnmthd']);
74 74
         }
75
-        if(!empty($_POST['jxncls']))
75
+        if (!empty($_POST['jxncls']))
76 76
         {
77 77
             $this->sRequestedClass = trim($_POST['jxncls']);
78 78
         }
79
-        if(!empty($_POST['jxnmthd']))
79
+        if (!empty($_POST['jxnmthd']))
80 80
         {
81 81
             $this->sRequestedMethod = trim($_POST['jxnmthd']);
82 82
         }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function getTarget()
101 101
     {
102
-        if(!$this->sRequestedClass || !$this->sRequestedMethod)
102
+        if (!$this->sRequestedClass || !$this->sRequestedMethod)
103 103
         {
104 104
             return null;
105 105
         }
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
     public function register($sType, $sClassName, $aOptions)
119 119
     {
120 120
         $sType = trim($sType);
121
-        if($sType != $this->getName())
121
+        if ($sType != $this->getName())
122 122
         {
123 123
             return false;
124 124
         }
125 125
 
126
-        if(!is_string($sClassName))
126
+        if (!is_string($sClassName))
127 127
         {
128 128
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
129 129
         }
130
-        if(is_string($aOptions))
130
+        if (is_string($aOptions))
131 131
         {
132 132
             $aOptions = ['include' => $aOptions];
133 133
         }
134
-        if(!is_array($aOptions))
134
+        if (!is_array($aOptions))
135 135
         {
136 136
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
137 137
         }
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
         $aCallableObjects = $this->xRepository->getCallableObjects();
155 155
         $sHash = '';
156 156
 
157
-        foreach($aNamespaces as $sNamespace => $aOptions)
157
+        foreach ($aNamespaces as $sNamespace => $aOptions)
158 158
         {
159 159
             $sHash .= $sNamespace . $aOptions['separator'];
160 160
         }
161
-        foreach($aCallableObjects as $sClassName => $xCallableObject)
161
+        foreach ($aCallableObjects as $sClassName => $xCallableObject)
162 162
         {
163 163
             $sHash .= $sClassName . implode('|', $xCallableObject->getMethods());
164 164
         }
@@ -183,21 +183,21 @@  discard block
 block discarded – undo
183 183
 
184 184
         $xCallableClass = new \ReflectionClass(UserCallableClass::class);
185 185
         $aCallableMethods = [];
186
-        foreach($xCallableClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
186
+        foreach ($xCallableClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
187 187
         {
188 188
             $aCallableMethods[] = $xMethod->getName();
189 189
         }
190 190
 
191
-        foreach(array_keys($aNamespaces) as $sNamespace)
191
+        foreach (array_keys($aNamespaces) as $sNamespace)
192 192
         {
193 193
             $offset = 0;
194 194
             $sJsNamespace = str_replace('\\', '.', $sNamespace);
195 195
             $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop.
196
-            while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false)
196
+            while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false)
197 197
             {
198 198
                 $sJsClass = substr($sJsNamespace, 0, $dotPosition);
199 199
                 // Generate code for this object
200
-                if(!key_exists($sJsClass, $aJsClasses))
200
+                if (!key_exists($sJsClass, $aJsClasses))
201 201
                 {
202 202
                     $sCode .= "$sPrefix$sJsClass = {};\n";
203 203
                     $aJsClasses[$sJsClass] = $sJsClass;
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
             }
207 207
         }
208 208
 
209
-        foreach($aCallableObjects as $sClassName => $xCallableObject)
209
+        foreach ($aCallableObjects as $sClassName => $xCallableObject)
210 210
         {
211 211
             $aConfig = $aCallableOptions[$sClassName];
212 212
             $aCommonConfig = key_exists('*', $aConfig) ? $aConfig['*'] : [];
213 213
 
214 214
             $aProtectedMethods = is_subclass_of($sClassName, UserCallableClass::class) ? $aCallableMethods : [];
215 215
             $aMethods = [];
216
-            foreach($xCallableObject->getMethods() as $sMethodName)
216
+            foreach ($xCallableObject->getMethods() as $sMethodName)
217 217
             {
218 218
                 // Don't export methods of the CallableClass class
219
-                if(in_array($sMethodName, $aProtectedMethods))
219
+                if (in_array($sMethodName, $aProtectedMethods))
220 220
                 {
221 221
                     continue;
222 222
                 }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     public function canProcessRequest()
248 248
     {
249 249
         // Check the validity of the class name
250
-        if(($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) ||
250
+        if (($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) ||
251 251
             ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)))
252 252
         {
253 253
             $this->sRequestedClass = null;
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function processRequest()
265 265
     {
266
-        if(!$this->canProcessRequest())
266
+        if (!$this->canProcessRequest())
267 267
         {
268 268
             return false;
269 269
         }
270 270
 
271 271
         // Find the requested method
272 272
         $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass);
273
-        if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
273
+        if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
274 274
         {
275 275
             // Unable to find the requested object or method
276 276
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid',
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $di = jaxon()->di();
282 282
         $aArgs = $di->getRequestHandler()->processArguments();
283 283
         $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs);
284
-        if(($xResponse))
284
+        if (($xResponse))
285 285
         {
286 286
             $di->getResponseManager()->append($xResponse);
287 287
         }
Please login to merge, or discard this patch.
src/Request/Handler.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     public function onBefore(&$bEndRequest)
147 147
     {
148 148
         // Call the user defined callback
149
-        if(($xCallback = $this->xCallbackManager->before()))
149
+        if (($xCallback = $this->xCallbackManager->before()))
150 150
         {
151 151
             call_user_func_array($xCallback, [$this->xTargetRequestPlugin->getTarget(), &$bEndRequest]);
152 152
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     public function onAfter($bEndRequest)
162 162
     {
163
-        if(($xCallback = $this->xCallbackManager->after()))
163
+        if (($xCallback = $this->xCallbackManager->after()))
164 164
         {
165 165
             call_user_func_array($xCallback, [$this->xTargetRequestPlugin->getTarget(), $bEndRequest]);
166 166
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function onInvalid($sMessage)
176 176
     {
177
-        if(($xCallback = $this->xCallbackManager->invalid()))
177
+        if (($xCallback = $this->xCallbackManager->invalid()))
178 178
         {
179 179
             call_user_func_array($xCallback, [$sMessage]);
180 180
         }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function onError(Exception $xException)
190 190
     {
191
-        if(($xCallback = $this->xCallbackManager->error()))
191
+        if (($xCallback = $this->xCallbackManager->error()))
192 192
         {
193 193
             call_user_func_array($xCallback, [$xException]);
194 194
         }
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
     public function canProcessRequest()
210 210
     {
211 211
         // Return true if the request plugin was already found
212
-        if(($this->xTargetRequestPlugin))
212
+        if (($this->xTargetRequestPlugin))
213 213
         {
214 214
             return true;
215 215
         }
216 216
 
217 217
         // Find a plugin to process the request
218
-        foreach($this->xPluginManager->getRequestPlugins() as $xPlugin)
218
+        foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin)
219 219
         {
220
-            if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
220
+            if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
221 221
             {
222 222
                 $this->xTargetRequestPlugin = $xPlugin;
223 223
                 return true;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     public function processRequest()
242 242
     {
243 243
         // Check to see if headers have already been sent out, in which case we can't do our job
244
-        if(headers_sent($filename, $linenumber))
244
+        if (headers_sent($filename, $linenumber))
245 245
         {
246 246
             echo $this->trans('errors.output.already-sent', [
247 247
                 'location' => $filename . ':' . $linenumber
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         }
251 251
 
252 252
         // Check if there is a plugin to process this request
253
-        if(!$this->canProcessRequest())
253
+        if (!$this->canProcessRequest())
254 254
         {
255 255
             return;
256 256
         }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
         $bEndRequest = false;
259 259
 
260 260
         // Handle before processing event
261
-        if(($this->xTargetRequestPlugin))
261
+        if (($this->xTargetRequestPlugin))
262 262
         {
263 263
             $this->onBefore($bEndRequest);
264 264
         }
265 265
 
266
-        if(!$bEndRequest)
266
+        if (!$bEndRequest)
267 267
         {
268 268
             try
269 269
             {
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
                 $this->xUploadRequestPlugin->processRequest();
272 272
 
273 273
                 // Process the request
274
-                if(($this->xTargetRequestPlugin))
274
+                if (($this->xTargetRequestPlugin))
275 275
                 {
276 276
                     $this->xTargetRequestPlugin->processRequest();
277 277
                 }
278 278
             }
279
-            catch(Exception $e)
279
+            catch (Exception $e)
280 280
             {
281 281
                 // An exception was thrown while processing the request.
282 282
                 // The request missed the corresponding handler function,
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
                 $this->xResponseManager->error($e->getMessage());
286 286
 
287
-                if($e instanceof \Jaxon\Exception\Error)
287
+                if ($e instanceof \Jaxon\Exception\Error)
288 288
                 {
289 289
                     $this->onInvalid($e->getMessage());
290 290
                 }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         }
297 297
 
298 298
         // Clean the processing buffer
299
-        if(($this->getOption('core.process.clean')))
299
+        if (($this->getOption('core.process.clean')))
300 300
         {
301 301
             $er = error_reporting(0);
302 302
             while (ob_get_level() > 0)
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
             error_reporting($er);
307 307
         }
308 308
 
309
-        if(($this->xTargetRequestPlugin))
309
+        if (($this->xTargetRequestPlugin))
310 310
         {
311 311
             // Handle after processing event
312 312
             $this->onAfter($bEndRequest);
313 313
         }
314 314
 
315 315
         // If the called function returned no response, take the the global response
316
-        if(!$this->xResponseManager->getResponse())
316
+        if (!$this->xResponseManager->getResponse())
317 317
         {
318 318
             $this->xResponseManager->append(jaxon()->getResponse());
319 319
         }
320 320
 
321 321
         $this->xResponseManager->printDebug();
322 322
 
323
-        if(($this->getOption('core.response.send')))
323
+        if (($this->getOption('core.response.send')))
324 324
         {
325 325
             $this->xResponseManager->sendOutput();
326 326
         }
327 327
 
328
-        if(($this->getOption('core.process.exit')))
328
+        if (($this->getOption('core.process.exit')))
329 329
         {
330 330
             exit();
331 331
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -191,8 +191,7 @@  discard block
 block discarded – undo
191 191
         if(($xCallback = $this->xCallbackManager->error()))
192 192
         {
193 193
             call_user_func_array($xCallback, [$xException]);
194
-        }
195
-        else
194
+        } else
196 195
         {
197 196
             throw $xException;
198 197
         }
@@ -275,8 +274,7 @@  discard block
 block discarded – undo
275 274
                 {
276 275
                     $this->xTargetRequestPlugin->processRequest();
277 276
                 }
278
-            }
279
-            catch(Exception $e)
277
+            } catch(Exception $e)
280 278
             {
281 279
                 // An exception was thrown while processing the request.
282 280
                 // The request missed the corresponding handler function,
@@ -287,8 +285,7 @@  discard block
 block discarded – undo
287 285
                 if($e instanceof \Jaxon\Exception\Error)
288 286
                 {
289 287
                     $this->onInvalid($e->getMessage());
290
-                }
291
-                else
288
+                } else
292 289
                 {
293 290
                     $this->onError($e);
294 291
                 }
Please login to merge, or discard this patch.