Completed
Push — master ( 859b6d...c8dd9a )
by Thierry
01:30
created
src/Request/Plugin/FileUpload.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@
 block discarded – undo
217 217
             $aFiles[$sVarName] = [];
218 218
             foreach($aUserFiles as $aUserFile)
219 219
             {
220
-                 $aFiles[$sVarName][] = $aUserFile->toTempData();
220
+                    $aFiles[$sVarName][] = $aUserFile->toTempData();
221 221
             }
222 222
         }
223 223
         // Save upload data in a temp file
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
 use Jaxon\Plugin\Request as RequestPlugin;
17 17
 use Jaxon\Request\Support\UploadedFile;
18 18
 use Jaxon\Response\UploadResponse;
19
-
20 19
 use Exception;
21 20
 use Closure;
22 21
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $this->sUploadSubdir = uniqid() . DIRECTORY_SEPARATOR;
70 70
 
71
-        if(array_key_exists('jxnupl', $_POST))
71
+        if (array_key_exists('jxnupl', $_POST))
72 72
         {
73 73
             $this->sTempFile = $_POST['jxnupl'];
74 74
         }
75
-        elseif(array_key_exists('jxnupl', $_GET))
75
+        elseif (array_key_exists('jxnupl', $_GET))
76 76
         {
77 77
             $this->sTempFile = $_GET['jxnupl'];
78 78
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function filterFilename($sFilename, $sVarName)
102 102
     {
103
-        if(($this->cFileFilter))
103
+        if (($this->cFileFilter))
104 104
         {
105 105
             $cFileFilter = $this->cFileFilter;
106 106
             $sFilename = (string)$cFileFilter($sFilename, $sVarName);
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
         $sUploadDir = $this->getOption('upload.files.' . $sFieldId . '.dir', $sDefaultUploadDir);
123 123
         $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR;
124 124
         // Verify that the upload dir exists and is writable
125
-        if(!is_writable($sUploadDir))
125
+        if (!is_writable($sUploadDir))
126 126
         {
127 127
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
128 128
         }
129 129
         $sUploadDir .= $this->sUploadSubdir;
130
-        if(!file_exists($sUploadDir) && !@mkdir($sUploadDir))
130
+        if (!file_exists($sUploadDir) && !@mkdir($sUploadDir))
131 131
         {
132 132
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
133 133
         }
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
         $sUploadDir = $this->getOption('upload.default.dir');
146 146
         $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR;
147 147
         // Verify that the upload dir exists and is writable
148
-        if(!is_writable($sUploadDir))
148
+        if (!is_writable($sUploadDir))
149 149
         {
150 150
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
151 151
         }
152 152
         $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR;
153
-        if(!file_exists($sUploadDir) && !@mkdir($sUploadDir))
153
+        if (!file_exists($sUploadDir) && !@mkdir($sUploadDir))
154 154
         {
155 155
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
156 156
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $sUploadDir = rtrim(trim($sUploadDir), '/\\') . DIRECTORY_SEPARATOR;
169 169
         $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR;
170 170
         $sUploadTempFile = $sUploadDir . $this->sTempFile . '.json';
171
-        if(!is_readable($sUploadTempFile))
171
+        if (!is_readable($sUploadTempFile))
172 172
         {
173 173
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
174 174
         }
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
     {
185 185
         // Check validity of the uploaded files
186 186
         $aTempFiles = [];
187
-        foreach($_FILES as $sVarName => $aFile)
187
+        foreach ($_FILES as $sVarName => $aFile)
188 188
         {
189
-            if(is_array($aFile['name']))
189
+            if (is_array($aFile['name']))
190 190
             {
191 191
                 $nFileCount = count($aFile['name']);
192
-                for($i = 0; $i < $nFileCount; $i++)
192
+                for ($i = 0; $i < $nFileCount; $i++)
193 193
                 {
194
-                    if(!$aFile['name'][$i])
194
+                    if (!$aFile['name'][$i])
195 195
                     {
196 196
                         continue;
197 197
                     }
198
-                    if(!array_key_exists($sVarName, $aTempFiles))
198
+                    if (!array_key_exists($sVarName, $aTempFiles))
199 199
                     {
200 200
                         $aTempFiles[$sVarName] = [];
201 201
                     }
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
             }
216 216
             else
217 217
             {
218
-                if(!$aFile['name'])
218
+                if (!$aFile['name'])
219 219
                 {
220 220
                     continue;
221 221
                 }
222
-                if(!array_key_exists($sVarName, $aTempFiles))
222
+                if (!array_key_exists($sVarName, $aTempFiles))
223 223
                 {
224 224
                     $aTempFiles[$sVarName] = [];
225 225
                 }
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
         }
240 240
 
241 241
         // Check uploaded files validity
242
-        foreach($aTempFiles as $sVarName => $aFiles)
242
+        foreach ($aTempFiles as $sVarName => $aFiles)
243 243
         {
244
-            foreach($aFiles as $aFile)
244
+            foreach ($aFiles as $aFile)
245 245
             {
246 246
                 // Verify upload result
247
-                if($aFile['error'] != 0)
247
+                if ($aFile['error'] != 0)
248 248
                 {
249 249
                     throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile));
250 250
                 }
251 251
                 // Verify file validity (format, size)
252
-                if(!$this->validateUploadedFile($sVarName, $aFile))
252
+                if (!$this->validateUploadedFile($sVarName, $aFile))
253 253
                 {
254 254
                     throw new \Jaxon\Exception\Error($this->getValidatorMessage());
255 255
                 }
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
         }
260 260
 
261 261
         // Copy the uploaded files from the temp dir to the user dir
262
-        foreach($aTempFiles as $sVarName => $_aTempFiles)
262
+        foreach ($aTempFiles as $sVarName => $_aTempFiles)
263 263
         {
264 264
             $this->aUserFiles[$sVarName] = [];
265
-            foreach($_aTempFiles as $aFile)
265
+            foreach ($_aTempFiles as $aFile)
266 266
             {
267 267
                 // Get the path to the upload dir
268 268
                 $sUploadDir = $this->getUploadDir($sVarName);
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
     {
285 285
         // Convert uploaded file to an array
286 286
         $aFiles = [];
287
-        foreach($this->aUserFiles as $sVarName => $aUserFiles)
287
+        foreach ($this->aUserFiles as $sVarName => $aUserFiles)
288 288
         {
289 289
             $aFiles[$sVarName] = [];
290
-            foreach($aUserFiles as $aUserFile)
290
+            foreach ($aUserFiles as $aUserFile)
291 291
             {
292 292
                  $aFiles[$sVarName][] = $aUserFile->toTempData();
293 293
             }
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
         // Upload temp file
309 309
         $sUploadTempFile = $this->getUploadTempFile();
310 310
         $aFiles = json_decode(file_get_contents($sUploadTempFile), true);
311
-        foreach($aFiles as $sVarName => $aUserFiles)
311
+        foreach ($aFiles as $sVarName => $aUserFiles)
312 312
         {
313 313
             $this->aUserFiles[$sVarName] = [];
314
-            foreach($aUserFiles as $aUserFile)
314
+            foreach ($aUserFiles as $aUserFile)
315 315
             {
316 316
                 $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile);
317 317
             }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     public function noRequestPluginFound()
380 380
     {
381
-        if(count($_FILES) > 0)
381
+        if (count($_FILES) > 0)
382 382
         {
383 383
             $this->bRequestIsHttpUpload = true;
384 384
         }
@@ -401,17 +401,17 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public function processRequest()
403 403
     {
404
-        if(!$this->canProcessRequest())
404
+        if (!$this->canProcessRequest())
405 405
         {
406 406
             return false;
407 407
         }
408 408
 
409
-        if(count($_FILES) > 0)
409
+        if (count($_FILES) > 0)
410 410
         {
411 411
             // Ajax request with upload
412 412
             $this->readFromHttpData();
413 413
 
414
-            if($this->bRequestIsHttpUpload)
414
+            if ($this->bRequestIsHttpUpload)
415 415
             {
416 416
                 // Process an HTTP upload request
417 417
                 // This requires to set the response to be returned.
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
                     $this->saveToTempFile();
422 422
                     $xResponse->setUploadedFile($this->sTempFile);
423 423
                 }
424
-                catch(Exception $e)
424
+                catch (Exception $e)
425 425
                 {
426 426
                     $xResponse->setErrorMessage($e->getMessage());
427 427
                 }
428 428
                 jaxon()->di()->getResponseManager()->append($xResponse);
429 429
             }
430 430
         }
431
-        elseif(($this->sTempFile))
431
+        elseif (($this->sTempFile))
432 432
         {
433 433
             // Ajax request following and HTTP upload
434 434
             $this->readFromTempFile();
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@  discard block
 block discarded – undo
71 71
         if(array_key_exists('jxnupl', $_POST))
72 72
         {
73 73
             $this->sTempFile = $_POST['jxnupl'];
74
-        }
75
-        elseif(array_key_exists('jxnupl', $_GET))
74
+        } elseif(array_key_exists('jxnupl', $_GET))
76 75
         {
77 76
             $this->sTempFile = $_GET['jxnupl'];
78 77
         }
@@ -212,8 +211,7 @@  discard block
 block discarded – undo
212 211
                         'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION),
213 212
                     ];
214 213
                 }
215
-            }
216
-            else
214
+            } else
217 215
             {
218 216
                 if(!$aFile['name'])
219 217
                 {
@@ -420,15 +418,13 @@  discard block
 block discarded – undo
420 418
                 {
421 419
                     $this->saveToTempFile();
422 420
                     $xResponse->setUploadedFile($this->sTempFile);
423
-                }
424
-                catch(Exception $e)
421
+                } catch(Exception $e)
425 422
                 {
426 423
                     $xResponse->setErrorMessage($e->getMessage());
427 424
                 }
428 425
                 jaxon()->di()->getResponseManager()->append($xResponse);
429 426
             }
430
-        }
431
-        elseif(($this->sTempFile))
427
+        } elseif(($this->sTempFile))
432 428
         {
433 429
             // Ajax request following and HTTP upload
434 430
             $this->readFromTempFile();
Please login to merge, or discard this patch.
templates/plugins/config.js.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,18 +14,18 @@
 block discarded – undo
14 14
 jaxon.config.defaultMode = "<?php echo $this->sDefaultMode ?>";
15 15
 jaxon.config.defaultMethod = "<?php echo $this->sDefaultMethod ?>";
16 16
 jaxon.config.responseType = "<?php echo $this->sResponseType ?>";
17
-<?php if($this->nResponseQueueSize > 0): ?>
17
+<?php if ($this->nResponseQueueSize > 0): ?>
18 18
 jaxon.config.responseQueueSize = <?php echo $this->nResponseQueueSize ?>;
19 19
 <?php endif ?>
20
-<?php if(($this->bDebug)): ?>
21
-<?php if(($this->sDebugOutputID)): ?>
20
+<?php if (($this->bDebug)): ?>
21
+<?php if (($this->sDebugOutputID)): ?>
22 22
 jaxon.debug.outputID = "<?php echo $this->sDebugOutputID ?>";
23 23
 <?php endif ?>
24
-<?php if(($this->bVerboseDebug)): ?>
24
+<?php if (($this->bVerboseDebug)): ?>
25 25
 jaxon.debug.verbose.active = true;
26 26
 <?php endif ?>
27 27
 <?php endif ?>
28
-<?php if(($this->sCsrfMetaName)): ?>
28
+<?php if (($this->sCsrfMetaName)): ?>
29 29
 metaTags = document.getElementsByTagName('meta');
30 30
 for(i = 0; i < metaTags.length; i++)
31 31
 {
Please login to merge, or discard this patch.
src/Response/Plugin/JQuery/Dom/Element.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
         $this->aCalls = [];
59 59
 
60 60
         $jQueryNs = jaxon()->getOption('core.jquery.no_conflict', false) ? 'jQuery' : '$';
61
-        if(!$sSelector)
61
+        if (!$sSelector)
62 62
         {
63 63
             $this->sSelector = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead
64 64
         }
65
-        elseif(($sContext))
65
+        elseif (($sContext))
66 66
         {
67 67
             $this->sSelector = "$jQueryNs('" . $sSelector . "', $jQueryNs('" . $sContext . "'))";
68 68
         }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function getScript()
120 120
     {
121
-        if(count($this->aCalls) == 0)
121
+        if (count($this->aCalls) == 0)
122 122
         {
123 123
             return $this->sSelector;
124 124
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,12 +57,10 @@
 block discarded – undo
57 57
         if(!$sSelector)
58 58
         {
59 59
             $this->sSelector = "$jQueryNs(this)"; // If an empty selector is given, use javascript "this" instead
60
-        }
61
-        elseif(($sContext))
60
+        } elseif(($sContext))
62 61
         {
63 62
             $this->sSelector = "$jQueryNs('" . $sSelector . "', $jQueryNs('" . $sContext . "'))";
64
-        }
65
-        else
63
+        } else
66 64
         {
67 65
             $this->sSelector = "$jQueryNs('" . $sSelector . "')";
68 66
         }
Please login to merge, or discard this patch.
src/Utils/Template/Renderer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
     public function render($sPath, array $aVars = [])
28 28
     {
29 29
         // Make the template vars available as attributes
30
-        foreach($aVars as $sName => $xValue)
30
+        foreach ($aVars as $sName => $xValue)
31 31
         {
32 32
             $sName = (string)$sName;
33 33
             $this->$sName = $xValue;
Please login to merge, or discard this patch.
src/Request/Factory/Request.php 4 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -270,8 +270,7 @@  discard block
 block discarded – undo
270 270
                     $aVariables[$sParameterStr] = $sVarName;
271 271
                     $sVars .= "$sVarName=$xParameter;";
272 272
                     $nVarId++;
273
-                }
274
-                else
273
+                } else
275 274
                 {
276 275
                     // The value is already defined. The corresponding variable is assigned.
277 276
                     $sVarName = $aVariables[$sParameterStr];
@@ -300,8 +299,7 @@  discard block
 block discarded – undo
300 299
                             $aVariables[$sParameterStr] = $sVarName;
301 300
                             $sVars .= "$sVarName=$xParameter;";
302 301
                             $nVarId++;
303
-                        }
304
-                        else
302
+                        } else
305 303
                         {
306 304
                             // The value is already defined. The corresponding variable is assigned.
307 305
                             $sVarName = $aVariables[$sParameterStr];
@@ -320,8 +318,7 @@  discard block
 block discarded – undo
320 318
         if($this->sCondition == '__confirm__')
321 319
         {
322 320
             $sScript = $xDialog->confirm($sPhrase, $sScript, '');
323
-        }
324
-        elseif($this->sCondition !== null)
321
+        } elseif($this->sCondition !== null)
325 322
         {
326 323
             $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}';
327 324
             if(($sPhrase))
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * @param integer       $nItemsPerPage          The number of items per page page
240 240
      * @param integer       $nItemsTotal            The total number of items
241 241
      *
242
-     * @return Paginator
242
+     * @return \Jaxon\Utils\Pagination\Paginator
243 243
      */
244 244
     public function pg($nCurrentPage, $nItemsPerPage, $nItemsTotal)
245 245
     {
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      * @param integer       $nItemsPerPage          The number of items per page page
255 255
      * @param integer       $nItemsTotal            The total number of items
256 256
      *
257
-     * @return Paginator
257
+     * @return \Jaxon\Utils\Pagination\Paginator
258 258
      */
259 259
     public function paginate($nCurrentPage, $nItemsPerPage, $nItemsTotal)
260 260
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,6 @@
 block discarded – undo
20 20
 
21 21
 namespace Jaxon\Request\Factory;
22 22
 
23
-use JsonSerializable;
24 23
 use Jaxon\Request\Factory\Parameter;
25 24
 use Jaxon\Response\Plugin\JQuery\Dom\Element as DomElement;
26 25
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function hasPageNumber()
54 54
     {
55
-        foreach($this->aParameters as $xParameter)
55
+        foreach ($this->aParameters as $xParameter)
56 56
         {
57
-            if($xParameter->getType() == Parameter::PAGE_NUMBER)
57
+            if ($xParameter->getType() == Parameter::PAGE_NUMBER)
58 58
             {
59 59
                 return true;
60 60
             }
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
     public function setPageNumber($nPageNumber)
73 73
     {
74 74
         // Set the value of the Parameter::PAGE_NUMBER parameter
75
-        foreach($this->aParameters as $xParameter)
75
+        foreach ($this->aParameters as $xParameter)
76 76
         {
77
-            if($xParameter->getType() == Parameter::PAGE_NUMBER)
77
+            if ($xParameter->getType() == Parameter::PAGE_NUMBER)
78 78
             {
79 79
                 $xParameter->setValue(intval($nPageNumber));
80 80
                 break;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     private function setMessageArgs(array $aArgs)
94 94
     {
95
-        array_walk($aArgs, function (&$xParameter) {
95
+        array_walk($aArgs, function(&$xParameter) {
96 96
             $xParameter = Parameter::make($xParameter);
97 97
         });
98 98
         $this->aMessageArgs = $aArgs;
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
         // This array will avoid declaring multiple variables with the same value.
148 148
         // The array key is the variable value, while the array value is the variable name.
149 149
         $aVariables = []; // Array of local variables.
150
-        foreach($this->aParameters as &$xParameter)
150
+        foreach ($this->aParameters as &$xParameter)
151 151
         {
152 152
             $sParameterStr = $xParameter->getScript();
153
-            if($xParameter instanceof DomElement)
153
+            if ($xParameter instanceof DomElement)
154 154
             {
155
-                if(!array_key_exists($sParameterStr, $aVariables))
155
+                if (!array_key_exists($sParameterStr, $aVariables))
156 156
                 {
157 157
                     // The value is not yet defined. A new variable is created.
158 158
                     $sVarName = "jxnVar$nVarId";
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
         }
171 171
 
172 172
         $sPhrase = '';
173
-        if(count($this->aMessageArgs) > 0)
173
+        if (count($this->aMessageArgs) > 0)
174 174
         {
175 175
             $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question.
176 176
             // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes
177
-            if(count($this->aMessageArgs) > 0)
177
+            if (count($this->aMessageArgs) > 0)
178 178
             {
179 179
                 $nParamId = 1;
180
-                foreach($this->aMessageArgs as &$xParameter)
180
+                foreach ($this->aMessageArgs as &$xParameter)
181 181
                 {
182 182
                     $sParameterStr = $xParameter->getScript();
183
-                    if($xParameter instanceof DomElement)
183
+                    if ($xParameter instanceof DomElement)
184 184
                     {
185
-                        if(!array_key_exists($sParameterStr, $aVariables))
185
+                        if (!array_key_exists($sParameterStr, $aVariables))
186 186
                         {
187 187
                             // The value is not yet defined. A new variable is created.
188 188
                             $sVarName = "jxnVar$nVarId";
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 
207 207
         $sScript = parent::getScript();
208 208
         $xDialog = jaxon()->dialog();
209
-        if($this->sCondition == '__confirm__')
209
+        if ($this->sCondition == '__confirm__')
210 210
         {
211 211
             $sScript = $xDialog->confirm($sPhrase, $sScript, '');
212 212
         }
213
-        elseif($this->sCondition !== null)
213
+        elseif ($this->sCondition !== null)
214 214
         {
215 215
             $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}';
216
-            if(($sPhrase))
216
+            if (($sPhrase))
217 217
             {
218 218
                 $xDialog->getAlert()->setReturn(true);
219 219
                 $sScript .= 'else{' . $xDialog->warning($sPhrase) . ';}';
Please login to merge, or discard this patch.
src/App/App.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
     /**
60 60
      * Process an incoming Jaxon request, and return the response.
61 61
      *
62
-     * @return void
62
+     * @return boolean|null
63 63
      */
64 64
     public function processRequest()
65 65
     {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function setup($sConfigFile)
30 30
     {
31
-        if(!file_exists($sConfigFile))
31
+        if (!file_exists($sConfigFile))
32 32
         {
33 33
             throw new Exception("Unable to find config file at $sConfigFile");
34 34
         }
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
         $aLibOptions = key_exists('lib', $aOptions) ? $aOptions['lib'] : [];
39 39
         $aAppOptions = key_exists('app', $aOptions) ? $aOptions['app'] : [];
40 40
 
41
-        if(!is_array($aLibOptions) || !is_array($aAppOptions))
41
+        if (!is_array($aLibOptions) || !is_array($aAppOptions))
42 42
         {
43 43
             throw new Exception("Unexpected content in config file at $sConfigFile");
44 44
         }
45 45
 
46 46
         // Set the session manager
47
-        jaxon()->di()->setSessionManager(function () {
47
+        jaxon()->di()->setSessionManager(function() {
48 48
             return new SessionManager();
49 49
         });
50 50
 
Please login to merge, or discard this patch.
src/Request/Factory/RequestFactory.php 3 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * @param string|null       $sClass              The callable class
55 55
      *
56
-     * @return Factory
56
+     * @return RequestFactory
57 57
      */
58 58
     public function setClassName($sClass)
59 59
     {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @param CallableObject    $xCallable              The callable object
82 82
      *
83
-     * @return Factory
83
+     * @return RequestFactory
84 84
      */
85 85
     public function setCallable(CallableObject $xCallable)
86 86
     {
@@ -93,7 +93,6 @@  discard block
 block discarded – undo
93 93
      * Return the javascript call to a Jaxon function or object method
94 94
      *
95 95
      * @param string            $sFunction          The function or method (without class) name
96
-     * @param ...               $xParams            The parameters of the function or method
97 96
      *
98 97
      * @return Request
99 98
      */
@@ -122,7 +121,6 @@  discard block
 block discarded – undo
122 121
      * Return the javascript call to a generic function
123 122
      *
124 123
      * @param string            $sFunction          The function or method (with class) name
125
-     * @param ...               $xParams            The parameters of the function or method
126 124
      *
127 125
      * @return Request
128 126
      */
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,6 @@
 block discarded – undo
17 17
 
18 18
 use Jaxon\Request\Support\CallableObject;
19 19
 use Jaxon\Request\Support\CallableRepository;
20
-use Jaxon\Utils\Pagination\Paginator;
21 20
 
22 21
 // Extends Parameter for compatibility with older versions (see function rq())
23 22
 class RequestFactory
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
         $this->sPrefix = $this->getOption('core.prefix.function');
62 62
 
63 63
         $sClass = trim($sClass, '.\\ ');
64
-        if(!$sClass)
64
+        if (!$sClass)
65 65
         {
66 66
             return $this;
67 67
         }
68 68
 
69
-        if(!($xCallable = $this->xRepository->getCallableObject($sClass)))
69
+        if (!($xCallable = $this->xRepository->getCallableObject($sClass)))
70 70
         {
71 71
             // Todo: decide which of these values to return
72 72
             // return null;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         array_shift($aArguments);
108 108
 
109 109
         // Makes legacy code works
110
-        if(strpos($sFunction, '.') !== false)
110
+        if (strpos($sFunction, '.') !== false)
111 111
         {
112 112
             // If there is a dot in the name, then it is a call to a class
113 113
             $this->sPrefix = $this->getOption('core.prefix.class');
Please login to merge, or discard this patch.
src/Request/Handler/Argument.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@
 block discarded – undo
152 152
      *
153 153
      * @param string        $sArg                The Jaxon request argument
154 154
      *
155
-     * @return mixed
155
+     * @return string|null
156 156
      */
157 157
     private function __argumentDecode(&$sArg)
158 158
     {
Please login to merge, or discard this patch.
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -131,19 +131,19 @@
 block discarded – undo
131 131
         $sValue = substr($sValue, 1);
132 132
         switch ($cType)
133 133
         {
134
-            case 'S':
135
-                $value = ($sValue === false ? '' : $sValue);
136
-                break;
137
-            case 'B':
138
-                $value = $this->__convertStringToBool($sValue);
139
-                break;
140
-            case 'N':
141
-                $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue);
142
-                break;
143
-            case '*':
144
-            default:
145
-                $value = null;
146
-                break;
134
+        case 'S':
135
+            $value = ($sValue === false ? '' : $sValue);
136
+            break;
137
+        case 'B':
138
+            $value = $this->__convertStringToBool($sValue);
139
+            break;
140
+        case 'N':
141
+            $value = ($sValue == floor($sValue) ? (int)$sValue : (float)$sValue);
142
+            break;
143
+        case '*':
144
+        default:
145
+            $value = null;
146
+            break;
147 147
         }
148 148
         return $value;
149 149
     }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
         $this->aArgs = [];
59 59
         $this->nMethod = self::METHOD_UNKNOWN;
60 60
 
61
-        if(isset($_POST['jxnargs']))
61
+        if (isset($_POST['jxnargs']))
62 62
         {
63 63
             $this->nMethod = self::METHOD_POST;
64 64
             $this->aArgs = $_POST['jxnargs'];
65 65
         }
66
-        elseif(isset($_GET['jxnargs']))
66
+        elseif (isset($_GET['jxnargs']))
67 67
         {
68 68
             $this->nMethod = self::METHOD_GET;
69 69
             $this->aArgs = $_GET['jxnargs'];
70 70
         }
71
-        if(get_magic_quotes_gpc() == 1)
71
+        if (get_magic_quotes_gpc() == 1)
72 72
         {
73 73
             array_walk($this->aArgs, [&$this, '__argumentStripSlashes']);
74 74
         }
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function __convertStringToBool($sValue)
86 86
     {
87
-        if(strcasecmp($sValue, 'true') == 0)
87
+        if (strcasecmp($sValue, 'true') == 0)
88 88
         {
89 89
             return true;
90 90
         }
91
-        if(strcasecmp($sValue, 'false') == 0)
91
+        if (strcasecmp($sValue, 'false') == 0)
92 92
         {
93 93
             return false;
94 94
         }
95
-        if(is_numeric($sValue))
95
+        if (is_numeric($sValue))
96 96
         {
97
-            if($sValue == 0)
97
+            if ($sValue == 0)
98 98
             {
99 99
                 return false;
100 100
             }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function __argumentStripSlashes(&$sArg)
114 114
     {
115
-        if(!is_string($sArg))
115
+        if (!is_string($sArg))
116 116
         {
117 117
             return '';
118 118
         }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      */
161 161
     private function __argumentDecode(&$sArg)
162 162
     {
163
-        if($sArg == '')
163
+        if ($sArg == '')
164 164
         {
165 165
             return '';
166 166
         }
@@ -169,22 +169,22 @@  discard block
 block discarded – undo
169 169
         $sType = 'multipart/form-data';
170 170
         $iLen = strlen($sType);
171 171
         $sContentType = '';
172
-        if(key_exists('CONTENT_TYPE', $_SERVER))
172
+        if (key_exists('CONTENT_TYPE', $_SERVER))
173 173
         {
174 174
             $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen);
175 175
         }
176
-        elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER))
176
+        elseif (key_exists('HTTP_CONTENT_TYPE', $_SERVER))
177 177
         {
178 178
             $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen);
179 179
         }
180
-        if($sContentType == $sType)
180
+        if ($sContentType == $sType)
181 181
         {
182 182
             $sArg = urldecode($sArg);
183 183
         }
184 184
 
185 185
         $data = json_decode($sArg, true);
186 186
 
187
-        if($data !== null && $sArg != $data)
187
+        if ($data !== null && $sArg != $data)
188 188
         {
189 189
             $sArg = $data;
190 190
         }
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
      */
204 204
     private function __argumentDecodeUTF8_iconv(&$mArg)
205 205
     {
206
-        if(is_array($mArg))
206
+        if (is_array($mArg))
207 207
         {
208
-            foreach($mArg as $sKey => &$xArg)
208
+            foreach ($mArg as $sKey => &$xArg)
209 209
             {
210 210
                 $sNewKey = $sKey;
211 211
                 $this->__argumentDecodeUTF8_iconv($sNewKey);
212
-                if($sNewKey != $sKey)
212
+                if ($sNewKey != $sKey)
213 213
                 {
214 214
                     $mArg[$sNewKey] = $xArg;
215 215
                     unset($mArg[$sKey]);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 $this->__argumentDecodeUTF8_iconv($xArg);
219 219
             }
220 220
         }
221
-        elseif(is_string($mArg))
221
+        elseif (is_string($mArg))
222 222
         {
223 223
             $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg);
224 224
         }
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
      */
234 234
     private function __argumentDecodeUTF8_mb_convert_encoding(&$mArg)
235 235
     {
236
-        if(is_array($mArg))
236
+        if (is_array($mArg))
237 237
         {
238
-            foreach($mArg as $sKey => &$xArg)
238
+            foreach ($mArg as $sKey => &$xArg)
239 239
             {
240 240
                 $sNewKey = $sKey;
241 241
                 $this->__argumentDecodeUTF8_mb_convert_encoding($sNewKey);
242
-                if($sNewKey != $sKey)
242
+                if ($sNewKey != $sKey)
243 243
                 {
244 244
                     $mArg[$sNewKey] = $xArg;
245 245
                     unset($mArg[$sKey]);
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                 $this->__argumentDecodeUTF8_mb_convert_encoding($xArg);
249 249
             }
250 250
         }
251
-        elseif(is_string($mArg))
251
+        elseif (is_string($mArg))
252 252
         {
253 253
             $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8");
254 254
         }
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
      */
264 264
     private function __argumentDecodeUTF8_utf8_decode(&$mArg)
265 265
     {
266
-        if(is_array($mArg))
266
+        if (is_array($mArg))
267 267
         {
268
-            foreach($mArg as $sKey => &$xArg)
268
+            foreach ($mArg as $sKey => &$xArg)
269 269
             {
270 270
                 $sNewKey = $sKey;
271 271
                 $this->__argumentDecodeUTF8_utf8_decode($sNewKey);
272 272
 
273
-                if($sNewKey != $sKey)
273
+                if ($sNewKey != $sKey)
274 274
                 {
275 275
                     $mArg[$sNewKey] = $xArg;
276 276
                     unset($mArg[$sKey]);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                 $this->__argumentDecodeUTF8_utf8_decode($xArg);
281 281
             }
282 282
         }
283
-        elseif(is_string($mArg))
283
+        elseif (is_string($mArg))
284 284
         {
285 285
             $mArg = utf8_decode($mArg);
286 286
         }
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public function process()
307 307
     {
308
-        if(($this->getOption('core.decode_utf8')))
308
+        if (($this->getOption('core.decode_utf8')))
309 309
         {
310 310
             $sFunction = '';
311 311
 
312
-            if(function_exists('iconv'))
312
+            if (function_exists('iconv'))
313 313
             {
314 314
                 $sFunction = "iconv";
315 315
             }
316
-            elseif(function_exists('mb_convert_encoding'))
316
+            elseif (function_exists('mb_convert_encoding'))
317 317
             {
318 318
                 $sFunction = "mb_convert_encoding";
319 319
             }
320
-            elseif($this->getOption('core.encoding') == "ISO-8859-1")
320
+            elseif ($this->getOption('core.encoding') == "ISO-8859-1")
321 321
             {
322 322
                 $sFunction = "utf8_decode";
323 323
             }
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
         {
63 63
             $this->nMethod = self::METHOD_POST;
64 64
             $this->aArgs = $_POST['jxnargs'];
65
-        }
66
-        elseif(isset($_GET['jxnargs']))
65
+        } elseif(isset($_GET['jxnargs']))
67 66
         {
68 67
             $this->nMethod = self::METHOD_GET;
69 68
             $this->aArgs = $_GET['jxnargs'];
@@ -172,8 +171,7 @@  discard block
 block discarded – undo
172 171
         if(key_exists('CONTENT_TYPE', $_SERVER))
173 172
         {
174 173
             $sContentType = substr($_SERVER['CONTENT_TYPE'], 0, $iLen);
175
-        }
176
-        elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER))
174
+        } elseif(key_exists('HTTP_CONTENT_TYPE', $_SERVER))
177 175
         {
178 176
             $sContentType = substr($_SERVER['HTTP_CONTENT_TYPE'], 0, $iLen);
179 177
         }
@@ -187,8 +185,7 @@  discard block
 block discarded – undo
187 185
         if($data !== null && $sArg != $data)
188 186
         {
189 187
             $sArg = $data;
190
-        }
191
-        else
188
+        } else
192 189
         {
193 190
             $sArg = $this->__convertValue($sArg);
194 191
         }
@@ -217,8 +214,7 @@  discard block
 block discarded – undo
217 214
                 }
218 215
                 $this->__argumentDecodeUTF8_iconv($xArg);
219 216
             }
220
-        }
221
-        elseif(is_string($mArg))
217
+        } elseif(is_string($mArg))
222 218
         {
223 219
             $mArg = iconv("UTF-8", $this->getOption('core.encoding') . '//TRANSLIT', $mArg);
224 220
         }
@@ -247,8 +243,7 @@  discard block
 block discarded – undo
247 243
                 }
248 244
                 $this->__argumentDecodeUTF8_mb_convert_encoding($xArg);
249 245
             }
250
-        }
251
-        elseif(is_string($mArg))
246
+        } elseif(is_string($mArg))
252 247
         {
253 248
             $mArg = mb_convert_encoding($mArg, $this->getOption('core.encoding'), "UTF-8");
254 249
         }
@@ -279,8 +274,7 @@  discard block
 block discarded – undo
279 274
 
280 275
                 $this->__argumentDecodeUTF8_utf8_decode($xArg);
281 276
             }
282
-        }
283
-        elseif(is_string($mArg))
277
+        } elseif(is_string($mArg))
284 278
         {
285 279
             $mArg = utf8_decode($mArg);
286 280
         }
@@ -312,16 +306,13 @@  discard block
 block discarded – undo
312 306
             if(function_exists('iconv'))
313 307
             {
314 308
                 $sFunction = "iconv";
315
-            }
316
-            elseif(function_exists('mb_convert_encoding'))
309
+            } elseif(function_exists('mb_convert_encoding'))
317 310
             {
318 311
                 $sFunction = "mb_convert_encoding";
319
-            }
320
-            elseif($this->getOption('core.encoding') == "ISO-8859-1")
312
+            } elseif($this->getOption('core.encoding') == "ISO-8859-1")
321 313
             {
322 314
                 $sFunction = "utf8_decode";
323
-            }
324
-            else
315
+            } else
325 316
             {
326 317
                 throw new \Jaxon\Exception\Error($this->trans('errors.request.conversion'));
327 318
             }
Please login to merge, or discard this patch.
src/Request/Plugin/CallableFunction.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
      * @param string        $sCallableFunction  The name of the function being registered
91 91
      * @param array|string  $aOptions       The associated options
92 92
      *
93
-     * @return \Jaxon\Request\Request
93
+     * @return boolean
94 94
      */
95 95
     public function register($sType, $sCallableFunction, $aOptions)
96 96
     {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function __construct()
51 51
     {
52
-        if(isset($_GET['jxnfun']))
52
+        if (isset($_GET['jxnfun']))
53 53
         {
54 54
             $this->sRequestedFunction = $_GET['jxnfun'];
55 55
         }
56
-        if(isset($_POST['jxnfun']))
56
+        if (isset($_POST['jxnfun']))
57 57
         {
58 58
             $this->sRequestedFunction = $_POST['jxnfun'];
59 59
         }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getTarget()
78 78
     {
79
-        if(!$this->sRequestedFunction)
79
+        if (!$this->sRequestedFunction)
80 80
         {
81 81
             return null;
82 82
         }
@@ -95,21 +95,21 @@  discard block
 block discarded – undo
95 95
     public function register($sType, $sCallableFunction, $aOptions)
96 96
     {
97 97
         $sType = trim($sType);
98
-        if($sType != $this->getName())
98
+        if ($sType != $this->getName())
99 99
         {
100 100
             return false;
101 101
         }
102 102
 
103
-        if(!is_string($sCallableFunction))
103
+        if (!is_string($sCallableFunction))
104 104
         {
105 105
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
106 106
         }
107 107
 
108
-        if(is_string($aOptions))
108
+        if (is_string($aOptions))
109 109
         {
110 110
             $aOptions = ['include' => $aOptions];
111 111
         }
112
-        if(!is_array($aOptions))
112
+        if (!is_array($aOptions))
113 113
         {
114 114
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
115 115
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
         $sCallableFunction = trim($sCallableFunction);
118 118
         // Check if an alias is defined
119 119
         $sFunctionName = $sCallableFunction;
120
-        foreach($aOptions as $sName => $sValue)
120
+        foreach ($aOptions as $sName => $sValue)
121 121
         {
122
-            if($sName == 'alias')
122
+            if ($sName == 'alias')
123 123
             {
124 124
                 $sFunctionName = $sValue;
125 125
                 break;
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
         }
128 128
 
129 129
         $this->aFunctions[$sFunctionName] = $aOptions;
130
-        jaxon()->di()->set($sFunctionName, function () use ($sFunctionName, $sCallableFunction) {
130
+        jaxon()->di()->set($sFunctionName, function() use ($sFunctionName, $sCallableFunction) {
131 131
             $xCallableFunction = new \Jaxon\Request\Support\CallableFunction($sCallableFunction);
132 132
 
133 133
             $aOptions = $this->aFunctions[$sFunctionName];
134
-            foreach($aOptions as $sName => $sValue)
134
+            foreach ($aOptions as $sName => $sValue)
135 135
             {
136 136
                 $xCallableFunction->configure($sName, $sValue);
137 137
             }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     {
162 162
         $di = jaxon()->di();
163 163
         $code = '';
164
-        foreach(array_keys($this->aFunctions) as $sName)
164
+        foreach (array_keys($this->aFunctions) as $sName)
165 165
         {
166 166
             $xFunction = $di->get($sName);
167 167
             $code .= $xFunction->getScript();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     public function canProcessRequest()
178 178
     {
179 179
         // Check the validity of the function name
180
-        if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
180
+        if (($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction))
181 181
         {
182 182
             $this->sRequestedFunction = null;
183 183
         }
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
      */
192 192
     public function processRequest()
193 193
     {
194
-        if(!$this->canProcessRequest())
194
+        if (!$this->canProcessRequest())
195 195
         {
196 196
             return false;
197 197
         }
198 198
 
199 199
         // Security check: make sure the requested function was registered.
200
-        if(!key_exists($this->sRequestedFunction, $this->aFunctions))
200
+        if (!key_exists($this->sRequestedFunction, $this->aFunctions))
201 201
         {
202 202
             // Unable to find the requested function
203 203
             throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid',
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         $xFunction = $di->get($this->sRequestedFunction);
209 209
         $aArgs = $di->getRequestHandler()->processArguments();
210 210
         $xResponse = $xFunction->call($aArgs);
211
-        if(($xResponse))
211
+        if (($xResponse))
212 212
         {
213 213
             $di->getResponseManager()->append($xResponse);
214 214
         }
Please login to merge, or discard this patch.