Completed
Push — master ( 791f1f...546eff )
by Thierry
01:43
created
src/Request/Plugin/CallableObject.php 2 patches
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
         $this->sRequestedClass = null;
92 92
         $this->sRequestedMethod = null;
93 93
 
94
-        if(!empty($_GET['jxncls']))
94
+        if (!empty($_GET['jxncls']))
95 95
         {
96 96
             $this->sRequestedClass = $_GET['jxncls'];
97 97
         }
98
-        if(!empty($_GET['jxnmthd']))
98
+        if (!empty($_GET['jxnmthd']))
99 99
         {
100 100
             $this->sRequestedMethod = $_GET['jxnmthd'];
101 101
         }
102
-        if(!empty($_POST['jxncls']))
102
+        if (!empty($_POST['jxncls']))
103 103
         {
104 104
             $this->sRequestedClass = $_POST['jxncls'];
105 105
         }
106
-        if(!empty($_POST['jxnmthd']))
106
+        if (!empty($_POST['jxnmthd']))
107 107
         {
108 108
             $this->sRequestedMethod = $_POST['jxnmthd'];
109 109
         }
@@ -152,19 +152,19 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function register($aArgs)
154 154
     {
155
-        if(count($aArgs) < 2)
155
+        if (count($aArgs) < 2)
156 156
         {
157 157
             return false;
158 158
         }
159 159
 
160 160
         $sType = $aArgs[0];
161
-        if($sType != Jaxon::CALLABLE_OBJECT)
161
+        if ($sType != Jaxon::CALLABLE_OBJECT)
162 162
         {
163 163
             return false;
164 164
         }
165 165
 
166 166
         $sCallableObject = $aArgs[1];
167
-        if(!is_string($sCallableObject) || !class_exists($sCallableObject))
167
+        if (!is_string($sCallableObject) || !class_exists($sCallableObject))
168 168
         {
169 169
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
170 170
         }
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
         $this->aCallableObjects[] = $sCallableObject;
173 173
 
174 174
         $aOptions = count($aArgs) > 2 ? $aArgs[2] : [];
175
-        if(is_string($aOptions))
175
+        if (is_string($aOptions))
176 176
         {
177 177
             $aOptions = ['namespace' => $aOptions];
178 178
         }
179
-        if(!is_array($aOptions))
179
+        if (!is_array($aOptions))
180 180
         {
181 181
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
182 182
         }
183 183
 
184 184
         // Save the classpath and the separator in this class
185
-        if(key_exists('*', $aOptions) && is_array($aOptions['*']))
185
+        if (key_exists('*', $aOptions) && is_array($aOptions['*']))
186 186
         {
187 187
             $_aOptions = $aOptions['*'];
188 188
             $sSeparator = '.';
189
-            if(key_exists('separator', $_aOptions))
189
+            if (key_exists('separator', $_aOptions))
190 190
             {
191 191
                 $sSeparator = trim($_aOptions['separator']);
192 192
             }
193
-            if(!in_array($sSeparator, ['.', '_']))
193
+            if (!in_array($sSeparator, ['.', '_']))
194 194
             {
195 195
                 $sSeparator = '.';
196 196
             }
197 197
             $_aOptions['separator'] = $sSeparator;
198 198
 
199
-            if(array_key_exists('classpath', $_aOptions))
199
+            if (array_key_exists('classpath', $_aOptions))
200 200
             {
201 201
                 $_aOptions['classpath'] = trim($_aOptions['classpath'], ' \\._');
202 202
                 // Save classpath with "\" in the parameters
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
         jaxon()->di()->set($sUserFunction, function() use($sCallableObject, $aOptions) {
210 210
             $xCallableObject = new \Jaxon\Request\Support\CallableObject($sCallableObject);
211 211
 
212
-            foreach($aOptions as $sMethod => $aValue)
212
+            foreach ($aOptions as $sMethod => $aValue)
213 213
             {
214
-                foreach($aValue as $sName => $sValue)
214
+                foreach ($aValue as $sName => $sValue)
215 215
                 {
216 216
                     $xCallableObject->configure($sMethod, $sName, $sValue);
217 217
                 }
@@ -235,37 +235,37 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function addClassDir($sDirectory, $sNamespace = '', $sSeparator = '.', array $aProtected = [])
237 237
     {
238
-        if(!is_dir(($sDirectory = trim($sDirectory))))
238
+        if (!is_dir(($sDirectory = trim($sDirectory))))
239 239
         {
240 240
             return false;
241 241
         }
242 242
         // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead.
243
-        if(($sSeparator = trim($sSeparator)) != '_')
243
+        if (($sSeparator = trim($sSeparator)) != '_')
244 244
         {
245 245
             $sSeparator = '.';
246 246
         }
247
-        if(!($sNamespace = trim($sNamespace, ' \\')))
247
+        if (!($sNamespace = trim($sNamespace, ' \\')))
248 248
         {
249 249
             $sNamespace = '';
250 250
         }
251
-        if(($sNamespace))
251
+        if (($sNamespace))
252 252
         {
253 253
             // If there is an autoloader, register the dir with PSR4 autoloading
254
-            if(($this->xAutoloader))
254
+            if (($this->xAutoloader))
255 255
             {
256 256
                 $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory);
257 257
             }
258 258
         }
259
-        elseif(($this->xAutoloader))
259
+        elseif (($this->xAutoloader))
260 260
         {
261 261
             // If there is an autoloader, register the dir with classmap autoloading
262 262
             $itDir = new RecursiveDirectoryIterator($sDirectory);
263 263
             $itFile = new RecursiveIteratorIterator($itDir);
264 264
             // Iterate on dir content
265
-            foreach($itFile as $xFile)
265
+            foreach ($itFile as $xFile)
266 266
             {
267 267
                 // skip everything except PHP files
268
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
268
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
269 269
                 {
270 270
                     continue;
271 271
                 }
@@ -301,33 +301,33 @@  discard block
 block discarded – undo
301 301
         $sClassPath = substr($xFile->getPath(), strlen($sDirectory));
302 302
         $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS));
303 303
         $sClassName = $xFile->getBasename('.php');
304
-        if(($sNamespace))
304
+        if (($sNamespace))
305 305
         {
306 306
             $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace;
307 307
             $sClassName = '\\' . $sClassPath . '\\' . $sClassName;
308 308
         }
309 309
         // Require the file only if autoload is enabled but there is no autoloader
310
-        if(($this->bAutoloadEnabled) && !($this->xAutoloader))
310
+        if (($this->bAutoloadEnabled) && !($this->xAutoloader))
311 311
         {
312 312
             require_once($xFile->getPathname());
313 313
         }
314 314
         // Create and register an instance of the class
315
-        if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*']))
315
+        if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*']))
316 316
         {
317 317
             $aOptions['*'] = [];
318 318
         }
319 319
         $aOptions['*']['separator'] = $sSeparator;
320
-        if(($sNamespace))
320
+        if (($sNamespace))
321 321
         {
322 322
             $aOptions['*']['namespace'] = $sNamespace;
323 323
         }
324
-        if(($sClassPath))
324
+        if (($sClassPath))
325 325
         {
326 326
             $aOptions['*']['classpath'] = $sClassPath;
327 327
         }
328 328
         // Filter excluded methods
329
-        $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);});
330
-        if(count($aProtected) > 0)
329
+        $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); });
330
+        if (count($aProtected) > 0)
331 331
         {
332 332
             $aOptions['*']['protected'] = $aProtected;
333 333
         }
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
         $sDS = DIRECTORY_SEPARATOR;
347 347
         // Change the keys in $aOptions to have "\" as separator
348 348
         $aNewOptions = [];
349
-        foreach($aOptions as $key => $aOption)
349
+        foreach ($aOptions as $key => $aOption)
350 350
         {
351 351
             $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\');
352 352
             $aNewOptions[$key] = $aOption;
353 353
         }
354 354
 
355
-        foreach($this->aClassDirs as $aClassDir)
355
+        foreach ($this->aClassDirs as $aClassDir)
356 356
         {
357 357
             // Get the directory
358 358
             $sDirectory = $aClassDir['directory'];
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
             $itDir = new RecursiveDirectoryIterator($sDirectory);
363 363
             $itFile = new RecursiveIteratorIterator($itDir);
364 364
             // Iterate on dir content
365
-            foreach($itFile as $xFile)
365
+            foreach ($itFile as $xFile)
366 366
             {
367 367
                 // skip everything except PHP files
368
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
368
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
369 369
                 {
370 370
                     continue;
371 371
                 }
@@ -374,17 +374,17 @@  discard block
 block discarded – undo
374 374
                 $sClassPath = substr($xFile->getPath(), strlen($sDirectory));
375 375
                 $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\');
376 376
                 $sClassName = $xFile->getBasename('.php');
377
-                if(($sClassPath))
377
+                if (($sClassPath))
378 378
                 {
379 379
                     $sClassName = $sClassPath . '\\' . $sClassName;
380 380
                 }
381
-                if(($sNamespace))
381
+                if (($sNamespace))
382 382
                 {
383 383
                     $sClassName = $sNamespace . '\\' . $sClassName;
384 384
                 }
385 385
                 // Get the class options
386 386
                 $aClassOptions = [];
387
-                if(array_key_exists($sClassName, $aNewOptions))
387
+                if (array_key_exists($sClassName, $aNewOptions))
388 388
                 {
389 389
                     $aClassOptions = $aNewOptions[$sClassName];
390 390
                 }
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      */
406 406
     public function registerClass($sClassName, array $aOptions = [])
407 407
     {
408
-        if(!($sClassName = trim($sClassName, ' \\._')))
408
+        if (!($sClassName = trim($sClassName, ' \\._')))
409 409
         {
410 410
             return false;
411 411
         }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
         // Replace "." and "_" with antislashes, and set the class path.
415 415
         $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName);
416 416
         $sClassPath = '';
417
-        if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false)
417
+        if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false)
418 418
         {
419 419
             $sClassPath = substr($sClassName, 0, $nLastSlashPosition);
420 420
             $sClassName = substr($sClassName, $nLastSlashPosition + 1);
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php';
424 424
 
425 425
         // Search for the class file in all directories.
426
-        foreach($this->aClassDirs as $aClassDir)
426
+        foreach ($this->aClassDirs as $aClassDir)
427 427
         {
428 428
             // Get the separator
429 429
             $sSeparator = $aClassDir['separator'];
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
             $nLen = strlen($sNamespace);
433 433
             $sFullPath = '';
434 434
             // Check if the class belongs to the namespace
435
-            if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace)
435
+            if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace)
436 436
             {
437 437
                 $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1);
438 438
             }
439
-            elseif(!($sNamespace))
439
+            elseif (!($sNamespace))
440 440
             {
441 441
                 $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath;
442 442
             }
443
-            if(($sFullPath) && is_file($sFullPath))
443
+            if (($sFullPath) && is_file($sFullPath))
444 444
             {
445 445
                 // Found the file in this directory
446 446
                 $xFileInfo = new \SplFileInfo($sFullPath);
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     {
463 463
         $di = jaxon()->di();
464 464
         $sHash = '';
465
-        foreach($this->aCallableObjects as $sName)
465
+        foreach ($this->aCallableObjects as $sName)
466 466
         {
467 467
             $xCallableObject = $di->get($sName);
468 468
             $sHash .= $sName . implode('|', $xCallableObject->getMethods());
@@ -481,15 +481,15 @@  discard block
 block discarded – undo
481 481
         // Generate code for javascript objects declaration
482 482
         $code = '';
483 483
         $classes = [];
484
-        foreach($this->aClassPaths as $sClassPath)
484
+        foreach ($this->aClassPaths as $sClassPath)
485 485
         {
486 486
             $offset = 0;
487 487
             $sClassPath .= '.Null'; // This is a sentinel. The last token is not processed in the while loop.
488
-            while(($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
488
+            while (($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
489 489
             {
490 490
                 $class = substr($sClassPath, 0, $dotPosition);
491 491
                 // Generate code for this object
492
-                if(!array_key_exists($class, $classes))
492
+                if (!array_key_exists($class, $classes))
493 493
                 {
494 494
                     $code .= "$sJaxonPrefix$class = {};\n";
495 495
                     $classes[$class] = $class;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
         }
500 500
         // Generate code for javascript methods
501 501
         $di = jaxon()->di();
502
-        foreach($this->aCallableObjects as $sName)
502
+        foreach ($this->aCallableObjects as $sName)
503 503
         {
504 504
             $xCallableObject = $di->get($sName);
505 505
             $code .= $xCallableObject->getScript();
@@ -515,13 +515,13 @@  discard block
 block discarded – undo
515 515
     public function canProcessRequest()
516 516
     {
517 517
         // Check the validity of the class name
518
-        if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
518
+        if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
519 519
         {
520 520
             $this->sRequestedClass = null;
521 521
             $this->sRequestedMethod = null;
522 522
         }
523 523
         // Check the validity of the method name
524
-        if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
524
+        if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
525 525
         {
526 526
             $this->sRequestedClass = null;
527 527
             $this->sRequestedMethod = null;
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
      */
537 537
     public function processRequest()
538 538
     {
539
-        if(!$this->canProcessRequest())
539
+        if (!$this->canProcessRequest())
540 540
         {
541 541
             return false;
542 542
         }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
         // Find the requested method
547 547
         $xCallableObject = $this->getCallableObject($this->sRequestedClass);
548
-        if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
548
+        if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
549 549
         {
550 550
             // Unable to find the requested object or method
551 551
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid',
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
         // at the beginning and the end of the class name.
571 571
         $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\');
572 572
         // Register an instance of the requested class, if it isn't yet
573
-        if(!key_exists($sClassName, $this->aCallableObjects))
573
+        if (!key_exists($sClassName, $this->aCallableObjects))
574 574
         {
575 575
             $this->getPluginManager()->registerClass($sClassName);
576 576
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -255,8 +255,7 @@  discard block
 block discarded – undo
255 255
             {
256 256
                 $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory);
257 257
             }
258
-        }
259
-        elseif(($this->xAutoloader))
258
+        } elseif(($this->xAutoloader))
260 259
         {
261 260
             // If there is an autoloader, register the dir with classmap autoloading
262 261
             $itDir = new RecursiveDirectoryIterator($sDirectory);
@@ -435,8 +434,7 @@  discard block
 block discarded – undo
435 434
             if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace)
436 435
             {
437 436
                 $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1);
438
-            }
439
-            elseif(!($sNamespace))
437
+            } elseif(!($sNamespace))
440 438
             {
441 439
                 $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath;
442 440
             }
Please login to merge, or discard this patch.
src/Request/Plugin/UserFunction.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
         $this->sRequestedFunction = null;
53 53
 
54
-        if(isset($_GET['jxnfun']))
54
+        if (isset($_GET['jxnfun']))
55 55
         {
56 56
             $this->sRequestedFunction = $_GET['jxnfun'];
57 57
         }
58
-        if(isset($_POST['jxnfun']))
58
+        if (isset($_POST['jxnfun']))
59 59
         {
60 60
             $this->sRequestedFunction = $_POST['jxnfun'];
61 61
         }
@@ -80,39 +80,39 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function register($aArgs)
82 82
     {
83
-        if(count($aArgs) < 2)
83
+        if (count($aArgs) < 2)
84 84
         {
85 85
             return false;
86 86
         }
87 87
 
88 88
         $sType = $aArgs[0];
89
-        if($sType != Jaxon::USER_FUNCTION)
89
+        if ($sType != Jaxon::USER_FUNCTION)
90 90
         {
91 91
             return false;
92 92
         }
93 93
 
94 94
         $sUserFunction = $aArgs[1];
95
-        if(!is_string($sUserFunction))
95
+        if (!is_string($sUserFunction))
96 96
         {
97 97
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
98 98
         }
99 99
         $this->aFunctions[] = $sUserFunction;
100 100
 
101 101
         $aOptions = count($aArgs) > 2 ? $aArgs[2] : [];
102
-        if(is_string($aOptions))
102
+        if (is_string($aOptions))
103 103
         {
104 104
             $aOptions = ['include' => $aOptions];
105 105
         }
106
-        if(!is_array($aOptions))
106
+        if (!is_array($aOptions))
107 107
         {
108 108
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
109 109
         }
110 110
 
111 111
         // Check if an alias is defined
112 112
         $sFunctionName = $sUserFunction;
113
-        foreach($aOptions as $sName => $sValue)
113
+        foreach ($aOptions as $sName => $sValue)
114 114
         {
115
-            if($sName == 'alias')
115
+            if ($sName == 'alias')
116 116
             {
117 117
                 $sFunctionName = $sValue;
118 118
                 break;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         jaxon()->di()->set($sFunctionName, function() use($sUserFunction, $aOptions) {
123 123
             $xUserFunction = new \Jaxon\Request\Support\UserFunction($sUserFunction);
124 124
 
125
-            foreach($aOptions as $sName => $sValue)
125
+            foreach ($aOptions as $sName => $sValue)
126 126
             {
127 127
                 $xUserFunction->configure($sName, $sValue);
128 128
             }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     {
153 153
         $di = jaxon()->di();
154 154
         $code = '';
155
-        foreach($this->aFunctions as $sName)
155
+        foreach ($this->aFunctions as $sName)
156 156
         {
157 157
             $xFunction = $di->get($sName);
158 158
             $code .= $xFunction->getScript();
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     public function canProcessRequest()
169 169
     {
170 170
         // Check the validity of the function name
171
-        if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
171
+        if (($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
172 172
         {
173 173
             $this->sRequestedFunction = null;
174 174
         }
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function processRequest()
184 184
     {
185
-        if(!$this->canProcessRequest())
185
+        if (!$this->canProcessRequest())
186 186
         {
187 187
             return false;
188 188
         }
189 189
 
190
-        if(!key_exists($this->sRequestedFunction, $this->aFunctions))
190
+        if (!key_exists($this->sRequestedFunction, $this->aFunctions))
191 191
         {
192 192
             // Unable to find the requested function
193 193
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid',
Please login to merge, or discard this patch.
src/Plugin/Manager.php 2 patches
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -219,32 +219,32 @@  discard block
 block discarded – undo
219 219
     {
220 220
         $bIsAlert = ($xPlugin instanceof \Jaxon\Request\Interfaces\Alert);
221 221
         $bIsConfirm = ($xPlugin instanceof \Jaxon\Request\Interfaces\Confirm);
222
-        if($xPlugin instanceof Request)
222
+        if ($xPlugin instanceof Request)
223 223
         {
224 224
             // The name of a request plugin is used as key in the plugin table
225 225
             $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin;
226 226
         }
227
-        elseif($xPlugin instanceof Response)
227
+        elseif ($xPlugin instanceof Response)
228 228
         {
229 229
             // The name of a response plugin is used as key in the plugin table
230 230
             $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin;
231 231
         }
232
-        elseif(!$bIsConfirm && !$bIsAlert)
232
+        elseif (!$bIsConfirm && !$bIsAlert)
233 233
         {
234 234
             throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin))));
235 235
         }
236 236
         // This plugin implements the Alert interface
237
-        if($bIsAlert)
237
+        if ($bIsAlert)
238 238
         {
239 239
             $this->setAlert($xPlugin);
240 240
         }
241 241
         // This plugin implements the Confirm interface
242
-        if($bIsConfirm)
242
+        if ($bIsConfirm)
243 243
         {
244 244
             $this->setConfirm($xPlugin);
245 245
         }
246 246
         // Register the plugin as an event listener
247
-        if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener)
247
+        if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener)
248 248
         {
249 249
             $this->addEventListener($xPlugin);
250 250
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     private function generateHash()
275 275
     {
276 276
         $sHash = $this->getVersion();
277
-        foreach($this->aPlugins as $xPlugin)
277
+        foreach ($this->aPlugins as $xPlugin)
278 278
         {
279 279
             $sHash .= $xPlugin->generateHash();
280 280
         }
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function canProcessRequest()
293 293
     {
294
-        foreach($this->aRequestPlugins as $xPlugin)
294
+        foreach ($this->aRequestPlugins as $xPlugin)
295 295
         {
296
-            if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
296
+            if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
297 297
             {
298 298
                 return true;
299 299
             }
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
     public function processRequest()
313 313
     {
314 314
         $xUploadPlugin = $this->getRequestPlugin(Jaxon::FILE_UPLOAD);
315
-        foreach($this->aRequestPlugins as $xPlugin)
315
+        foreach ($this->aRequestPlugins as $xPlugin)
316 316
         {
317
-            if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
317
+            if ($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
318 318
             {
319 319
                 // Process uploaded files
320
-                if($xUploadPlugin != null)
320
+                if ($xUploadPlugin != null)
321 321
                 {
322 322
                     $xUploadPlugin->processRequest();
323 323
                 }
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
      */
342 342
     public function register($aArgs)
343 343
     {
344
-        foreach($this->aRequestPlugins as $xPlugin)
344
+        foreach ($this->aRequestPlugins as $xPlugin)
345 345
         {
346 346
             $mResult = $xPlugin->register($aArgs);
347
-            if($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true)
347
+            if ($mResult instanceof \Jaxon\Request\Request || is_array($mResult) || $mResult === true)
348 348
             {
349 349
                 return $mResult;
350 350
             }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
      */
360 360
     private function getJsLibUri()
361 361
     {
362
-        if(!$this->hasOption('js.lib.uri'))
362
+        if (!$this->hasOption('js.lib.uri'))
363 363
         {
364 364
             // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/';
365 365
             return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/';
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         // The jsDelivr CDN only hosts minified files
383 383
         // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri)
384 384
         // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files.
385
-        if(($this->getOption('js.app.minify')))
385
+        if (($this->getOption('js.app.minify')))
386 386
         {
387 387
             return '.min.js';
388 388
         }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
         // Check config options
400 400
         // - The js.app.extern option must be set to true
401 401
         // - The js.app.uri and js.app.dir options must be set to non null values
402
-        if(!$this->getOption('js.app.extern') ||
402
+        if (!$this->getOption('js.app.extern') ||
403 403
             !$this->getOption('js.app.uri') ||
404 404
             !$this->getOption('js.app.dir'))
405 405
         {
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
         // Check dir access
409 409
         // - The js.app.dir must be writable
410 410
         $sJsAppDir = $this->getOption('js.app.dir');
411
-        if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir))
411
+        if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir))
412 412
         {
413 413
             return false;
414 414
         }
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
      */
423 423
     private function setTemplateCacheDir()
424 424
     {
425
-        if($this->hasOption('core.template.cache_dir'))
425
+        if ($this->hasOption('core.template.cache_dir'))
426 426
         {
427 427
             $this->setCacheDir($this->getOption('core.template.cache_dir'));
428 428
         }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
         // Add component files to the javascript file array;
446 446
         $aJsFiles = array($sJsCoreUrl);
447
-        if($this->getOption('core.debug.on'))
447
+        if ($this->getOption('core.debug.on'))
448 448
         {
449 449
             $aJsFiles[] = $sJsDebugUrl;
450 450
             $aJsFiles[] = $sJsLanguageUrl;
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
             'sJsOptions' => $this->getOption('js.app.options'),
461 461
             'aUrls' => $aJsFiles,
462 462
         ));
463
-        foreach($this->aResponsePlugins as $xPlugin)
463
+        foreach ($this->aResponsePlugins as $xPlugin)
464 464
         {
465
-            if(($str = trim($xPlugin->getJs())))
465
+            if (($str = trim($xPlugin->getJs())))
466 466
             {
467 467
                 $sCode .= rtrim($str, " \n") . "\n";
468 468
             }
469 469
         }
470
-        foreach($this->aPackages as $sClass)
470
+        foreach ($this->aPackages as $sClass)
471 471
         {
472 472
             $xPackage = jaxon()->di()->get($sClass);
473
-            if(($str = trim($xPackage->js())))
473
+            if (($str = trim($xPackage->js())))
474 474
             {
475 475
                 $sCode .= rtrim($str, " \n") . "\n";
476 476
             }
@@ -489,17 +489,17 @@  discard block
 block discarded – undo
489 489
         $this->setTemplateCacheDir();
490 490
 
491 491
         $sCode = '';
492
-        foreach($this->aResponsePlugins as $xPlugin)
492
+        foreach ($this->aResponsePlugins as $xPlugin)
493 493
         {
494
-            if(($str = trim($xPlugin->getCss())))
494
+            if (($str = trim($xPlugin->getCss())))
495 495
             {
496 496
                 $sCode .= rtrim($str, " \n") . "\n";
497 497
             }
498 498
         }
499
-        foreach($this->aPackages as $sClass)
499
+        foreach ($this->aPackages as $sClass)
500 500
         {
501 501
             $xPackage = jaxon()->di()->get($sClass);
502
-            if(($str = trim($xPackage->css())))
502
+            if (($str = trim($xPackage->css())))
503 503
             {
504 504
                 $sCode .= rtrim($str, " \n") . "\n";
505 505
             }
@@ -563,17 +563,17 @@  discard block
 block discarded – undo
563 563
     private function getReadyScript()
564 564
     {
565 565
         $sPluginScript = '';
566
-        foreach($this->aResponsePlugins as $xPlugin)
566
+        foreach ($this->aResponsePlugins as $xPlugin)
567 567
         {
568
-            if(($str = trim($xPlugin->getScript())))
568
+            if (($str = trim($xPlugin->getScript())))
569 569
             {
570 570
                 $sPluginScript .= "\n" . trim($str, " \n");
571 571
             }
572 572
         }
573
-        foreach($this->aPackages as $sClass)
573
+        foreach ($this->aPackages as $sClass)
574 574
         {
575 575
             $xPackage = jaxon()->di()->get($sClass);
576
-            if(($str = trim($xPackage->ready())))
576
+            if (($str = trim($xPackage->ready())))
577 577
             {
578 578
                 $sPluginScript .= "\n" . trim($str, " \n");
579 579
             }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     {
597 597
         // Get the config and plugins scripts
598 598
         $sScript = $this->getConfigScript() . "\n" . $this->getReadyScript() . "\n";
599
-        foreach($this->aRequestPlugins as $xPlugin)
599
+        foreach ($this->aRequestPlugins as $xPlugin)
600 600
         {
601 601
             $sScript .= "\n" . trim($xPlugin->getScript(), " \n");
602 602
         }
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
         // Set the template engine cache dir
619 619
         $this->setTemplateCacheDir();
620 620
 
621
-        if($this->canExportJavascript())
621
+        if ($this->canExportJavascript())
622 622
         {
623 623
             $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/';
624 624
             $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/';
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
             $sHash = $this->generateHash();
628 628
             $sOutFile = $sHash . '.js';
629 629
             $sMinFile = $sHash . '.min.js';
630
-            if(!is_file($sJsAppDir . $sOutFile))
630
+            if (!is_file($sJsAppDir . $sOutFile))
631 631
             {
632 632
                 file_put_contents($sJsAppDir . $sOutFile, $this->getAllScripts());
633 633
             }
634
-            if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile))
634
+            if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile))
635 635
             {
636
-                if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
636
+                if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
637 637
                 {
638 638
                     $sOutFile = $sMinFile;
639 639
                 }
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
      */
667 667
     public function getResponsePlugin($sName)
668 668
     {
669
-        if(array_key_exists($sName, $this->aResponsePlugins))
669
+        if (array_key_exists($sName, $this->aResponsePlugins))
670 670
         {
671 671
             return $this->aResponsePlugins[$sName];
672 672
         }
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
      */
683 683
     public function getRequestPlugin($sName)
684 684
     {
685
-        if(array_key_exists($sName, $this->aRequestPlugins))
685
+        if (array_key_exists($sName, $this->aRequestPlugins))
686 686
         {
687 687
             return $this->aRequestPlugins[$sName];
688 688
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -223,13 +223,11 @@  discard block
 block discarded – undo
223 223
         {
224 224
             // The name of a request plugin is used as key in the plugin table
225 225
             $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin;
226
-        }
227
-        elseif($xPlugin instanceof Response)
226
+        } elseif($xPlugin instanceof Response)
228 227
         {
229 228
             // The name of a response plugin is used as key in the plugin table
230 229
             $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin;
231
-        }
232
-        elseif(!$bIsConfirm && !$bIsAlert)
230
+        } elseif(!$bIsConfirm && !$bIsAlert)
233 231
         {
234 232
             throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', array('name' => get_class($xPlugin))));
235 233
         }
@@ -644,8 +642,7 @@  discard block
 block discarded – undo
644 642
                 'sJsOptions' => $this->getOption('js.app.options'),
645 643
                 'sUrl' => $sJsAppURI . $sOutFile,
646 644
             ));
647
-        }
648
-        else
645
+        } else
649 646
         {
650 647
             // The plugins scripts are wrapped with javascript tags
651 648
             $sScript = $this->render('jaxon::plugins/wrapper.js', array(
Please login to merge, or discard this patch.