Completed
Push — master ( f4cda3...cae0c7 )
by Thierry
03:50
created
src/Utils/Config/Yaml.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
     public static function read($sConfigFile, $sLibKey = '', $sAppKey = null)
30 30
     {
31 31
         $sConfigFile = realpath($sConfigFile);
32
-        if(!extension_loaded('yaml'))
32
+        if (!extension_loaded('yaml'))
33 33
         {
34 34
             throw new \Jaxon\Exception\Config\Yaml(jaxon_trans('config.errors.yaml.install'));
35 35
         }
36
-        if(!is_readable($sConfigFile))
36
+        if (!is_readable($sConfigFile))
37 37
         {
38 38
             throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile)));
39 39
         }
40 40
         $aConfigOptions = yaml_parse_file($sConfigFile);
41
-        if(!is_array($aConfigOptions))
41
+        if (!is_array($aConfigOptions))
42 42
         {
43 43
             throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile)));
44 44
         }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         // Setup the config options into the library.
47 47
         $jaxon = jaxon();
48 48
         $jaxon->setOptions($aConfigOptions, $sLibKey);
49
-        if(!is_string($sAppKey))
49
+        if (!is_string($sAppKey))
50 50
         {
51 51
             return null;
52 52
         }
Please login to merge, or discard this patch.
src/Utils/Config/Php.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
     public static function read($sConfigFile, $sLibKey = '', $sAppKey = null)
30 30
     {
31 31
         $sConfigFile = realpath($sConfigFile);
32
-        if(!is_readable($sConfigFile))
32
+        if (!is_readable($sConfigFile))
33 33
         {
34 34
             throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile)));
35 35
         }
36 36
         $aConfigOptions = include($sConfigFile);
37
-        if(!is_array($aConfigOptions))
37
+        if (!is_array($aConfigOptions))
38 38
         {
39 39
             throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile)));
40 40
         }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         // Setup the config options into the library.
43 43
         $jaxon = jaxon();
44 44
         $jaxon->setOptions($aConfigOptions, $sLibKey);
45
-        if(!is_string($sAppKey))
45
+        if (!is_string($sAppKey))
46 46
         {
47 47
             return null;
48 48
         }
Please login to merge, or discard this patch.
src/Request/Parameter.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public static function make($xValue)
93 93
     {
94
-        if($xValue instanceof Interfaces\Parameter)
94
+        if ($xValue instanceof Interfaces\Parameter)
95 95
         {
96 96
             return $xValue;
97 97
         }
98
-        elseif(is_numeric($xValue))
98
+        elseif (is_numeric($xValue))
99 99
         {
100 100
             return new Parameter(Jaxon::NUMERIC_VALUE, $xValue);
101 101
         }
102
-        elseif(is_string($xValue))
102
+        elseif (is_string($xValue))
103 103
         {
104 104
             return new Parameter(Jaxon::QUOTED_VALUE, $xValue);
105 105
         }
106
-        elseif(is_bool($xValue))
106
+        elseif (is_bool($xValue))
107 107
         {
108 108
             return new Parameter(Jaxon::BOOL_VALUE, $xValue);
109 109
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $sJsCode = '';
124 124
         $sQuoteCharacter = "'";
125
-        switch($this->sType)
125
+        switch ($this->sType)
126 126
         {
127 127
         case Jaxon::FORM_VALUES:
128 128
             $sFormID = (string)$this->xValue;
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
             break;
131 131
         case Jaxon::INPUT_VALUE:
132 132
             $sInputID = (string)$this->xValue;
133
-            $sJsCode = "jaxon.$("  . $sQuoteCharacter . $sInputID . $sQuoteCharacter  . ").value";
133
+            $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sInputID . $sQuoteCharacter . ").value";
134 134
             break;
135 135
         case Jaxon::CHECKED_VALUE:
136 136
             $sCheckedID = (string)$this->xValue;
137
-            $sJsCode = "jaxon.$("  . $sQuoteCharacter . $sCheckedID  . $sQuoteCharacter . ").checked";
137
+            $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sCheckedID . $sQuoteCharacter . ").checked";
138 138
             break;
139 139
         case Jaxon::ELEMENT_INNERHTML:
140 140
             $sElementID = (string)$this->xValue;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             $sJsCode = (string)$this->xValue;
154 154
             break;
155 155
         case Jaxon::JS_VALUE:
156
-            if(is_array($this->xValue) || is_object($this->xValue))
156
+            if (is_array($this->xValue) || is_object($this->xValue))
157 157
             {
158 158
                 // Unable to use double quotes here because they cannot be handled on client side.
159 159
                 // So we are using simple quotes even if the Json standard recommends double quotes.
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -94,20 +94,16 @@  discard block
 block discarded – undo
94 94
         if($xValue instanceof Interfaces\Parameter)
95 95
         {
96 96
             return $xValue;
97
-        }
98
-        elseif(is_numeric($xValue))
97
+        } elseif(is_numeric($xValue))
99 98
         {
100 99
             return new Parameter(Jaxon::NUMERIC_VALUE, $xValue);
101
-        }
102
-        elseif(is_string($xValue))
100
+        } elseif(is_string($xValue))
103 101
         {
104 102
             return new Parameter(Jaxon::QUOTED_VALUE, $xValue);
105
-        }
106
-        elseif(is_bool($xValue))
103
+        } elseif(is_bool($xValue))
107 104
         {
108 105
             return new Parameter(Jaxon::BOOL_VALUE, $xValue);
109
-        }
110
-        else // if(is_array($xValue) || is_object($xValue))
106
+        } else // if(is_array($xValue) || is_object($xValue))
111 107
         {
112 108
             return new Parameter(Jaxon::JS_VALUE, $xValue);
113 109
         }
@@ -158,8 +154,7 @@  discard block
 block discarded – undo
158 154
                 // Unable to use double quotes here because they cannot be handled on client side.
159 155
                 // So we are using simple quotes even if the Json standard recommends double quotes.
160 156
                 $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT));
161
-            }
162
-            else
157
+            } else
163 158
             {
164 159
                 $sJsCode = (string)$this->xValue;
165 160
             }
Please login to merge, or discard this patch.
src/Request/Plugin/BrowserEvent.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 
52 52
         $this->sRequestedEvent = null;
53 53
 
54
-        if(isset($_GET['jxnevt']))
54
+        if (isset($_GET['jxnevt']))
55 55
         {
56 56
             $this->sRequestedEvent = $_GET['jxnevt'];
57 57
         }
58
-        if(isset($_POST['jxnevt']))
58
+        if (isset($_POST['jxnevt']))
59 59
         {
60 60
             $this->sRequestedEvent = $_POST['jxnevt'];
61 61
         }
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function register($aArgs)
82 82
     {
83
-        if(count($aArgs) > 1)
83
+        if (count($aArgs) > 1)
84 84
         {
85 85
             $sType = $aArgs[0];
86 86
 
87
-            if($sType == Jaxon::BROWSER_EVENT)
87
+            if ($sType == Jaxon::BROWSER_EVENT)
88 88
             {
89 89
                 $sEvent = $aArgs[1];
90
-                if(!isset($this->aEvents[$sEvent]))
90
+                if (!isset($this->aEvents[$sEvent]))
91 91
                 {
92 92
                     $xBrowserEvent = new \Jaxon\Support\BrowserEvent($sEvent);
93
-                    if(count($aArgs) > 2 && is_array($aArgs[2]))
93
+                    if (count($aArgs) > 2 && is_array($aArgs[2]))
94 94
                     {
95
-                        foreach($aArgs[2] as $sKey => $sValue)
95
+                        foreach ($aArgs[2] as $sKey => $sValue)
96 96
                         {
97 97
                             $xBrowserEvent->configure($sKey, $sValue);
98 98
                         }
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
                     return $xBrowserEvent->generateRequest();
102 102
                 }
103 103
             }
104
-            elseif($sType == Jaxon::EVENT_HANDLER)
104
+            elseif ($sType == Jaxon::EVENT_HANDLER)
105 105
             {
106 106
                 $sEvent = $aArgs[1];
107
-                if(isset($this->aEvents[$sEvent]) && isset($aArgs[2]))
107
+                if (isset($this->aEvents[$sEvent]) && isset($aArgs[2]))
108 108
                 {
109 109
                     $xUserFunction = $aArgs[2];
110
-                    if(!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction))
110
+                    if (!($xUserFunction instanceof \Jaxon\Request\Support\UserFunction))
111 111
                     {
112 112
                         $xUserFunction = new \Jaxon\Request\Support\UserFunction($xUserFunction);
113 113
                     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     public function generateHash()
130 130
     {
131 131
         $sHash = '';
132
-        foreach($this->aEvents as $xEvent)
132
+        foreach ($this->aEvents as $xEvent)
133 133
         {
134 134
             $sHash .= $xEvent->getName();
135 135
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     public function getScript()
145 145
     {
146 146
         $sCode = '';
147
-        foreach($this->aEvents as $xEvent)
147
+        foreach ($this->aEvents as $xEvent)
148 148
         {
149 149
             $sCode .= $xEvent->getScript();
150 150
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     public function canProcessRequest()
160 160
     {
161 161
         // Check the validity of the event name
162
-        if(($this->sRequestedEvent) && !$this->validateEvent($this->sRequestedEvent))
162
+        if (($this->sRequestedEvent) && !$this->validateEvent($this->sRequestedEvent))
163 163
         {
164 164
             $this->sRequestedEvent = null;
165 165
         }
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function processRequest()
175 175
     {
176
-        if(!$this->canProcessRequest())
176
+        if (!$this->canProcessRequest())
177 177
             return false;
178 178
 
179 179
         $aArgs = $this->getRequestManager()->process();
180 180
 
181
-        if(array_key_exists($this->sRequestedEvent, $this->aEvents))
181
+        if (array_key_exists($this->sRequestedEvent, $this->aEvents))
182 182
         {
183 183
             $this->aEvents[$this->sRequestedEvent]->fire($aArgs);
184 184
             return true;
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -100,8 +100,7 @@  discard block
 block discarded – undo
100 100
                     $this->aEvents[$sEvent] = $xBrowserEvent;
101 101
                     return $xBrowserEvent->generateRequest();
102 102
                 }
103
-            }
104
-            elseif($sType == Jaxon::EVENT_HANDLER)
103
+            } elseif($sType == Jaxon::EVENT_HANDLER)
105 104
             {
106 105
                 $sEvent = $aArgs[1];
107 106
                 if(isset($this->aEvents[$sEvent]) && isset($aArgs[2]))
@@ -173,8 +172,9 @@  discard block
 block discarded – undo
173 172
      */
174 173
     public function processRequest()
175 174
     {
176
-        if(!$this->canProcessRequest())
177
-            return false;
175
+        if(!$this->canProcessRequest()) {
176
+                    return false;
177
+        }
178 178
 
179 179
         $aArgs = $this->getRequestManager()->process();
180 180
 
Please login to merge, or discard this patch.
src/Jaxon.php 4 patches
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -212,8 +212,9 @@  discard block
 block discarded – undo
212 212
             {
213 213
                 $sEvent = $xArgs;
214 214
                 $xUserFunction = $aArgs[2];
215
-                if(!is_a($xUserFunction, 'Request\\Support\\UserFunction'))
216
-                    $xUserFunction = new Request\Support\UserFunction($xUserFunction);
215
+                if(!is_a($xUserFunction, 'Request\\Support\\UserFunction')) {
216
+                                    $xUserFunction = new Request\Support\UserFunction($xUserFunction);
217
+                }
217 218
                 $this->aProcessingEvents[$sEvent] = $xUserFunction;
218 219
             }
219 220
             /*else
@@ -326,8 +327,7 @@  discard block
 block discarded – undo
326 327
             try
327 328
             {
328 329
                 $mResult = $this->getPluginManager()->processRequest();
329
-            }
330
-            catch(Exception $e)
330
+            } catch(Exception $e)
331 331
             {
332 332
                 // An exception was thrown while processing the request.
333 333
                 // The request missed the corresponding handler function,
@@ -344,8 +344,7 @@  discard block
 block discarded – undo
344 344
                 {
345 345
                     $sEvent = self::PROCESSING_EVENT_INVALID;
346 346
                     $aParams = array($e->getMessage());
347
-                }
348
-                else
347
+                } else
349 348
                 {
350 349
                     $sEvent = self::PROCESSING_EVENT_ERROR;
351 350
                     $aParams = array($e);
@@ -355,8 +354,7 @@  discard block
 block discarded – undo
355 354
                 {
356 355
                     // Call the processing event
357 356
                     $this->aProcessingEvents[$sEvent]->call($aParams);
358
-                }
359
-                else
357
+                } else
360 358
                 {
361 359
                     // The exception is not to be processed here.
362 360
                     throw $e;
Please login to merge, or discard this patch.
Doc Comments   -9 removed lines patch added patch discarded remove patch
@@ -141,15 +141,6 @@
 block discarded – undo
141 141
      *        - Jaxon::CALLABLE_OBJECT: an object who's methods are to be registered
142 142
      *        - Jaxon::BROWSER_EVENT: an event which will cause zero or more event handlers to be called
143 143
      *        - Jaxon::EVENT_HANDLER: register an event handler function.
144
-     * @param mixed        $sFunction | $objObject | $sEvent
145
-     *        When registering a function, this is the name of the function
146
-     *        When registering a callable object, this is the object being registered
147
-     *        When registering an event or event handler, this is the name of the event
148
-     * @param mixed        $sIncludeFile | $aCallOptions | $sEventHandler
149
-     *        When registering a function, this is the (optional) include file
150
-     *        When registering a callable object, this is an (optional) array
151
-     *             of call options for the functions being registered
152
-     *        When registering an event handler, this is the name of the function
153 144
      *
154 145
      * @return mixed
155 146
      */
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
         $aArgs = func_get_args();
159 159
         $nArgs = func_num_args();
160 160
 
161
-        if(self::PROCESSING_EVENT == $sType)
161
+        if (self::PROCESSING_EVENT == $sType)
162 162
         {
163
-            if($nArgs > 2)
163
+            if ($nArgs > 2)
164 164
             {
165 165
                 $sEvent = $xArgs;
166 166
                 $xUserFunction = $aArgs[2];
167
-                if(!is_a($xUserFunction, 'Request\\Support\\UserFunction'))
167
+                if (!is_a($xUserFunction, 'Request\\Support\\UserFunction'))
168 168
                     $xUserFunction = new Request\Support\UserFunction($xUserFunction);
169 169
                 $this->aProcessingEvents[$sEvent] = $xUserFunction;
170 170
             }
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function getScript($bIncludeJs = false, $bIncludeCss = false)
238 238
     {
239
-        if(!$this->getOption('core.request.uri'))
239
+        if (!$this->getOption('core.request.uri'))
240 240
         {
241 241
             $this->setOption('core.request.uri', URI::detect());
242 242
         }
243 243
         $sCode = '';
244
-        if(($bIncludeCss))
244
+        if (($bIncludeCss))
245 245
         {
246 246
             $sCode .= $this->getPluginManager()->getCss() . "\n";
247 247
         }
248
-        if(($bIncludeJs))
248
+        if (($bIncludeJs))
249 249
         {
250 250
             $sCode .= $this->getPluginManager()->getJs() . "\n";
251 251
         }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     public function processRequest()
317 317
     {
318 318
         // Check to see if headers have already been sent out, in which case we can't do our job
319
-        if(headers_sent($filename, $linenumber))
319
+        if (headers_sent($filename, $linenumber))
320 320
         {
321 321
             echo $this->trans('errors.output.already-sent', array(
322 322
                 'location' => $filename . ':' . $linenumber
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         }
326 326
 
327 327
         // Check if there is a plugin to process this request
328
-        if(!$this->canProcessRequest())
328
+        if (!$this->canProcessRequest())
329 329
         {
330 330
             return;
331 331
         }
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
         $mResult = true;
335 335
 
336 336
         // Handle before processing event
337
-        if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]))
337
+        if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]))
338 338
         {
339 339
             $this->aProcessingEvents[self::PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest));
340 340
         }
341 341
 
342
-        if(!$bEndRequest)
342
+        if (!$bEndRequest)
343 343
         {
344 344
             try
345 345
             {
346 346
                 $mResult = $this->getPluginManager()->processRequest();
347 347
             }
348
-            catch(Exception $e)
348
+            catch (Exception $e)
349 349
             {
350 350
                 // An exception was thrown while processing the request.
351 351
                 // The request missed the corresponding handler function,
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 $xResponseManager->debug($e->getMessage());
359 359
                 $mResult = false;
360 360
 
361
-                if($e instanceof \Jaxon\Exception\Error)
361
+                if ($e instanceof \Jaxon\Exception\Error)
362 362
                 {
363 363
                     $sEvent = self::PROCESSING_EVENT_INVALID;
364 364
                     $aParams = array($e->getMessage());
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                     $aParams = array($e);
370 370
                 }
371 371
 
372
-                if(isset($this->aProcessingEvents[$sEvent]))
372
+                if (isset($this->aProcessingEvents[$sEvent]))
373 373
                 {
374 374
                     // Call the processing event
375 375
                     $this->aProcessingEvents[$sEvent]->call($aParams);
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             }
383 383
         }
384 384
         // Clean the processing buffer
385
-        if(($this->getOption('core.process.clean')))
385
+        if (($this->getOption('core.process.clean')))
386 386
         {
387 387
             $er = error_reporting(0);
388 388
             while (ob_get_level() > 0)
@@ -392,10 +392,10 @@  discard block
 block discarded – undo
392 392
             error_reporting($er);
393 393
         }
394 394
 
395
-        if($mResult === true)
395
+        if ($mResult === true)
396 396
         {
397 397
             // Handle after processing event
398
-            if(isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]))
398
+            if (isset($this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]))
399 399
             {
400 400
                 $bEndRequest = false;
401 401
                 $this->aProcessingEvents[self::PROCESSING_EVENT_AFTER]->call(array($bEndRequest));
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
         $this->getResponseManager()->printDebug();
406 406
 
407
-        if(($this->getOption('core.process.exit')))
407
+        if (($this->getOption('core.process.exit')))
408 408
         {
409 409
             $this->getResponseManager()->sendOutput();
410 410
             exit();
Please login to merge, or discard this patch.
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -25,14 +25,9 @@
 block discarded – undo
25 25
 
26 26
 namespace Jaxon;
27 27
 
28
-use Jaxon\Plugin\Manager as PluginManager;
29
-use Jaxon\Request\Manager as RequestManager;
30
-use Jaxon\Response\Manager as ResponseManager;
31
-
32 28
 use Jaxon\Utils\URI;
33 29
 use Jaxon\Utils\Container;
34 30
 use Exception;
35
-use Closure;
36 31
 
37 32
 class Jaxon
38 33
 {
Please login to merge, or discard this patch.
src/Utils/Validation/Validator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         // Verify the file extension
130 130
         $xDefault = $this->xConfig->getOption('upload.default.types');
131 131
         $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.types', $xDefault);
132
-        if(is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed))
132
+        if (is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed))
133 133
         {
134 134
             $this->sErrorMessage = $this->xTranslator->trans('errors.upload.type', $aUploadedFile);
135 135
             return false;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         // Verify the file extension
138 138
         $xDefault = $this->xConfig->getOption('upload.default.extensions');
139 139
         $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.extensions', $xDefault);
140
-        if(is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed))
140
+        if (is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed))
141 141
         {
142 142
             $this->sErrorMessage = $this->xTranslator->trans('errors.upload.extension', $aUploadedFile);
143 143
             return false;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         // Verify the max size
146 146
         $xDefault = $this->xConfig->getOption('upload.default.max-size', 0);
147 147
         $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.max-size', $xDefault);
148
-        if($iSize > 0 && $aUploadedFile['size'] > $iSize)
148
+        if ($iSize > 0 && $aUploadedFile['size'] > $iSize)
149 149
         {
150 150
             $this->sErrorMessage = $this->xTranslator->trans('errors.upload.max-size', $aUploadedFile);
151 151
             return false;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         // Verify the min size
154 154
         $xDefault = $this->xConfig->getOption('upload.default.min-size', 0);
155 155
         $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.min-size', $xDefault);
156
-        if($iSize > 0 && $aUploadedFile['size'] < $iSize)
156
+        if ($iSize > 0 && $aUploadedFile['size'] < $iSize)
157 157
         {
158 158
             $this->sErrorMessage = $this->xTranslator->trans('errors.upload.min-size', $aUploadedFile);
159 159
             return false;
Please login to merge, or discard this patch.
src/Utils/Translation/Translator.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
         }
122 122
         if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage]))
123 123
         {
124
-           return $sText;
124
+            return $sText;
125 125
         }
126 126
         $message = $this->aTranslations[$sLanguage][$sText];
127 127
         foreach($aPlaceHolders as $name => $value)
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
      */
56 56
     private function _loadTranslations($sLanguage, $sPrefix, array $aTranslations)
57 57
     {
58
-        foreach($aTranslations as $sName => $xTranslation)
58
+        foreach ($aTranslations as $sName => $xTranslation)
59 59
         {
60 60
             $sName = trim($sName);
61 61
             $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName;
62
-            if(!is_array($xTranslation))
62
+            if (!is_array($xTranslation))
63 63
             {
64 64
                 // Save this translation
65 65
                 $this->aTranslations[$sLanguage][$sName] = $xTranslation;
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function loadTranslations($sFilePath, $sLanguage)
84 84
     {
85
-        if(!file_exists($sFilePath))
85
+        if (!file_exists($sFilePath))
86 86
         {
87 87
             return;
88 88
         }
89 89
         $aTranslations = require($sFilePath);
90
-        if(!is_array($aTranslations))
90
+        if (!is_array($aTranslations))
91 91
         {
92 92
             return;
93 93
         }
94 94
         // Load the translations
95
-        if(!array_key_exists($sLanguage, $this->aTranslations))
95
+        if (!array_key_exists($sLanguage, $this->aTranslations))
96 96
         {
97 97
             $this->aTranslations[$sLanguage] = [];
98 98
         }
@@ -111,20 +111,20 @@  discard block
 block discarded – undo
111 111
     public function trans($sText, array $aPlaceHolders = array(), $sLanguage = null)
112 112
     {
113 113
         $sText = trim((string)$sText);
114
-        if(!$sLanguage)
114
+        if (!$sLanguage)
115 115
         {
116 116
             $sLanguage = $this->xConfig->getOption('language');
117 117
         }
118
-        if(!$sLanguage)
118
+        if (!$sLanguage)
119 119
         {
120 120
             $sLanguage = $this->sDefaultLocale;
121 121
         }
122
-        if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage]))
122
+        if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage]))
123 123
         {
124 124
            return $sText;
125 125
         }
126 126
         $message = $this->aTranslations[$sLanguage][$sText];
127
-        foreach($aPlaceHolders as $name => $value)
127
+        foreach ($aPlaceHolders as $name => $value)
128 128
         {
129 129
             $message = str_replace(':' . $name, $value, $message);
130 130
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@
 block discarded – undo
63 63
             {
64 64
                 // Save this translation
65 65
                 $this->aTranslations[$sLanguage][$sName] = $xTranslation;
66
-            }
67
-            else
66
+            } else
68 67
             {
69 68
                 // Recursively read the translations in the array
70 69
                 $this->_loadTranslations($sLanguage, $sName, $xTranslation);
Please login to merge, or discard this patch.
src/Request/Plugin/FileUpload.php 5 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @param array         $aArgs                An array containing the event specification
282 282
      *
283
-     * @return \Jaxon\Request\Request
283
+     * @return boolean
284 284
      */
285 285
     public function register($aArgs)
286 286
     {
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     /**
343 343
      * Check uploaded files validity and move them to the user dir
344 344
      *
345
-     * @return boolean
345
+     * @return string
346 346
      */
347 347
     public function saveUploadedFiles()
348 348
     {
Please login to merge, or discard this patch.
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.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $this->aUserFiles = [];
51 51
 
52
-        if(array_key_exists('jxnupl', $_POST))
52
+        if (array_key_exists('jxnupl', $_POST))
53 53
         {
54 54
             $this->sTempFile = $_POST['jxnupl'];
55 55
         }
56
-        elseif(array_key_exists('jxnupl', $_GET))
56
+        elseif (array_key_exists('jxnupl', $_GET))
57 57
         {
58 58
             $this->sTempFile = $_GET['jxnupl'];
59 59
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function filterFilename($sFilename, $sVarName)
83 83
     {
84
-        if(($this->fFileFilter))
84
+        if (($this->fFileFilter))
85 85
         {
86 86
             $fFileFilter = $this->fFileFilter;
87 87
             $sFilename = (string)$fFileFilter($sFilename, $sVarName);
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
     {
99 99
         // Check validity of the uploaded files
100 100
         $aTempFiles = [];
101
-        foreach($_FILES as $sVarName => $aFile)
101
+        foreach ($_FILES as $sVarName => $aFile)
102 102
         {
103
-            if(is_array($aFile['name']))
103
+            if (is_array($aFile['name']))
104 104
             {
105
-                for($i = 0; $i < count($aFile['name']); $i++)
105
+                for ($i = 0; $i < count($aFile['name']); $i++)
106 106
                 {
107
-                    if(!$aFile['name'][$i])
107
+                    if (!$aFile['name'][$i])
108 108
                     {
109 109
                         continue;
110 110
                     }
111
-                    if(!array_key_exists($sVarName, $aTempFiles))
111
+                    if (!array_key_exists($sVarName, $aTempFiles))
112 112
                     {
113 113
                         $aTempFiles[$sVarName] = [];
114 114
                     }
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
             }
129 129
             else
130 130
             {
131
-                if(!$aFile['name'])
131
+                if (!$aFile['name'])
132 132
                 {
133 133
                     continue;
134 134
                 }
135
-                if(!array_key_exists($sVarName, $aTempFiles))
135
+                if (!array_key_exists($sVarName, $aTempFiles))
136 136
                 {
137 137
                     $aTempFiles[$sVarName] = [];
138 138
                 }
@@ -155,24 +155,24 @@  discard block
 block discarded – undo
155 155
         $sDefaultUploadDir = $this->getOption('upload.default.dir');
156 156
 
157 157
         // Check uploaded files validity
158
-        foreach($aTempFiles as $sVarName => $aFiles)
158
+        foreach ($aTempFiles as $sVarName => $aFiles)
159 159
         {
160
-            foreach($aFiles as $aFile)
160
+            foreach ($aFiles as $aFile)
161 161
             {
162 162
                 // Verify upload result
163
-                if($aFile['error'] != 0)
163
+                if ($aFile['error'] != 0)
164 164
                 {
165 165
                     throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile));
166 166
                 }
167 167
                 // Verify file validity (format, size)
168
-                if(!$this->validateUploadedFile($sVarName, $aFile))
168
+                if (!$this->validateUploadedFile($sVarName, $aFile))
169 169
                 {
170 170
                     throw new \Jaxon\Exception\Error($this->getValidatorMessage());
171 171
                 }
172 172
                 // Verify that the upload dir exists and is writable
173 173
                 $sUploadDir = $this->getOption('upload.files.' . $sVarName . '.dir', $sDefaultUploadDir);
174 174
                 $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
175
-                if(!is_writable($sUploadDir))
175
+                if (!is_writable($sUploadDir))
176 176
                 {
177 177
                     throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
178 178
                 }
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
         }
181 181
 
182 182
         // Copy the uploaded files from the temp dir to the user dir
183
-        foreach($aTempFiles as $sVarName => $aTempFiles)
183
+        foreach ($aTempFiles as $sVarName => $aTempFiles)
184 184
         {
185 185
             $this->aUserFiles[$sVarName] = [];
186
-            foreach($aTempFiles as $aFile)
186
+            foreach ($aTempFiles as $aFile)
187 187
             {
188 188
                 // Set the user file data
189 189
                 $sUploadDir = $this->getOption('upload.files.' . $sVarName . '.dir', $sDefaultUploadDir);
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
         // Default upload dir
207 207
         $sUploadDir = $this->getOption('upload.default.dir');
208 208
         $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
209
-        if(!is_writable($sUploadDir))
209
+        if (!is_writable($sUploadDir))
210 210
         {
211 211
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
212 212
         }
213 213
         // Convert uploaded file to an array
214 214
         $aFiles = [];
215
-        foreach($this->aUserFiles as $sVarName => $aUserFiles)
215
+        foreach ($this->aUserFiles as $sVarName => $aUserFiles)
216 216
         {
217 217
             $aFiles[$sVarName] = [];
218
-            foreach($aUserFiles as $aUserFile)
218
+            foreach ($aUserFiles as $aUserFile)
219 219
             {
220 220
                  $aFiles[$sVarName][] = $aUserFile->toTempData();
221 221
             }
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
         $sUploadDir = $this->getOption('upload.default.dir');
239 239
         $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
240 240
         $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR;
241
-        if(!is_readable($sUploadDir . $this->sTempFile . '.json'))
241
+        if (!is_readable($sUploadDir . $this->sTempFile . '.json'))
242 242
         {
243 243
             throw new \Jaxon\Exception\Error($this->trans('errors.upload.access'));
244 244
         }
245 245
         $aFiles = file_get_contents($sUploadDir . $this->sTempFile . '.json');
246 246
         $aFiles = json_decode($aFiles, true);
247
-        foreach($aFiles as $sVarName => $aUserFiles)
247
+        foreach ($aFiles as $sVarName => $aUserFiles)
248 248
         {
249 249
             $this->aUserFiles[$sVarName] = [];
250
-            foreach($aUserFiles as $aUserFile)
250
+            foreach ($aUserFiles as $aUserFile)
251 251
             {
252 252
                 $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile);
253 253
             }
@@ -324,15 +324,15 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function processRequest()
326 326
     {
327
-        if(!$this->canProcessRequest())
327
+        if (!$this->canProcessRequest())
328 328
         {
329 329
             return false;
330 330
         }
331
-        if(count($_FILES) > 0)
331
+        if (count($_FILES) > 0)
332 332
         {
333 333
             $this->readFromHttpData();
334 334
         }
335
-        elseif(($this->sTempFile))
335
+        elseif (($this->sTempFile))
336 336
         {
337 337
             $this->readFromTempFile();
338 338
         }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
     public function saveUploadedFiles()
348 348
     {
349 349
         // Process uploaded files
350
-        if(!$this->processRequest())
350
+        if (!$this->processRequest())
351 351
         {
352 352
             return '';
353 353
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
         if(array_key_exists('jxnupl', $_POST))
53 53
         {
54 54
             $this->sTempFile = $_POST['jxnupl'];
55
-        }
56
-        elseif(array_key_exists('jxnupl', $_GET))
55
+        } elseif(array_key_exists('jxnupl', $_GET))
57 56
         {
58 57
             $this->sTempFile = $_GET['jxnupl'];
59 58
         }
@@ -125,8 +124,7 @@  discard block
 block discarded – undo
125 124
                         'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION),
126 125
                     ];
127 126
                 }
128
-            }
129
-            else
127
+            } else
130 128
             {
131 129
                 if(!$aFile['name'])
132 130
                 {
@@ -331,8 +329,7 @@  discard block
 block discarded – undo
331 329
         if(count($_FILES) > 0)
332 330
         {
333 331
             $this->readFromHttpData();
334
-        }
335
-        elseif(($this->sTempFile))
332
+        } elseif(($this->sTempFile))
336 333
         {
337 334
             $this->readFromTempFile();
338 335
         }
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 use Jaxon\Jaxon;
16 16
 use Jaxon\Plugin\Request as RequestPlugin;
17 17
 use Jaxon\Request\Support\UploadedFile;
18
-
19 18
 use Closure;
20 19
 
21 20
 class FileUpload extends RequestPlugin
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.