Passed
Push — master ( ce2bc1...e68e02 )
by Fran
05:34
created
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         if (count($pks) === 1) {
101 101
             $pks = array_keys($pks);
102 102
             return [
103
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
103
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
104 104
             ];
105 105
         }
106 106
         if (count($pks) > 1) {
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
             $principal = '';
109 109
             $sep = 'CONCAT(';
110 110
             foreach ($pks as $pk) {
111
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
112
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
113
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
111
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
112
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
113
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
114 114
             }
115 115
             $principal .= ')';
116 116
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
         $pks = '';
138 138
         $sep = '';
139 139
         foreach ($tableMap->getPrimaryKeys() as $pk) {
140
-            $pks .= $sep . $pk->getFullyQualifiedName();
140
+            $pks .= $sep.$pk->getFullyQualifiedName();
141 141
             $sep = ', "|", ';
142 142
         }
143
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
143
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
144 144
     }
145 145
 
146 146
     /**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             }
163 163
             if (null !== $column) {
164 164
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
165
-            } else {
165
+            }else {
166 166
                 $this->addClassListName($tableMap);
167 167
             }
168 168
         }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      * @param $action
174 174
      * @throws ApiException
175 175
      */
176
-    private function addExtraColumns(ModelCriteria &$query, $action)
176
+    private function addExtraColumns(ModelCriteria & $query, $action)
177 177
     {
178 178
         if (Api::API_ACTION_LIST === $action) {
179 179
             $this->addDefaultListField();
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         if (!empty($this->extraColumns)) {
183 183
             if (Config::getParam('api.extrafields.compat', true)) {
184 184
                 $fields = array_values($this->extraColumns);
185
-            } else {
185
+            }else {
186 186
                 $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
187 187
                 $fields = explode(',', $returnFields ?: '');
188 188
                 $fields[] = self::API_MODEL_KEY_FIELD;
@@ -216,32 +216,32 @@  discard block
 block discarded – undo
216 216
     /**
217 217
      * @param ModelCriteria $query
218 218
      */
219
-    protected function checkI18n(ModelCriteria &$query)
219
+    protected function checkI18n(ModelCriteria & $query)
220 220
     {
221 221
         $this->extractApiLang();
222 222
         $model = $this->getModelNamespace();
223
-        $modelI18n = $model . 'I18n';
223
+        $modelI18n = $model.'I18n';
224 224
         if (method_exists($query, 'useI18nQuery')) {
225 225
             $query->useI18nQuery($this->lang);
226 226
             $modelParts = explode('\\', $modelI18n);
227
-            $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap';
227
+            $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap';
228 228
             /** @var TableMap $modelI18nTableMap */
229 229
             $modelI18nTableMap = $i18nMapClass::getTableMap();
230 230
             foreach ($modelI18nTableMap->getColumns() as $columnMap) {
231 231
                 if (!$columnMap->isPrimaryKey()) {
232 232
                     $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap));
233 233
                 } elseif (!$columnMap->isForeignKey()) {
234
-                    $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "' . $this->lang . '")', ApiHelper::getColumnMapName($columnMap));
234
+                    $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap));
235 235
                 }
236 236
             }
237 237
         }
238 238
     }
239 239
 
240 240
     protected function cleanData(array &$data) {
241
-        foreach($data as $key => &$value) {
242
-            if(is_array($value)) {
241
+        foreach ($data as $key => &$value) {
242
+            if (is_array($value)) {
243 243
                 $this->cleanData($value);
244
-            } else if(is_string($value)) {
244
+            }else if (is_string($value)) {
245 245
                 $value = I18nHelper::cleanHtmlAttacks($value);
246 246
             }
247 247
         }
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
         $model->fromArray($data, ApiHelper::getFieldTypes());
258 258
         $tableMap = $this->getTableMap();
259 259
         try {
260
-            if ($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) {
261
-                $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
260
+            if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) {
261
+                $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
262 262
                 $i18NTableMap = $relateI18n->getLocalTable();
263 263
                 $model->setLocale(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES')));
264 264
                 foreach ($i18NTableMap->getColumns() as $columnMap) {
265
-                    $method = 'set' . $columnMap->getPhpName();
265
+                    $method = 'set'.$columnMap->getPhpName();
266 266
                     $dtoColumnName = ApiHelper::getColumnMapName($columnMap);
267 267
                     if (array_key_exists($dtoColumnName, $data)
268 268
                         && method_exists($model, $method)
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                     }
272 272
                 }
273 273
             }
274
-        } catch (Exception $e) {
274
+        }catch (Exception $e) {
275 275
             Logger::log($e->getMessage(), LOG_DEBUG);
276 276
         }
277 277
     }
Please login to merge, or discard this patch.
src/base/Security.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getAdmins()
62 62
     {
63
-        return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true);
63
+        return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true);
64 64
     }
65 65
 
66 66
     /**
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
             $admins = $this->getAdmins();
78 78
             $token = null;
79 79
             if (null !== $admins) {
80
-                if(empty($user)) {
80
+                if (empty($user)) {
81 81
                     // First try, traditional basic auth
82 82
                     Inspector::stats('[Auth] Checking Basic Auth');
83 83
                     list($user, $token) = AuthHelper::checkBasicAuth($user, $pass, $admins);
84 84
                 }
85
-                if(empty($user)) {
85
+                if (empty($user)) {
86 86
                     // Second try, cookie auth
87 87
                     Inspector::stats('[Auth] Checking Basic Auth PSFS');
88 88
                     list($user, $token) = AuthHelper::checkComplexAuth($admins);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                         ]);
104 104
                         $this->setSessionKey(AuthHelper::ADMIN_ID_TOKEN, $encrypted);
105 105
                     }
106
-                } else {
106
+                }else {
107 107
                     $this->admin = null;
108 108
                     $this->setSessionKey(AuthHelper::ADMIN_ID_TOKEN, null);
109 109
                 }
Please login to merge, or discard this patch.
src/base/dto/Dto.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
                             }
59 59
                         }
60 60
                         $dto[$property->getName()] = $value;
61
-                    } else {
61
+                    }else {
62 62
                         $type = InjectorHelper::extractVarType($property->getDocComment());
63 63
                         $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type ?: 'string');
64 64
                     }
65 65
                 }
66 66
             }
67
-        } catch (\Exception $e) {
68
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
67
+        }catch (\Exception $e) {
68
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
69 69
         }
70 70
         return $dto;
71 71
     }
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
                             $this->$key[] = $dto;
103 103
                         }
104 104
                     }
105
-                } else {
105
+                }else {
106 106
                     $this->$key = clone $this->__cache[$type];
107 107
                     $this->$key->fromArray($value);
108 108
                 }
109 109
             }
110
-        } else {
110
+        }else {
111 111
             $this->castValue($key, $value, $type);
112 112
         }
113 113
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     /**
135 135
      * @return mixed
136 136
      */
137
-    public function jsonSerialize(): array|string|null
137
+    public function jsonSerialize(): array | string | null
138 138
     {
139 139
         return $this->toArray();
140 140
     }
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
                 default:
181 181
                 case 'string':
182 182
                     // Cleaning HTML dangerous tags
183
-                    if(is_array($rawValue)) {
184
-                        foreach($rawValue as &$item) {
183
+                    if (is_array($rawValue)) {
184
+                        foreach ($rawValue as &$item) {
185 185
                             $item = $this->checkCastedValue($item, $type);
186 186
                         }
187 187
                         $value = $rawValue;
188
-                    } elseif(is_string($rawValue)) {
188
+                    } elseif (is_string($rawValue)) {
189 189
                         $value = I18nHelper::cleanHtmlAttacks($rawValue);
190
-                    } else {
190
+                    }else {
191 191
                         $value = $rawValue;
192 192
                     }
193 193
                     break;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                     $value = (bool)$rawValue;
205 205
                     break;
206 206
             }
207
-        } else {
207
+        }else {
208 208
             $value = $rawValue;
209 209
         }
210 210
         return $value;
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
             $objects = scandir($dir);
27 27
             foreach ($objects as $object) {
28 28
                 if ($object != "." && $object != "..") {
29
-                    if (filetype($dir . "/" . $object) == "dir") {
30
-                        self::deleteDir($dir . "/" . $object);
31
-                    } else {
32
-                        unlink($dir . "/" . $object);
29
+                    if (filetype($dir."/".$object) == "dir") {
30
+                        self::deleteDir($dir."/".$object);
31
+                    }else {
32
+                        unlink($dir."/".$object);
33 33
                     }
34 34
                 }
35 35
             }
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $rootDirs = array("css", "js", "media", "font");
46 46
         foreach ($rootDirs as $dir) {
47
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
47
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
48 48
                 try {
49
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
50
-                } catch (\Exception $e) {
49
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
50
+                }catch (\Exception $e) {
51 51
                     syslog(LOG_INFO, $e->getMessage());
52 52
                 }
53 53
             }
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
         if (!empty($dir)) {
65 65
             try {
66 66
                 if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
67
-                    throw new Exception(t('Can\'t create directory ') . $dir);
67
+                    throw new Exception(t('Can\'t create directory ').$dir);
68 68
                 }
69
-            } catch (\Exception $e) {
69
+            }catch (\Exception $e) {
70 70
                 syslog(LOG_WARNING, $e->getMessage());
71 71
                 if (!file_exists(dirname($dir))) {
72
-                    throw new GeneratorException($e->getMessage() . $dir);
72
+                    throw new GeneratorException($e->getMessage().$dir);
73 73
                 }
74 74
             }
75 75
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public static function getTemplatePath(): string
83 83
     {
84
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
84
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
85 85
         return realpath($path);
86 86
     }
87 87
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 } elseif (!$reflector->isAbstract()) {
110 110
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
111 111
                 }
112
-            } else {
112
+            }else {
113 113
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
114 114
             }
115 115
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         GeneratorHelper::createDir($path);
132 132
         $paths = array("js", "css", "img", "media", "font");
133 133
         foreach ($paths as $htmlPath) {
134
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
134
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
135 135
         }
136 136
 
137 137
         // Generates the root needed files
@@ -141,35 +141,35 @@  discard block
 block discarded – undo
141 141
             'crossdomain' => 'crossdomain.xml',
142 142
             'humans' => 'humans.txt',
143 143
             'robots' => 'robots.txt',
144
-            'docker' => '..' . DIRECTORY_SEPARATOR . 'docker-compose.yml',
144
+            'docker' => '..'.DIRECTORY_SEPARATOR.'docker-compose.yml',
145 145
         ];
146 146
         $verificable = ['humans', 'robots', 'docker'];
147 147
         if (!$quiet) {
148 148
             $output->writeln('Start creating html files');
149 149
         }
150 150
         foreach ($files as $template => $filename) {
151
-            if (in_array($template, $verificable) && file_exists($path . DIRECTORY_SEPARATOR . $filename)) {
151
+            if (in_array($template, $verificable) && file_exists($path.DIRECTORY_SEPARATOR.$filename)) {
152 152
                 if (!$quiet) {
153
-                    $output->writeln($filename . ' already exists');
153
+                    $output->writeln($filename.' already exists');
154 154
                 }
155 155
                 continue;
156 156
             }
157
-            $text = Template::getInstance()->dump("generator/html/" . $template . '.html.twig');
158
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
157
+            $text = Template::getInstance()->dump("generator/html/".$template.'.html.twig');
158
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
159 159
                 if (!$quiet) {
160
-                    $output->writeln('Can\t create the file ' . $filename);
160
+                    $output->writeln('Can\t create the file '.$filename);
161 161
                 }
162
-            } else {
162
+            }else {
163 163
                 if (!$quiet) {
164
-                    $output->writeln($filename . ' created successfully');
164
+                    $output->writeln($filename.' created successfully');
165 165
                 }
166 166
             }
167 167
         }
168 168
 
169 169
         //Export base locale translations
170
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
171
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
172
-            self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
170
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
171
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
172
+            self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
173 173
         }
174 174
     }
175 175
 
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
     {
186 186
         if (file_exists($filenamePath)) {
187 187
             $destfolder = basename($filenamePath);
188
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
188
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
189 189
                 if (is_dir($filenamePath)) {
190
-                    self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
191
-                } else {
192
-                    if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
193
-                        throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
190
+                    self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
191
+                }else {
192
+                    if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
193
+                        throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
194 194
                     }
195 195
                 }
196 196
             }
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
         self::createDir($dst);
210 210
         while (false !== ($file = readdir($dir))) {
211 211
             if (($file != '.') && ($file != '..')) {
212
-                if (is_dir($src . '/' . $file)) {
213
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
214
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
215
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
212
+                if (is_dir($src.'/'.$file)) {
213
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
214
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
215
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
216 216
                 }
217 217
             }
218 218
         }
Please login to merge, or discard this patch.
src/functions.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@
 block discarded – undo
27 27
     {
28 28
         $html = '<style>*{margin: 0} body{background: rgb(36,36,36); padding: 5px;}</style>';
29 29
         $html .= '<pre style="padding: 10px; margin: 5px; display: block; background: rgb(41,41,41); color: white; border-radius: 5px;">';
30
-        if(is_null($var)) {
31
-            if($varName) $html .= $varName . ' ==> <b>NULL</b>';
32
-        } else {
33
-            $html .= print_r('(' . gettype($var) . ') ', TRUE);
34
-            if($varName) $html .= $varName . ' ==> ';
35
-            if("boolean" === gettype($var)) {
30
+        if (is_null($var)) {
31
+            if ($varName) $html .= $varName.' ==> <b>NULL</b>';
32
+        }else {
33
+            $html .= print_r('('.gettype($var).') ', TRUE);
34
+            if ($varName) $html .= $varName.' ==> ';
35
+            if ("boolean" === gettype($var)) {
36 36
                 $html .= print_r($var ? "TRUE" : "FALSE", TRUE);
37
-            } else if((is_array($var) && !empty($var)) || (!is_array($var)) ||  ($var === 0)) {
37
+            }else if ((is_array($var) && !empty($var)) || (!is_array($var)) || ($var === 0)) {
38 38
                 $html .= print_r($var, TRUE);
39
-            } else {
39
+            }else {
40 40
                 $html .= 'empty';
41 41
             }
42 42
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,10 +28,14 @@
 block discarded – undo
28 28
         $html = '<style>*{margin: 0} body{background: rgb(36,36,36); padding: 5px;}</style>';
29 29
         $html .= '<pre style="padding: 10px; margin: 5px; display: block; background: rgb(41,41,41); color: white; border-radius: 5px;">';
30 30
         if(is_null($var)) {
31
-            if($varName) $html .= $varName . ' ==> <b>NULL</b>';
31
+            if($varName) {
32
+                $html .= $varName . ' ==> <b>NULL</b>';
33
+            }
32 34
         } else {
33 35
             $html .= print_r('(' . gettype($var) . ') ', TRUE);
34
-            if($varName) $html .= $varName . ' ==> ';
36
+            if($varName) {
37
+                $html .= $varName . ' ==> ';
38
+            }
35 39
             if("boolean" === gettype($var)) {
36 40
                 $html .= print_r($var ? "TRUE" : "FALSE", TRUE);
37 41
             } else if((is_array($var) && !empty($var)) || (!is_array($var)) ||  ($var === 0)) {
Please login to merge, or discard this patch.
src/base/types/helpers/I18nHelper.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
         // TODO check more en locales
47 47
         if (strtolower($locale) === 'en') {
48 48
             $locale = 'en_GB';
49
-        } else {
50
-            $locale = $locale . '_' . strtoupper($locale);
49
+        }else {
50
+            $locale = $locale.'_'.strtoupper($locale);
51 51
         }
52 52
         $defaultLocales = explode(',', Config::getParam('i18n.locales', ''));
53 53
         if (!in_array($locale, array_merge($defaultLocales, self::$langs))) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $translations = array();
67 67
         if (file_exists($absoluteFileName)) {
68 68
             @include($absoluteFileName);
69
-        } else {
69
+        }else {
70 70
             Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
71 71
         }
72 72
 
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
     public static function setLocale(string $default = null, string $customKey = null, bool $force = false): void
84 84
     {
85 85
         $locale = $force ? $default : self::extractLocale($default);
86
-        Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG);
86
+        Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG);
87 87
         // Load translations
88
-        putenv("LC_ALL=" . $locale);
88
+        putenv("LC_ALL=".$locale);
89 89
         setlocale(LC_ALL, $locale);
90 90
         // Load the locale path
91
-        $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
92
-        Logger::log('Set locale dir ' . $localePath);
91
+        $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
92
+        Logger::log('Set locale dir '.$localePath);
93 93
         GeneratorHelper::createDir($localePath);
94 94
         bindtextdomain('translations', $localePath);
95 95
         textdomain('translations');
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             }
113 113
         } elseif (is_object($data)) {
114 114
             $properties = get_class_vars($data);
115
-            if(is_array($properties)) {
115
+            if (is_array($properties)) {
116 116
                 foreach (array_keys($properties) as $property) {
117 117
                     $data->$property = self::utf8Encode($data->$property);
118 118
                 }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'],
160 160
             ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'],
161 161
             ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'],
162
-            ['n', 'N', 'c', 'C',],
162
+            ['n', 'N', 'c', 'C', ],
163 163
         ];
164 164
 
165 165
         $text = htmlspecialchars($string);
@@ -179,24 +179,24 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public static function findTranslations(string $path, string $locale): array
181 181
     {
182
-        $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
183
-        $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
182
+        $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
183
+        $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
184 184
 
185 185
         $translations = array();
186 186
         if (file_exists($path)) {
187 187
             $directory = dir($path);
188 188
             while (false !== ($fileName = $directory->read())) {
189 189
                 GeneratorHelper::createDir($localePath);
190
-                if (!file_exists($localePath . 'translations.po')) {
191
-                    file_put_contents($localePath . 'translations.po', '');
190
+                if (!file_exists($localePath.'translations.po')) {
191
+                    file_put_contents($localePath.'translations.po', '');
192 192
                 }
193
-                $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName);
194
-                $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " .
195
-                    $inspectPath . DIRECTORY_SEPARATOR .
193
+                $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName);
194
+                $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ".
195
+                    $inspectPath.DIRECTORY_SEPARATOR.
196 196
                     "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po";
197
-                if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) {
198
-                    $res = t('Revisando directorio: ') . $inspectPath;
199
-                    $res .= t('Comando ejecutado: ') . $cmdPhp;
197
+                if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) {
198
+                    $res = t('Revisando directorio: ').$inspectPath;
199
+                    $res .= t('Comando ejecutado: ').$cmdPhp;
200 200
                     $res .= shell_exec($cmdPhp);
201 201
                     usleep(10);
202 202
                     $translations[] = $res;
Please login to merge, or discard this patch.
src/base/types/helpers/AuthHelper.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         if (NULL === $user || (array_key_exists($user, $admins) && empty($admins[$user]))) {
48 48
             list($user, $pass) = self::getAdminFromCookie();
49 49
         }
50
-        return array_key_exists($user, $admins) ? [$user, sha1($user . $pass)] : [null, null];
50
+        return array_key_exists($user, $admins) ? [$user, sha1($user.$pass)] : [null, null];
51 51
     }
52 52
 
53 53
     public static function checkComplexAuth(array $admins)
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             foreach ($admins as $admin => $profile) {
63 63
                 list($decrypted_user, $timestamp, $userAgent) = self::decodeToken($token, $profile['hash']);
64 64
                 if (!empty($decrypted_user) && !empty($timestamp)) {
65
-                    if(!empty($userAgent) && $userAgent === $reqUserAgent) {
65
+                    if (!empty($userAgent) && $userAgent === $reqUserAgent) {
66 66
                         $expiration = \DateTime::createFromFormat(self::EXPIRATION_TIMESTAMP_FORMAT, $timestamp);
67 67
                         if (false !== $expiration && $decrypted_user === $admin && $expiration > $now) {
68 68
                             $user = $admin;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         return base64_encode($encrypted_data);
90 90
     }
91 91
 
92
-    public static function decrypt(string $encrypted_data, string $key): false|string
92
+    public static function decrypt(string $encrypted_data, string $key): false | string
93 93
     {
94 94
         $encrypted_data = base64_decode($encrypted_data);
95 95
         $data = '';
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
         if (null === $userAgent && array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
111 111
             $userAgent = $_SERVER['HTTP_USER_AGENT'];
112 112
         }
113
-        $data = $user . Security::LOGGED_USER_TOKEN . $timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT) . Security::LOGGED_USER_TOKEN . ($userAgent ?? 'psfs');
114
-        return self::encrypt($data, sha1($user . $password));
113
+        $data = $user.Security::LOGGED_USER_TOKEN.$timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT).Security::LOGGED_USER_TOKEN.($userAgent ?? 'psfs');
114
+        return self::encrypt($data, sha1($user.$password));
115 115
     }
116 116
 
117 117
     public static function decodeToken(string $token, string $password): array
118 118
     {
119 119
         $user = $timestamp = $userAgent = null;
120 120
         $secret = self::decrypt($token, $password);
121
-        if(!empty($secret) && str_contains($secret, Security::LOGGED_USER_TOKEN)) {
121
+        if (!empty($secret) && str_contains($secret, Security::LOGGED_USER_TOKEN)) {
122 122
             list($user, $timestamp, $userAgent) = explode(Security::LOGGED_USER_TOKEN, $secret);
123 123
         }
124 124
         return [$user, $timestamp, $userAgent];
Please login to merge, or discard this patch.
src/base/types/traits/OutputTrait.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 $this->setStatusCode(Template::STATUS_OK);
128 128
                 break;
129 129
             default:
130
-                $this->setStatusCode('HTTP/1.0 ' . ($status ?: 200));
130
+                $this->setStatusCode('HTTP/1.0 '.($status ?: 200));
131 131
                 break;
132 132
         }
133 133
         return $this;
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
      */
141 141
     private function setResponseHeaders($contentType = 'text/html', array $cookies = array()): void
142 142
     {
143
-        ResponseHelper::setHeader('X-Powered-By: ' . Config::getParam('poweredBy', 'PSFS'));
143
+        ResponseHelper::setHeader('X-Powered-By: '.Config::getParam('poweredBy', 'PSFS'));
144 144
         ResponseHelper::setStatusHeader($this->getStatusCode());
145 145
         ResponseHelper::setAuthHeaders($this->isPublicZone());
146 146
         ResponseHelper::setCookieHeaders($cookies);
147
-        ResponseHelper::setHeader('Content-type: ' . $contentType);
147
+        ResponseHelper::setHeader('Content-type: '.$contentType);
148 148
 
149 149
     }
150 150
 
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
             Logger::log('Start output response');
163 163
             ob_start();
164 164
             $this->setResponseHeaders($contentType, $cookies);
165
-            ResponseHelper::setHeader('Content-length: ' . strlen($output));
166
-            ResponseHelper::setHeader('CRC: ' . crc32($output));
165
+            ResponseHelper::setHeader('Content-length: '.strlen($output));
166
+            ResponseHelper::setHeader('CRC: '.crc32($output));
167 167
 
168 168
             $needCache = Cache::needCache();
169 169
             $cache = Cache::getInstance();
170 170
             list($path, $cacheDataName) = $cache->getRequestCacheHash();
171 171
             if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) {
172 172
                 Logger::log('Saving output response into cache');
173
-                $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output);
174
-                $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON);
173
+                $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $output);
174
+                $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', headers_list(), Cache::JSON);
175 175
             } elseif (Request::getInstance()->getMethod() !== 'GET') {
176 176
                 $cache->flushCache();
177 177
             }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             ob_end_clean();
182 182
             Logger::log('End output response');
183 183
             $this->closeRender();
184
-        } else {
184
+        }else {
185 185
             return $output;
186 186
         }
187 187
     }
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
         Logger::log('Close template render');
195 195
         $uri = Request::requestUri();
196 196
         Security::getInstance()->setSessionKey('lastRequest', array(
197
-            'url' => Request::getInstance()->getRootUrl() . $uri,
197
+            'url' => Request::getInstance()->getRootUrl().$uri,
198 198
             'ts' => microtime(true),
199 199
         ));
200 200
         Security::getInstance()->updateSession();
201 201
         EventHelper::handleEvents(EventHelper::EVENT_END_REQUEST);
202
-        Logger::log('End request: ' . Request::requestUri(), LOG_INFO);
202
+        Logger::log('End request: '.Request::requestUri(), LOG_INFO);
203 203
         exit;
204 204
     }
205 205
 
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
         /////////////////////////////////////////////////////////////
238 238
         // Date in the past sets the value to already have been expired.
239 239
         ResponseHelper::setHeader('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
240
-        ResponseHelper::setHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
240
+        ResponseHelper::setHeader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
241 241
         ResponseHelper::setHeader('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
242 242
         ResponseHelper::setHeader('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
243 243
         ResponseHelper::setHeader('Pragma: no-cache');
244 244
         ResponseHelper::setHeader('Expires: 0');
245 245
         ResponseHelper::setHeader('Content-Transfer-Encoding: binary');
246
-        ResponseHelper::setHeader('Content-type: ' . $content);
247
-        ResponseHelper::setHeader('Content-length: ' . strlen($data));
248
-        ResponseHelper::setHeader('Content-Disposition: attachment; filename="' . $filename . '"');
246
+        ResponseHelper::setHeader('Content-type: '.$content);
247
+        ResponseHelper::setHeader('Content-length: '.strlen($data));
248
+        ResponseHelper::setHeader('Content-Disposition: attachment; filename="'.$filename.'"');
249 249
         ResponseHelper::setHeader('Access-Control-Expose-Headers: Filename');
250
-        ResponseHelper::setHeader('Filename: ' . $filename);
250
+        ResponseHelper::setHeader('Filename: '.$filename);
251 251
         echo $data;
252 252
         ob_flush();
253 253
         ob_end_clean();
Please login to merge, or discard this patch.
src/base/types/traits/Security/ProfileTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
     public static function save($user)
90 90
     {
91 91
         $saved = true;
92
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
93
-        $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']);
92
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
93
+        $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']);
94 94
         $admins[$user['username']]['profile'] = $user['profile'];
95 95
 
96
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
96
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
97 97
         return $saved;
98 98
     }
99 99
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function deleteUser($user)
115 115
     {
116
-        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: [];
116
+        $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: [];
117 117
         unset($admins[$user]);
118
-        Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true);
118
+        Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true);
119 119
     }
120 120
 
121 121
     /**
Please login to merge, or discard this patch.