Completed
Push — master ( 7b173b...f911b9 )
by Thierry
01:48
created
src/Request/Factory.php 4 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -71,7 +71,6 @@  discard block
 block discarded – undo
71 71
      * Return the javascript call to a Jaxon function or object method
72 72
      *
73 73
      * @param string            $sFunction          The function or method (without class) name
74
-     * @param ...               $xParams            The parameters of the function or method
75 74
      *
76 75
      * @return \Jaxon\Request\Request
77 76
      */
@@ -100,7 +99,6 @@  discard block
 block discarded – undo
100 99
      * Return the javascript call to a generic function
101 100
      *
102 101
      * @param string            $sFunction          The function or method (with class) name
103
-     * @param ...               $xParams            The parameters of the function or method
104 102
      *
105 103
      * @return \Jaxon\Request\Request
106 104
      */
@@ -124,7 +122,6 @@  discard block
 block discarded – undo
124 122
      * @param integer       $nItemsPerPage          The number of items per page page
125 123
      * @param integer       $nCurrentPage           The current page
126 124
      * @param string        $sMethod                The name of function or a method prepended with its class name
127
-     * @param ...           $xParams                The parameters of the function or method
128 125
      *
129 126
      * @return string the pagination links
130 127
      */
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
 namespace Jaxon\Request;
17 17
 
18 18
 use Jaxon\Jaxon;
19
-
20 19
 use Jaxon\Request\Support\CallableObject;
21 20
 
22 21
 class Factory
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function setClassName($sClass)
41 41
     {
42 42
         $sClass = trim($sClass, '.\\ ');
43
-        if(($sClass))
43
+        if (($sClass))
44 44
         {
45 45
             $xCallable = jaxon()->di()->get($sClass);
46 46
             $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.';
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         array_shift($aArguments);
84 84
 
85 85
         // Makes legacy code works
86
-        if(strpos($sFunction, '.') !== false)
86
+        if (strpos($sFunction, '.') !== false)
87 87
         {
88 88
             // If there is a dot in the name, then it is a call to a class
89 89
             $this->sPrefix = $this->getOption('core.prefix.class');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@
 block discarded – undo
44 44
         {
45 45
             $xCallable = jaxon()->di()->get($sClass);
46 46
             $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.';
47
-        }
48
-        else
47
+        } else
49 48
         {
50 49
             $this->sPrefix = $this->getOption('core.prefix.function');
51 50
         }
Please login to merge, or discard this patch.
src/Plugin/Manager.php 1 patch
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 Dialogs\Interfaces\Alert);
221 221
         $bIsConfirm = ($xPlugin instanceof Dialogs\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.
src/Request/Request.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function hasPageNumber()
60 60
     {
61
-        foreach($this->aParameters as $xParameter)
61
+        foreach ($this->aParameters as $xParameter)
62 62
         {
63
-            if($xParameter->getType() == Jaxon::PAGE_NUMBER)
63
+            if ($xParameter->getType() == Jaxon::PAGE_NUMBER)
64 64
             {
65 65
                 return true;
66 66
             }
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
     public function setPageNumber($nPageNumber)
79 79
     {
80 80
         // Set the value of the Jaxon::PAGE_NUMBER parameter
81
-        foreach($this->aParameters as $xParameter)
81
+        foreach ($this->aParameters as $xParameter)
82 82
         {
83
-            if($xParameter->getType() == Jaxon::PAGE_NUMBER)
83
+            if ($xParameter->getType() == Jaxon::PAGE_NUMBER)
84 84
             {
85 85
                 $xParameter->setValue(intval($nPageNumber));
86 86
                 break;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $this->sCondition = '__confirm__';
102 102
         $this->aMessageArgs = func_get_args();
103
-        array_walk($this->aMessageArgs, function (&$xParameter) {
103
+        array_walk($this->aMessageArgs, function(&$xParameter) {
104 104
             $xParameter = Parameter::make($xParameter);
105 105
         });
106 106
         return $this;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     public function elseShow($sMessage)
234 234
     {
235 235
         $this->aMessageArgs = func_get_args();
236
-        array_walk($this->aMessageArgs, function (&$xParameter) {
236
+        array_walk($this->aMessageArgs, function(&$xParameter) {
237 237
             $xParameter = Parameter::make($xParameter);
238 238
         });
239 239
         return $this;
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
         // This array will avoid declaring multiple variables with the same value.
259 259
         // The array key is the variable value, while the array value is the variable name.
260 260
         $aVariables = []; // Array of local variables.
261
-        foreach($this->aParameters as &$xParameter)
261
+        foreach ($this->aParameters as &$xParameter)
262 262
         {
263 263
             $sParameterStr = $xParameter->getScript();
264
-            if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element)
264
+            if ($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element)
265 265
             {
266
-                if(!array_key_exists($sParameterStr, $aVariables))
266
+                if (!array_key_exists($sParameterStr, $aVariables))
267 267
                 {
268 268
                     // The value is not yet defined. A new variable is created.
269 269
                     $sVarName = "jxnVar$nVarId";
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
         }
282 282
 
283 283
         $sPhrase = '';
284
-        if(count($this->aMessageArgs) > 0)
284
+        if (count($this->aMessageArgs) > 0)
285 285
         {
286 286
             $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question.
287 287
             // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes
288
-            if(count($this->aMessageArgs) > 0)
288
+            if (count($this->aMessageArgs) > 0)
289 289
             {
290 290
                 $nParamId = 1;
291
-                foreach($this->aMessageArgs as &$xParameter)
291
+                foreach ($this->aMessageArgs as &$xParameter)
292 292
                 {
293 293
                     $sParameterStr = $xParameter->getScript();
294
-                    if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element)
294
+                    if ($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element)
295 295
                     {
296
-                        if(!array_key_exists($sParameterStr, $aVariables))
296
+                        if (!array_key_exists($sParameterStr, $aVariables))
297 297
                         {
298 298
                             // The value is not yet defined. A new variable is created.
299 299
                             $sVarName = "jxnVar$nVarId";
@@ -316,15 +316,15 @@  discard block
 block discarded – undo
316 316
         }
317 317
 
318 318
         $sScript = parent::getScript();
319
-        if($this->sCondition == '__confirm__')
319
+        if ($this->sCondition == '__confirm__')
320 320
         {
321 321
             $xConfirm = $this->getPluginManager()->getConfirm();
322 322
             $sScript = $xConfirm->confirm($sPhrase, $sScript, '');
323 323
         }
324
-        elseif($this->sCondition !== null)
324
+        elseif ($this->sCondition !== null)
325 325
         {
326 326
             $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}';
327
-            if(($sPhrase))
327
+            if (($sPhrase))
328 328
             {
329 329
                 $xAlert = $this->getPluginManager()->getAlert();
330 330
                 $xAlert->setReturn(true);
Please login to merge, or discard this patch.
src/Request/Plugin/CallableObject.php 1 patch
Spacing   +56 added lines, -56 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
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
         }
208 208
 
209 209
         // Register the callable object
210
-        jaxon()->di()->set($sCallableObject, function () use ($sCallableObject, $aOptions) {
210
+        jaxon()->di()->set($sCallableObject, function() use ($sCallableObject, $aOptions) {
211 211
             $xCallableObject = new \Jaxon\Request\Support\CallableObject($sCallableObject);
212 212
 
213
-            foreach($aOptions as $sMethod => $aValue)
213
+            foreach ($aOptions as $sMethod => $aValue)
214 214
             {
215
-                foreach($aValue as $sName => $sValue)
215
+                foreach ($aValue as $sName => $sValue)
216 216
                 {
217 217
                     $xCallableObject->configure($sMethod, $sName, $sValue);
218 218
                 }
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
         });
223 223
 
224 224
         // Register the request factory for this callable object
225
-        jaxon()->di()->set($sCallableObject . '\Factory\Rq', function ($di) use ($sCallableObject) {
225
+        jaxon()->di()->set($sCallableObject . '\Factory\Rq', function($di) use ($sCallableObject) {
226 226
             $xCallableObject = $di->get($sCallableObject);
227 227
             return new \Jaxon\Sentry\Factory\Request($xCallableObject);
228 228
         });
229 229
 
230 230
         // Register the paginator factory for this callable object
231
-        jaxon()->di()->set($sCallableObject . '\Factory\Pg', function ($di) use ($sCallableObject) {
231
+        jaxon()->di()->set($sCallableObject . '\Factory\Pg', function($di) use ($sCallableObject) {
232 232
             $xCallableObject = $di->get($sCallableObject);
233 233
             return new \Jaxon\Sentry\Factory\Paginator($xCallableObject);
234 234
         });
@@ -248,37 +248,37 @@  discard block
 block discarded – undo
248 248
      */
249 249
     public function addClassDir($sDirectory, $sNamespace = '', $sSeparator = '.', array $aProtected = [])
250 250
     {
251
-        if(!is_dir(($sDirectory = trim($sDirectory))))
251
+        if (!is_dir(($sDirectory = trim($sDirectory))))
252 252
         {
253 253
             return false;
254 254
         }
255 255
         // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead.
256
-        if(($sSeparator = trim($sSeparator)) != '_')
256
+        if (($sSeparator = trim($sSeparator)) != '_')
257 257
         {
258 258
             $sSeparator = '.';
259 259
         }
260
-        if(!($sNamespace = trim($sNamespace, ' \\')))
260
+        if (!($sNamespace = trim($sNamespace, ' \\')))
261 261
         {
262 262
             $sNamespace = '';
263 263
         }
264
-        if(($sNamespace))
264
+        if (($sNamespace))
265 265
         {
266 266
             // If there is an autoloader, register the dir with PSR4 autoloading
267
-            if(($this->xAutoloader))
267
+            if (($this->xAutoloader))
268 268
             {
269 269
                 $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory);
270 270
             }
271 271
         }
272
-        elseif(($this->xAutoloader))
272
+        elseif (($this->xAutoloader))
273 273
         {
274 274
             // If there is an autoloader, register the dir with classmap autoloading
275 275
             $itDir = new RecursiveDirectoryIterator($sDirectory);
276 276
             $itFile = new RecursiveIteratorIterator($itDir);
277 277
             // Iterate on dir content
278
-            foreach($itFile as $xFile)
278
+            foreach ($itFile as $xFile)
279 279
             {
280 280
                 // skip everything except PHP files
281
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
281
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
282 282
                 {
283 283
                     continue;
284 284
                 }
@@ -314,33 +314,33 @@  discard block
 block discarded – undo
314 314
         $sClassPath = substr($xFile->getPath(), strlen($sDirectory));
315 315
         $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS));
316 316
         $sClassName = $xFile->getBasename('.php');
317
-        if(($sNamespace))
317
+        if (($sNamespace))
318 318
         {
319 319
             $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace;
320 320
             $sClassName = '\\' . $sClassPath . '\\' . $sClassName;
321 321
         }
322 322
         // Require the file only if autoload is enabled but there is no autoloader
323
-        if(($this->bAutoloadEnabled) && !($this->xAutoloader))
323
+        if (($this->bAutoloadEnabled) && !($this->xAutoloader))
324 324
         {
325 325
             require_once($xFile->getPathname());
326 326
         }
327 327
         // Create and register an instance of the class
328
-        if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*']))
328
+        if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*']))
329 329
         {
330 330
             $aOptions['*'] = [];
331 331
         }
332 332
         $aOptions['*']['separator'] = $sSeparator;
333
-        if(($sNamespace))
333
+        if (($sNamespace))
334 334
         {
335 335
             $aOptions['*']['namespace'] = $sNamespace;
336 336
         }
337
-        if(($sClassPath))
337
+        if (($sClassPath))
338 338
         {
339 339
             $aOptions['*']['classpath'] = $sClassPath;
340 340
         }
341 341
         // Filter excluded methods
342
-        $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);});
343
-        if(count($aProtected) > 0)
342
+        $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); });
343
+        if (count($aProtected) > 0)
344 344
         {
345 345
             $aOptions['*']['protected'] = $aProtected;
346 346
         }
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
         $sDS = DIRECTORY_SEPARATOR;
360 360
         // Change the keys in $aOptions to have "\" as separator
361 361
         $aNewOptions = [];
362
-        foreach($aOptions as $key => $aOption)
362
+        foreach ($aOptions as $key => $aOption)
363 363
         {
364 364
             $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\');
365 365
             $aNewOptions[$key] = $aOption;
366 366
         }
367 367
 
368
-        foreach($this->aClassDirs as $aClassDir)
368
+        foreach ($this->aClassDirs as $aClassDir)
369 369
         {
370 370
             // Get the directory
371 371
             $sDirectory = $aClassDir['directory'];
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
             $itDir = new RecursiveDirectoryIterator($sDirectory);
376 376
             $itFile = new RecursiveIteratorIterator($itDir);
377 377
             // Iterate on dir content
378
-            foreach($itFile as $xFile)
378
+            foreach ($itFile as $xFile)
379 379
             {
380 380
                 // skip everything except PHP files
381
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
381
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
382 382
                 {
383 383
                     continue;
384 384
                 }
@@ -387,17 +387,17 @@  discard block
 block discarded – undo
387 387
                 $sClassPath = substr($xFile->getPath(), strlen($sDirectory));
388 388
                 $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\');
389 389
                 $sClassName = $xFile->getBasename('.php');
390
-                if(($sClassPath))
390
+                if (($sClassPath))
391 391
                 {
392 392
                     $sClassName = $sClassPath . '\\' . $sClassName;
393 393
                 }
394
-                if(($sNamespace))
394
+                if (($sNamespace))
395 395
                 {
396 396
                     $sClassName = $sNamespace . '\\' . $sClassName;
397 397
                 }
398 398
                 // Get the class options
399 399
                 $aClassOptions = [];
400
-                if(array_key_exists($sClassName, $aNewOptions))
400
+                if (array_key_exists($sClassName, $aNewOptions))
401 401
                 {
402 402
                     $aClassOptions = $aNewOptions[$sClassName];
403 403
                 }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      */
419 419
     public function registerClass($sClassName, array $aOptions = [])
420 420
     {
421
-        if(!($sClassName = trim($sClassName, ' \\._')))
421
+        if (!($sClassName = trim($sClassName, ' \\._')))
422 422
         {
423 423
             return false;
424 424
         }
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
         // Replace "." and "_" with antislashes, and set the class path.
428 428
         $sClassName = str_replace(['.', '_'], ['\\', '\\'], $sClassName);
429 429
         $sClassPath = '';
430
-        if(($nLastSlashPosition = strrpos($sClassName, '\\')) !== false)
430
+        if (($nLastSlashPosition = strrpos($sClassName, '\\')) !== false)
431 431
         {
432 432
             $sClassPath = substr($sClassName, 0, $nLastSlashPosition);
433 433
             $sClassName = substr($sClassName, $nLastSlashPosition + 1);
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
         $sPartPath = str_replace('\\', $sDS, $sClassPath) . $sDS . $sClassName . '.php';
437 437
 
438 438
         // Search for the class file in all directories.
439
-        foreach($this->aClassDirs as $aClassDir)
439
+        foreach ($this->aClassDirs as $aClassDir)
440 440
         {
441 441
             // Get the separator
442 442
             $sSeparator = $aClassDir['separator'];
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
             $nLen = strlen($sNamespace);
446 446
             $sFullPath = '';
447 447
             // Check if the class belongs to the namespace
448
-            if(($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace)
448
+            if (($sNamespace) && substr($sClassPath, 0, $nLen) == $sNamespace)
449 449
             {
450 450
                 $sFullPath = $aClassDir['directory'] . $sDS . substr($sPartPath, $nLen + 1);
451 451
             }
452
-            elseif(!($sNamespace))
452
+            elseif (!($sNamespace))
453 453
             {
454 454
                 $sFullPath = $aClassDir['directory'] . $sDS . $sPartPath;
455 455
             }
456
-            if(($sFullPath) && is_file($sFullPath))
456
+            if (($sFullPath) && is_file($sFullPath))
457 457
             {
458 458
                 // Found the file in this directory
459 459
                 $xFileInfo = new \SplFileInfo($sFullPath);
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
     {
476 476
         $di = jaxon()->di();
477 477
         $sHash = '';
478
-        foreach($this->aCallableObjects as $sName)
478
+        foreach ($this->aCallableObjects as $sName)
479 479
         {
480 480
             $xCallableObject = $di->get($sName);
481 481
             $sHash .= $sName . implode('|', $xCallableObject->getMethods());
@@ -494,15 +494,15 @@  discard block
 block discarded – undo
494 494
         // Generate code for javascript objects declaration
495 495
         $code = '';
496 496
         $classes = [];
497
-        foreach($this->aClassPaths as $sClassPath)
497
+        foreach ($this->aClassPaths as $sClassPath)
498 498
         {
499 499
             $offset = 0;
500 500
             $sClassPath .= '.Null'; // This is a sentinel. The last token is not processed in the while loop.
501
-            while(($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
501
+            while (($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
502 502
             {
503 503
                 $class = substr($sClassPath, 0, $dotPosition);
504 504
                 // Generate code for this object
505
-                if(!array_key_exists($class, $classes))
505
+                if (!array_key_exists($class, $classes))
506 506
                 {
507 507
                     $code .= "$sJaxonPrefix$class = {};\n";
508 508
                     $classes[$class] = $class;
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         }
513 513
         // Generate code for javascript methods
514 514
         $di = jaxon()->di();
515
-        foreach($this->aCallableObjects as $sName)
515
+        foreach ($this->aCallableObjects as $sName)
516 516
         {
517 517
             $xCallableObject = $di->get($sName);
518 518
             $code .= $xCallableObject->getScript();
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
     public function canProcessRequest()
529 529
     {
530 530
         // Check the validity of the class name
531
-        if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
531
+        if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
532 532
         {
533 533
             $this->sRequestedClass = null;
534 534
             $this->sRequestedMethod = null;
535 535
         }
536 536
         // Check the validity of the method name
537
-        if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
537
+        if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
538 538
         {
539 539
             $this->sRequestedClass = null;
540 540
             $this->sRequestedMethod = null;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      */
550 550
     public function processRequest()
551 551
     {
552
-        if(!$this->canProcessRequest())
552
+        if (!$this->canProcessRequest())
553 553
         {
554 554
             return false;
555 555
         }
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 
559 559
         // Find the requested method
560 560
         $xCallableObject = $this->getCallableObject($this->sRequestedClass);
561
-        if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
561
+        if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
562 562
         {
563 563
             // Unable to find the requested object or method
564 564
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid',
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
         // at the beginning and the end of the class name.
584 584
         $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\');
585 585
         // Register an instance of the requested class, if it isn't yet
586
-        if(!key_exists($sClassName, $this->aCallableObjects))
586
+        if (!key_exists($sClassName, $this->aCallableObjects))
587 587
         {
588 588
             $this->getPluginManager()->registerClass($sClassName);
589 589
         }
Please login to merge, or discard this patch.
src/Request/Support/CallableObject.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
     private function makeCallable()
108 108
     {
109 109
         // Create an instance of the registered class
110
-        if($this->callableObject == null)
110
+        if ($this->callableObject == null)
111 111
         {
112 112
             $di = jaxon()->di();
113 113
             // Use the Reflection class to get the parameters of the constructor
114
-            if(($constructor = $this->reflectionClass->getConstructor()) != null)
114
+            if (($constructor = $this->reflectionClass->getConstructor()) != null)
115 115
             {
116 116
                 $parameters = $constructor->getParameters();
117 117
                 $parameterInstances = [];
118
-                foreach($parameters as $parameter)
118
+                foreach ($parameters as $parameter)
119 119
                 {
120 120
                     // Get the parameter instance from the DI
121 121
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function getRegisteredObject()
138 138
     {
139
-        if($this->callableObject == null)
139
+        if ($this->callableObject == null)
140 140
         {
141 141
             $this->makeCallable();
142 142
         }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         // The class name without the namespace.
165 165
         $name = $this->reflectionClass->getShortName();
166 166
         // Append the classpath to the name
167
-        if(($this->classpath))
167
+        if (($this->classpath))
168 168
         {
169 169
             $name = $this->classpath . '\\' . $name;
170 170
         }
@@ -211,16 +211,16 @@  discard block
 block discarded – undo
211 211
     public function getMethods()
212 212
     {
213 213
         $aReturn = [];
214
-        foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
214
+        foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
215 215
         {
216 216
             $sMethodName = $xMethod->getShortName();
217 217
             // Don't take magic __call, __construct, __destruct methods
218
-            if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
218
+            if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
219 219
             {
220 220
                 continue;
221 221
             }
222 222
             // Don't take excluded methods
223
-            if(in_array($sMethodName, $this->aProtectedMethods))
223
+            if (in_array($sMethodName, $this->aProtectedMethods))
224 224
             {
225 225
                 continue;
226 226
             }
@@ -241,37 +241,37 @@  discard block
 block discarded – undo
241 241
     public function configure($sMethod, $sName, $sValue)
242 242
     {
243 243
         // Set the namespace
244
-        if($sName == 'namespace')
244
+        if ($sName == 'namespace')
245 245
         {
246
-            if($sValue != '')
246
+            if ($sValue != '')
247 247
                 $this->namespace = $sValue;
248 248
             return;
249 249
         }
250 250
         // Set the classpath
251
-        if($sName == 'classpath')
251
+        if ($sName == 'classpath')
252 252
         {
253
-            if($sValue != '')
253
+            if ($sValue != '')
254 254
                 $this->classpath = trim($sValue, '\\');
255 255
             return;
256 256
         }
257 257
         // Set the separator
258
-        if($sName == 'separator')
258
+        if ($sName == 'separator')
259 259
         {
260
-            if($sValue == '_' || $sValue == '.')
260
+            if ($sValue == '_' || $sValue == '.')
261 261
                 $this->separator = $sValue;
262 262
             return;
263 263
         }
264 264
         // Set the excluded methods
265
-        if($sName == 'protected')
265
+        if ($sName == 'protected')
266 266
         {
267
-            if(is_array($sValue))
267
+            if (is_array($sValue))
268 268
                 $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
269
-            elseif(is_string($sValue))
269
+            elseif (is_string($sValue))
270 270
                 $this->aProtectedMethods[] = $sValue;
271 271
             return;
272 272
         }
273 273
 
274
-        if(!isset($this->aConfiguration[$sMethod]))
274
+        if (!isset($this->aConfiguration[$sMethod]))
275 275
         {
276 276
             $this->aConfiguration[$sMethod] = [];
277 277
         }
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
 
293 293
         // Common options to be set on all methods
294 294
         $aCommonConfig = array_key_exists('*', $this->aConfiguration) ? $this->aConfiguration['*'] : [];
295
-        foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
295
+        foreach ($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
296 296
         {
297 297
             $sMethodName = $xMethod->getShortName();
298 298
             // Don't export magic __call, __construct, __destruct methods
299
-            if(strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__')
299
+            if (strlen($sMethodName) > 0 && substr($sMethodName, 0, 2) == '__')
300 300
             {
301 301
                 continue;
302 302
             }
303 303
             // Don't export "protected" methods
304
-            if(in_array($sMethodName, $this->aProtectedMethods))
304
+            if (in_array($sMethodName, $this->aProtectedMethods))
305 305
             {
306 306
                 continue;
307 307
             }
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
      */
352 352
     public function call($sMethod, $aArgs)
353 353
     {
354
-        if(!$this->hasMethod($sMethod))
354
+        if (!$this->hasMethod($sMethod))
355 355
         {
356 356
             return;
357 357
         }
358 358
         $reflectionMethod = $this->reflectionClass->getMethod($sMethod);
359 359
         $callableObject = $this->getRegisteredObject();
360 360
         $response = $reflectionMethod->invokeArgs($callableObject, $aArgs);
361
-        if(($response))
361
+        if (($response))
362 362
         {
363 363
             $this->getResponseManager()->append($response);
364 364
         }
Please login to merge, or discard this patch.
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -121,8 +121,7 @@  discard block
 block discarded – undo
121 121
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
122 122
                 }
123 123
                 $this->callableObject = $this->reflectionClass->newInstanceArgs($parameterInstances);
124
-            }
125
-            else
124
+            } else
126 125
             {
127 126
                 $this->callableObject = $this->reflectionClass->newInstance();
128 127
             }
@@ -243,31 +242,35 @@  discard block
 block discarded – undo
243 242
         // Set the namespace
244 243
         if($sName == 'namespace')
245 244
         {
246
-            if($sValue != '')
247
-                $this->namespace = $sValue;
245
+            if($sValue != '') {
246
+                            $this->namespace = $sValue;
247
+            }
248 248
             return;
249 249
         }
250 250
         // Set the classpath
251 251
         if($sName == 'classpath')
252 252
         {
253
-            if($sValue != '')
254
-                $this->classpath = trim($sValue, '\\');
253
+            if($sValue != '') {
254
+                            $this->classpath = trim($sValue, '\\');
255
+            }
255 256
             return;
256 257
         }
257 258
         // Set the separator
258 259
         if($sName == 'separator')
259 260
         {
260
-            if($sValue == '_' || $sValue == '.')
261
-                $this->separator = $sValue;
261
+            if($sValue == '_' || $sValue == '.') {
262
+                            $this->separator = $sValue;
263
+            }
262 264
             return;
263 265
         }
264 266
         // Set the excluded methods
265 267
         if($sName == 'protected')
266 268
         {
267
-            if(is_array($sValue))
268
-                $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
269
-            elseif(is_string($sValue))
270
-                $this->aProtectedMethods[] = $sValue;
269
+            if(is_array($sValue)) {
270
+                            $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
271
+            } elseif(is_string($sValue)) {
272
+                            $this->aProtectedMethods[] = $sValue;
273
+            }
271 274
             return;
272 275
         }
273 276
 
Please login to merge, or discard this patch.