Completed
Push — master ( bcb23d...237738 )
by Thierry
01:30
created
src/App/App.php 1 patch
Spacing   +5 added lines, -5 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
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $jaxon = jaxon();
69 69
         // Only if the response is not yet sent
70
-        if(!$jaxon->getOption('core.response.send'))
70
+        if (!$jaxon->getOption('core.response.send'))
71 71
         {
72 72
             // Set the HTTP response code
73 73
             http_response_code(intval($code));
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             // Send the response
76 76
             $jaxon->di()->getResponseManager()->sendOutput();
77 77
 
78
-            if(($jaxon->getOption('core.process.exit')))
78
+            if (($jaxon->getOption('core.process.exit')))
79 79
             {
80 80
                 exit();
81 81
             }
Please login to merge, or discard this patch.
src/Utils/Http/URI.php 2 patches
Braces   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
             if(strpos($_SERVER[$sKey], ':') > 0)
30 30
             {
31 31
                 list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]);
32
-            }
33
-            else
32
+            } else
34 33
             {
35 34
                 $aURL['host'] = $_SERVER[$sKey];
36 35
             }
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
             if(!empty($_SERVER['HTTP_SCHEME']))
59 58
             {
60 59
                 $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
61
-            }
62
-            else
60
+            } else
63 61
             {
64 62
                 $aURL['scheme'] = ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http');
65 63
             }
@@ -88,8 +86,7 @@  discard block
 block discarded – undo
88 86
             if(!empty($_SERVER['PATH_INFO']))
89 87
             {
90 88
                 $sPath = parse_url($_SERVER['PATH_INFO']);
91
-            }
92
-            else
89
+            } else
93 90
             {
94 91
                 $sPath = parse_url($_SERVER['PHP_SELF']);
95 92
             }
@@ -147,8 +144,9 @@  discard block
 block discarded – undo
147 144
 
148 145
             foreach($aQueries as $sKey => $sQuery)
149 146
             {
150
-                if("jxnGenerate" == substr($sQuery, 0, 11))
151
-                    unset($aQueries[$sKey]);
147
+                if("jxnGenerate" == substr($sQuery, 0, 11)) {
148
+                                    unset($aQueries[$sKey]);
149
+                }
152 150
             }
153 151
 
154 152
             $sQueries = implode("&", $aQueries);
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      */
25 25
     private static function getHostFromServer(array &$aURL, $sKey)
26 26
     {
27
-        if(empty($aURL['host']) && !empty($_SERVER[$sKey]))
27
+        if (empty($aURL['host']) && !empty($_SERVER[$sKey]))
28 28
         {
29
-            if(strpos($_SERVER[$sKey], ':') > 0)
29
+            if (strpos($_SERVER[$sKey], ':') > 0)
30 30
             {
31 31
                 list($aURL['host'], $aURL['port']) = explode(':', $_SERVER[$sKey]);
32 32
             }
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $aURL = [];
48 48
         // Try to get the request URL
49
-        if(!empty($_SERVER['REQUEST_URI']))
49
+        if (!empty($_SERVER['REQUEST_URI']))
50 50
         {
51
-            $_SERVER['REQUEST_URI'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $_SERVER['REQUEST_URI']);
51
+            $_SERVER['REQUEST_URI'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $_SERVER['REQUEST_URI']);
52 52
             $aURL = parse_url($_SERVER['REQUEST_URI']);
53
-            if(!is_array($aURL))
53
+            if (!is_array($aURL))
54 54
             {
55 55
                 $aURL = [];
56 56
             }
57 57
         }
58 58
 
59 59
         // Fill in the empty values
60
-        if(empty($aURL['scheme']))
60
+        if (empty($aURL['scheme']))
61 61
         {
62
-            if(!empty($_SERVER['HTTP_SCHEME']))
62
+            if (!empty($_SERVER['HTTP_SCHEME']))
63 63
             {
64 64
                 $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
65 65
             }
@@ -72,24 +72,24 @@  discard block
 block discarded – undo
72 72
         self::getHostFromServer($aURL, 'HTTP_X_FORWARDED_HOST');
73 73
         self::getHostFromServer($aURL, 'HTTP_HOST');
74 74
         self::getHostFromServer($aURL, 'SERVER_NAME');
75
-        if(empty($aURL['host']))
75
+        if (empty($aURL['host']))
76 76
         {
77 77
             throw new \Jaxon\Exception\URI();
78 78
         }
79 79
 
80
-        if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT']))
80
+        if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT']))
81 81
         {
82 82
             $aURL['port'] = $_SERVER['SERVER_PORT'];
83 83
         }
84 84
 
85
-        if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0)
85
+        if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0)
86 86
         {
87 87
             unset($aURL['path']);
88 88
         }
89 89
 
90
-        if(empty($aURL['path']))
90
+        if (empty($aURL['path']))
91 91
         {
92
-            if(!empty($_SERVER['PATH_INFO']))
92
+            if (!empty($_SERVER['PATH_INFO']))
93 93
             {
94 94
                 $sPath = parse_url($_SERVER['PATH_INFO']);
95 95
             }
@@ -97,61 +97,61 @@  discard block
 block discarded – undo
97 97
             {
98 98
                 $sPath = parse_url($_SERVER['PHP_SELF']);
99 99
             }
100
-            if(isset($sPath['path']))
100
+            if (isset($sPath['path']))
101 101
             {
102
-                $aURL['path'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $sPath['path']);
102
+                $aURL['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']);
103 103
             }
104 104
             unset($sPath);
105 105
         }
106 106
 
107
-        if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING']))
107
+        if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING']))
108 108
         {
109 109
             $aURL['query'] = $_SERVER['QUERY_STRING'];
110 110
         }
111 111
 
112
-        if(!empty($aURL['query']))
112
+        if (!empty($aURL['query']))
113 113
         {
114
-            $aURL['query'] = '?'.$aURL['query'];
114
+            $aURL['query'] = '?' . $aURL['query'];
115 115
         }
116 116
 
117 117
         // Build the URL: Start with scheme, user and pass
118
-        $sURL = $aURL['scheme'].'://';
119
-        if(!empty($aURL['user']))
118
+        $sURL = $aURL['scheme'] . '://';
119
+        if (!empty($aURL['user']))
120 120
         {
121
-            $sURL.= $aURL['user'];
122
-            if(!empty($aURL['pass']))
121
+            $sURL .= $aURL['user'];
122
+            if (!empty($aURL['pass']))
123 123
             {
124
-                $sURL.= ':'.$aURL['pass'];
124
+                $sURL .= ':' . $aURL['pass'];
125 125
             }
126
-            $sURL.= '@';
126
+            $sURL .= '@';
127 127
         }
128 128
 
129 129
         // Add the host
130
-        $sURL.= $aURL['host'];
130
+        $sURL .= $aURL['host'];
131 131
 
132 132
         // Add the port if needed
133
-        if(!empty($aURL['port'])
133
+        if (!empty($aURL['port'])
134 134
                 && (($aURL['scheme'] == 'http' && $aURL['port'] != 80)
135 135
                         || ($aURL['scheme'] == 'https' && $aURL['port'] != 443)))
136 136
         {
137
-            $sURL.= ':'.$aURL['port'];
137
+            $sURL .= ':' . $aURL['port'];
138 138
         }
139 139
 
140 140
         // Add the path and the query string
141
-        $sURL.= $aURL['path'].@$aURL['query'];
141
+        $sURL .= $aURL['path'] . @$aURL['query'];
142 142
 
143 143
         // Clean up
144 144
         unset($aURL);
145 145
 
146 146
         $aURL = explode("?", $sURL);
147 147
 
148
-        if(1 < count($aURL))
148
+        if (1 < count($aURL))
149 149
         {
150 150
             $aQueries = explode("&", $aURL[1]);
151 151
 
152
-            foreach($aQueries as $sKey => $sQuery)
152
+            foreach ($aQueries as $sKey => $sQuery)
153 153
             {
154
-                if("jxnGenerate" == substr($sQuery, 0, 11))
154
+                if ("jxnGenerate" == substr($sQuery, 0, 11))
155 155
                     unset($aQueries[$sKey]);
156 156
             }
157 157
 
Please login to merge, or discard this patch.
src/Utils/Validation/Validator.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     {
130 130
         $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty);
131 131
         $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault);
132
-        if(is_array($aAllowed) && !in_array($sValue, $aAllowed))
132
+        if (is_array($aAllowed) && !in_array($sValue, $aAllowed))
133 133
         {
134 134
             $this->sErrorMessage = $this->xTranslator->trans('errors.upload.' . $sField, [$sField = $sValue]);
135 135
             return false;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $xDefault = $this->xConfig->getOption('upload.default.' . $sProperty, 0);
152 152
         $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.' . $sProperty, $xDefault);
153
-        if($iSize > 0 && (
153
+        if ($iSize > 0 && (
154 154
             ($sProperty == 'max-size' && $iFileSize > $iSize) ||
155 155
             ($sProperty == 'min-size' && $iFileSize < $iSize)))
156 156
         {
@@ -172,25 +172,25 @@  discard block
 block discarded – undo
172 172
     {
173 173
         $this->sErrorMessage = '';
174 174
         // Verify the file extension
175
-        if(!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type'))
175
+        if (!$this->validateFileProperty($sName, $aUploadedFile['type'], 'types', 'type'))
176 176
         {
177 177
             return false;
178 178
         }
179 179
 
180 180
         // Verify the file extension
181
-        if(!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension'))
181
+        if (!$this->validateFileProperty($sName, $aUploadedFile['extension'], 'extensions', 'extension'))
182 182
         {
183 183
             return false;
184 184
         }
185 185
 
186 186
         // Verify the max size
187
-        if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size'))
187
+        if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'max-size'))
188 188
         {
189 189
             return false;
190 190
         }
191 191
 
192 192
         // Verify the min size
193
-        if(!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size'))
193
+        if (!$this->validateFileSize($sName, $aUploadedFile['size'], 'min-size'))
194 194
         {
195 195
             return false;
196 196
         }
Please login to merge, or discard this patch.