Passed
Push — master ( e3e57c...ca9272 )
by Fran
14:15
created
src/base/Request.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
         $header = null;
138 138
         if ($this->hasHeader($name)) {
139 139
             $header = $this->header[$name];
140
-        } else if (array_key_exists('h_' . strtolower($name), $this->query)) {
141
-            $header = $this->query['h_' . strtolower($name)];
142
-        } else if (array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) {
143
-            $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name)));
140
+        }else if (array_key_exists('h_'.strtolower($name), $this->query)) {
141
+            $header = $this->query['h_'.strtolower($name)];
142
+        }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) {
143
+            $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name)));
144 144
         }
145 145
         return $header ?: $default;
146 146
     }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
             $url = $this->getServer('HTTP_ORIGIN');
255 255
         }
256 256
         ob_start();
257
-        header('Location: ' . $url);
257
+        header('Location: '.$url);
258 258
         ob_end_clean();
259 259
         Security::getInstance()->updateSession();
260 260
         exit(t('Redirect...'));
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         $url = $this->getServerName();
271 271
         $protocol = $hasProtocol ? $this->getProtocol() : '//';
272 272
         if (!empty($protocol)) {
273
-            $url = $protocol . $url;
273
+            $url = $protocol.$url;
274 274
         }
275 275
         return $this->checkServerPort($url);
276 276
     }
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
             }
292 292
         }
293 293
         if (!in_array($port, [80, 443], true)) {
294
-            $url .= ':' . $port;
294
+            $url .= ':'.$port;
295 295
         }
296 296
         return $url;
297 297
     }
Please login to merge, or discard this patch.
src/base/extension/TemplateFunctions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
         $filePath = $returnPath = '';
48 48
         if (!file_exists($filePath)) {
49
-            $filePath = BASE_DIR . $string;
49
+            $filePath = BASE_DIR.$string;
50 50
         }
51 51
         $filenamePath = AssetsHelper::findDomainPath($string, $filePath);
52
-        if(!empty($filenamePath)){
52
+        if (!empty($filenamePath)) {
53 53
             $filePath = self::processAsset($string, $name, $return, $filenamePath);
54 54
             $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl(false));
55
-            $returnPath = empty($name) ? $basePath . '/' . $filePath : $name;
55
+            $returnPath = empty($name) ? $basePath.'/'.$filePath : $name;
56 56
         }
57 57
         return $return ? $returnPath : '';
58 58
     }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         $router = Router::getInstance();
71 71
         try {
72 72
             return $router->getRoute($path, $absolute, $params);
73
-        } catch (\Exception $e) {
73
+        }catch (\Exception $e) {
74 74
             Logger::log($e->getMessage());
75 75
             return $router->getRoute('', $absolute, $params);
76 76
         }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         $filenamePath = self::extractPathname($path, $domains);
167 167
         // Check if resources has been copied to public folders
168 168
         if (!$debug) {
169
-            $cacheFilename = Config::getParam('cache.var', '__initial__') . '.file.cache';
169
+            $cacheFilename = Config::getParam('cache.var', '__initial__').'.file.cache';
170 170
             $cachedFiles = Cache::getInstance()->readFromCache($cacheFilename,
171 171
                 1, fn() => [], Cache::JSON, true) ?: [];
172 172
             // Force the resource copy
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      *
188 188
      * @return string|array
189 189
      */
190
-    private static function extractPathname(string $path, $domains): string|array
190
+    private static function extractPathname(string $path, $domains): string | array
191 191
     {
192 192
         $filenamePath = $path;
193 193
         if (!empty($domains) && !file_exists($path)) {
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
      * @param string $base
227 227
      * @param string $filePath
228 228
      */
229
-    private static function putResourceContent(string|null $name, string $filenamePath, string $base, string $filePath): void
229
+    private static function putResourceContent(string | null $name, string $filenamePath, string $base, string $filePath): void
230 230
     {
231 231
         $data = file_get_contents($filenamePath);
232 232
         if (!empty($name)) {
233
-            file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data);
234
-        } else {
235
-            file_put_contents($base . $filePath, $data);
233
+            file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);
234
+        }else {
235
+            file_put_contents($base.$filePath, $data);
236 236
         }
237 237
     }
238 238
 
@@ -245,15 +245,15 @@  discard block
 block discarded – undo
245 245
      * @return string
246 246
      * @throws GeneratorException
247 247
      */
248
-    private static function processAsset(string $string, string|null $name = null, bool $return = true, string $filenamePath = ''): string
248
+    private static function processAsset(string $string, string | null $name = null, bool $return = true, string $filenamePath = ''): string
249 249
     {
250 250
         $filePath = $filenamePath;
251 251
         if (file_exists($filenamePath)) {
252 252
             list($base, $htmlBase, $filePath) = AssetsHelper::calculateAssetPath($string, $name, $return, $filenamePath);
253 253
             //Creamos el directorio si no existe
254
-            GeneratorHelper::createDir($base . $htmlBase);
254
+            GeneratorHelper::createDir($base.$htmlBase);
255 255
             //Si se ha modificado
256
-            if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) {
256
+            if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) {
257 257
                 if ($htmlBase === 'css') {
258 258
                     self::processCssLines($filenamePath);
259 259
                 }
Please login to merge, or discard this patch.
src/base/types/helpers/ResponseHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
     public static array $headers_sent = [];
21 21
 
22 22
     public static function setHeader(string $header): void {
23
-        if(str_contains($header, ':')) {
23
+        if (str_contains($header, ':')) {
24 24
             list($key, $value) = explode(':', $header);
25
-        } else {
25
+        }else {
26 26
             $key = 'Http Status';
27 27
             $value = $header;
28 28
         }
29 29
         if (!in_array($key, self::$headers_sent)) {
30
-            if(!self::isTest()) {
30
+            if (!self::isTest()) {
31 31
                 header($header);
32 32
             }
33 33
             self::$headers_sent[$key] = $value;
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
             Logger::log('Adding debug headers to render response');
100 100
             $vars["__DEBUG__"]["includes"] = get_included_files();
101 101
             $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
102
-            self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s');
103
-            self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes');
104
-            self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened');
102
+            self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s');
103
+            self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes');
104
+            self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened');
105 105
         }
106 106
 
107 107
         return $vars;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @return int|string
114 114
      * @throws GeneratorException
115 115
      */
116
-    public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int|string
116
+    public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int | string
117 117
     {
118 118
         if (self::isTest()) {
119 119
             return 404;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $notFoundRoute = Config::getParam('route.404');
133 133
         if (null !== $notFoundRoute) {
134 134
             Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true));
135
-        } else {
135
+        }else {
136 136
             return $template->render('error.html.twig', array(
137 137
                 'exception' => $exception,
138 138
                 'trace' => $exception->getTraceAsString(),
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function init()
64 64
     {
65
-        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'urls.json', $this->cacheType, TRUE);
66
-        $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->cacheType, TRUE);
65
+        list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'urls.json', $this->cacheType, TRUE);
66
+        $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->cacheType, TRUE);
67 67
         if (empty($this->routing) || Config::getParam('debug', true)) {
68 68
             $this->debugLoad();
69 69
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $this->hydrateRouting();
85 85
             $this->simpatize();
86 86
             Logger::log('End routes load');
87
-        } else {
87
+        }else {
88 88
             Logger::log('Routes generation skipped');
89 89
         }
90 90
     }
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
         try {
102 102
             //Search action and execute
103 103
             return $this->searchAction($route);
104
-        } catch (AccessDeniedException $e) {
105
-            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile() . '[' . $e->getLine() . ']']);
104
+        }catch (AccessDeniedException $e) {
105
+            Logger::log(t('Solicitamos credenciales de acceso a zona restringida'), LOG_WARNING, ['file' => $e->getFile().'['.$e->getLine().']']);
106 106
             return Admin::staticAdminLogon();
107
-        } catch (RouterException $r) {
107
+        }catch (RouterException $r) {
108 108
             Logger::log($r->getMessage(), LOG_WARNING);
109 109
             $code = $r->getCode();
110
-        } catch (Exception $e) {
110
+        }catch (Exception $e) {
111 111
             Logger::log($e->getMessage(), LOG_ERR);
112 112
             throw $e;
113 113
         }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function searchAction($route)
127 127
     {
128
-        Inspector::stats('[Router] Searching action to execute: ' . $route, Inspector::SCOPE_DEBUG);
128
+        Inspector::stats('[Router] Searching action to execute: '.$route, Inspector::SCOPE_DEBUG);
129 129
         //Revisamos si tenemos la ruta registrada
130 130
         $parts = parse_url($route);
131 131
         $path = array_key_exists('path', $parts) ? $parts['path'] : $route;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                     }
146 146
 
147 147
                     throw new RouterException(t('Preconditions failed'), 412);
148
-                } catch (Exception $e) {
148
+                }catch (Exception $e) {
149 149
                     Logger::log($e->getMessage(), LOG_ERR);
150 150
                     throw $e;
151 151
                 }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 }
171 171
             }
172 172
             $valid = count($action['requirements']) === $checked;
173
-        } else {
173
+        }else {
174 174
             $valid = true;
175 175
         }
176 176
         return $valid;
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
             if ($modules->hasResults()) {
194 194
                 foreach ($modules->getIterator() as $modulePath) {
195 195
                     $module = $modulePath->getBasename();
196
-                    $this->routing = $this->inspectDir($modulesPath . DIRECTORY_SEPARATOR . $module, $module, $this->routing);
196
+                    $this->routing = $this->inspectDir($modulesPath.DIRECTORY_SEPARATOR.$module, $module, $this->routing);
197 197
                 }
198 198
             }
199 199
         }
200
-        $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', $this->domains, Cache::JSON, TRUE);
200
+        $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', $this->domains, Cache::JSON, TRUE);
201 201
     }
202 202
 
203 203
     /**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             $homeParams = NULL;
215 215
             foreach ($this->routing as $pattern => $params) {
216 216
                 list($method, $route) = RouterHelper::extractHttpRoute($pattern);
217
-                if (preg_match('/' . preg_quote($route, '/') . '$/i', '/' . $home)) {
217
+                if (preg_match('/'.preg_quote($route, '/').'$/i', '/'.$home)) {
218 218
                     $homeParams = $params;
219 219
                 }
220 220
                 unset($method);
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
     {
247 247
         $baseUrl = $absolute ? Request::getInstance()->getRootUrl() : '';
248 248
         if ('' === $slug) {
249
-            return $baseUrl . '/';
249
+            return $baseUrl.'/';
250 250
         }
251 251
         if (!is_array($this->slugs) || !array_key_exists($slug, $this->slugs)) {
252 252
             throw new RouterException(t('No existe la ruta especificada'));
253 253
         }
254
-        $url = $baseUrl . $this->slugs[$slug];
254
+        $url = $baseUrl.$this->slugs[$slug];
255 255
         if (!empty($params)) {
256 256
             foreach ($params as $key => $value) {
257
-                $url = str_replace('{' . $key . '}', $value, $url);
257
+                $url = str_replace('{'.$key.'}', $value, $url);
258 258
             }
259 259
         } elseif (!empty($this->routing[$this->slugs[$slug]]['default'])) {
260
-            $url = $baseUrl . $this->routing[$this->slugs[$slug]]['default'];
260
+            $url = $baseUrl.$this->routing[$this->slugs[$slug]]['default'];
261 261
         }
262 262
 
263 263
         return preg_replace('/(GET|POST|PUT|DELETE|ALL|HEAD|PATCH)\#\|\#/', '', $url);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         if ($this->hasToRunPreChecks($class)) {
273 273
             self::run($class, '__check', true);
274 274
         }
275
-        $preAction = 'pre' . ucfirst($method);
275
+        $preAction = 'pre'.ucfirst($method);
276 276
         if (method_exists($class, $preAction)) {
277 277
             self::run($class, $preAction);
278 278
         }
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
      */
288 288
     public static function run($class, $method, $throwExceptions = false): void
289 289
     {
290
-        Inspector::stats("[Router] Pre action invoked " . get_class($class) . "::{$method}", Inspector::SCOPE_DEBUG);
290
+        Inspector::stats("[Router] Pre action invoked ".get_class($class)."::{$method}", Inspector::SCOPE_DEBUG);
291 291
         try {
292 292
             if (false === call_user_func_array([$class, $method], [])) {
293
-                Logger::log(t("[Router] action " . get_class($class) . "::{$method} failed"), LOG_ERR, [error_get_last()]);
293
+                Logger::log(t("[Router] action ".get_class($class)."::{$method} failed"), LOG_ERR, [error_get_last()]);
294 294
                 error_clear_last();
295 295
             }
296
-        } catch (Exception $e) {
296
+        }catch (Exception $e) {
297 297
             Logger::log($e->getMessage(), LOG_ERR, [$class, $method]);
298 298
             if ($throwExceptions) {
299 299
                 throw $e;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
324 324
     {
325
-        Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG);
325
+        Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG);
326 326
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
327 327
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
328 328
         $cache = Cache::needCache();
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
         $return = null;
331 331
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
332 332
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
333
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache);
333
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache);
334 334
             if (NULL !== $cachedData) {
335
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON);
335
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON);
336 336
                 Template::getInstance()->renderCache($cachedData, $headers);
337 337
                 $execute = FALSE;
338 338
             }
339 339
         }
340 340
         if ($execute) {
341
-            Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG);
341
+            Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG);
342 342
             $this->checkPreActions($class, $action['method']);
343 343
             $return = call_user_func_array([$class, $action['method']], $params);
344 344
             if (false === $return) {
Please login to merge, or discard this patch.
src/base/types/Api.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     public function init()
55 55
     {
56 56
         parent::init();
57
-        Logger::log(static::class . ' init', LOG_DEBUG);
57
+        Logger::log(static::class.' init', LOG_DEBUG);
58 58
         $this->domain = $this->getDomain();
59 59
         $this->hydrateRequestData();
60 60
         $this->hydrateOrders();
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         }
64 64
         $this->checkFieldType();
65 65
         $this->setLoaded(true);
66
-        Logger::log(static::class . ' loaded', LOG_DEBUG);
66
+        Logger::log(static::class.' loaded', LOG_DEBUG);
67 67
     }
68 68
 
69 69
     private function checkActions($method)
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
                 $status = 200;
160 160
                 $saved = TRUE;
161 161
                 $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
162
-            } else {
162
+            }else {
163 163
                 $message = t('No se ha podido guardar el modelo seleccionado');
164 164
             }
165
-        } catch (\Exception $e) {
166
-            if(Config::getParam('debug')) {
167
-                $message = t('Ha ocurrido un error intentando guardar el elemento: ') . '<br>' . $e->getMessage();
168
-            } else {
169
-                $message = t('Ha ocurrido un error intentando guardar el elemento: ') . '<br>' . $e->getCode();
165
+        }catch (\Exception $e) {
166
+            if (Config::getParam('debug')) {
167
+                $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
168
+            }else {
169
+                $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getCode();
170 170
             }
171 171
             $context = [];
172 172
             if (null !== $e->getPrevious()) {
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
                     $updated = TRUE;
206 206
                     $status = 200;
207 207
                     $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
208
-                } else {
208
+                }else {
209 209
                     $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
210 210
                 }
211
-            } catch (\Exception $e) {
212
-                if(Config::getParam('debug')) {
213
-                    $message = t('Ha ocurrido un error intentando actualizar el elemento: ') . '<br>' . $e->getMessage();
214
-                } else {
215
-                    $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs: ') . '<br>' . $e->getCode();
211
+            }catch (\Exception $e) {
212
+                if (Config::getParam('debug')) {
213
+                    $message = t('Ha ocurrido un error intentando actualizar el elemento: ').'<br>'.$e->getMessage();
214
+                }else {
215
+                    $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs: ').'<br>'.$e->getCode();
216 216
                 }
217 217
                 $context = [];
218 218
                 if (null !== $e->getPrevious()) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                 }
221 221
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
222 222
             }
223
-        } else {
223
+        }else {
224 224
             $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar');
225 225
         }
226 226
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
                     $this->model->delete($this->con);
255 255
                     $deleted = TRUE;
256 256
                 }
257
-            } catch (\Exception $e) {
257
+            }catch (\Exception $e) {
258 258
                 $context = [];
259 259
                 if (null !== $e->getPrevious()) {
260 260
                     $context[] = $e->getPrevious()->getMessage();
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
             $this->saveBulk();
287 287
             $saved = true;
288 288
             $status = 200;
289
-        } catch (\Exception $e) {
289
+        }catch (\Exception $e) {
290 290
             Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData());
291 291
             $message = t('Bulk insert rolled back');
292 292
         }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
             if (null !== $this->list) {
319 319
                 if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
320 320
                     $return = $this->extractDataWithFormat();
321
-                } else {
321
+                }else {
322 322
                     $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false);
323 323
                 }
324 324
                 $total = 0;
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
                     $pages = 1;
332 332
                 }
333 333
             }
334
-        } catch (\Exception $e) {
335
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
334
+        }catch (\Exception $e) {
335
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
336 336
         }
337 337
 
338 338
         return array($return, $total, $pages);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         $return = array();
351 351
         if (NULL === $model || !method_exists($model, 'toArray')) {
352 352
             $code = 404;
353
-        } else {
353
+        }else {
354 354
             $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
355 355
         }
356 356
 
Please login to merge, or discard this patch.
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/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/base/types/helpers/AuthHelper.php 1 patch
Spacing   +5 added lines, -5 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)
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         return base64_encode($encrypted_data);
87 87
     }
88 88
 
89
-    public static function decrypt(string $encrypted_data, string $key): false|string
89
+    public static function decrypt(string $encrypted_data, string $key): false | string
90 90
     {
91 91
         $encrypted_data = base64_decode($encrypted_data);
92 92
         $data = '';
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
         $tz = new \DateTimeZone('UTC');
105 105
         $timestamp = new \DateTime('now', $tz);
106 106
         $timestamp->modify(Config::getParam('auth.expiration', '+1 day'));
107
-        $data = $user . Security::LOGGED_USER_TOKEN . $timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT);
108
-        return self::encrypt($data, sha1($user . $password));
107
+        $data = $user.Security::LOGGED_USER_TOKEN.$timestamp->format(self::EXPIRATION_TIMESTAMP_FORMAT);
108
+        return self::encrypt($data, sha1($user.$password));
109 109
     }
110 110
 
111 111
     public static function decodeToken(string $token, string $password): array
112 112
     {
113 113
         $user = $timestamp = null;
114 114
         $secret = self::decrypt($token, $password);
115
-        if(!empty($secret) && str_contains($secret, Security::LOGGED_USER_TOKEN)) {
115
+        if (!empty($secret) && str_contains($secret, Security::LOGGED_USER_TOKEN)) {
116 116
             list($user, $timestamp) = explode(Security::LOGGED_USER_TOKEN, $secret);
117 117
         }
118 118
         return [$user, $timestamp];
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.