Test Failed
Push — master ( cfdf4c...b122d3 )
by Fran
09:57
created
src/base/types/traits/SystemTrait.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 namespace PSFS\base\types\traits;
3 3
 
4 4
 use PSFS\base\Logger;
5
-use PSFS\base\Request;
6 5
 
7 6
 /**
8 7
  * Class SystemTrait
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                 $use /= 1024;
36 36
                 break;
37 37
             case "MBytes":
38
-                $use /= (1024 * 1024);
38
+                $use /= (1024*1024);
39 39
                 break;
40 40
             case "Bytes":
41 41
             default:
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         Logger::log('Added handlers for errors');
62 62
         //Warning & Notice handler
63
-        set_error_handler(function ($errno, $errstr, $errfile, $errline) {
63
+        set_error_handler(function($errno, $errstr, $errfile, $errline) {
64 64
             Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline, 'errno' => $errno]);
65 65
             return true;
66 66
         }, E_ALL | E_STRICT);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         Logger::log('Initializing stats (mem + ts)');
75 75
         if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) {
76 76
             $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT'];
77
-        } else {
77
+        }else {
78 78
             $this->ts = PSFS_START_TS;
79 79
         }
80 80
         $this->mem = PSFS_START_MEM;
Please login to merge, or discard this patch.
src/services/GeneratorService.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     /**
28 28
      * Método que revisa las traducciones directorio a directorio
29
-     * @param $path
29
+     * @param string $path
30 30
      * @param $locale
31 31
      * @return array
32 32
      */
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * Servicio que genera la estructura base
99 99
      * @param string $module
100 100
      * @param boolean $mod_path
101
-     * @return boolean
101
+     * @return boolean|null
102 102
      */
103 103
     private function createModulePathTree($module, $mod_path)
104 104
     {
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
      * Method that copy resources recursively
463 463
      * @param string $dest
464 464
      * @param boolean $force
465
-     * @param $filename_path
465
+     * @param string $filename_path
466 466
      * @param boolean $debug
467 467
      */
468 468
     public static function copyResources($dest, $force, $filename_path, $debug)
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -32,24 +32,24 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function findTranslations($path, $locale)
34 34
     {
35
-        $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
36
-        $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
35
+        $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
36
+        $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
37 37
 
38 38
         $translations = array();
39 39
         if (file_exists($path)) {
40 40
             $d = dir($path);
41 41
             while (false !== ($dir = $d->read())) {
42 42
                 GeneratorHelper::createDir($locale_path);
43
-                if (!file_exists($locale_path . 'translations.po')) {
44
-                    file_put_contents($locale_path . 'translations.po', '');
43
+                if (!file_exists($locale_path.'translations.po')) {
44
+                    file_put_contents($locale_path.'translations.po', '');
45 45
                 }
46
-                $inspect_path = realpath($path . DIRECTORY_SEPARATOR . $dir);
47
-                $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext " .
48
-                    $inspect_path . DIRECTORY_SEPARATOR .
46
+                $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir);
47
+                $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ".
48
+                    $inspect_path.DIRECTORY_SEPARATOR.
49 49
                     "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po";
50
-                if (is_dir($path . DIRECTORY_SEPARATOR . $dir) && preg_match('/^\./', $dir) == 0) {
51
-                    $res = _('Revisando directorio: ') . $inspect_path;
52
-                    $res .= _('Comando ejecutado: ') . $cmd_php;
50
+                if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) {
51
+                    $res = _('Revisando directorio: ').$inspect_path;
52
+                    $res .= _('Comando ejecutado: ').$cmd_php;
53 53
                     $res .= shell_exec($cmd_php);
54 54
                     usleep(10);
55 55
                     $translations[] = $res;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function createStructureModule($module, $force = false, $type = "", $apiClass = "")
72 72
     {
73
-        $mod_path = CORE_DIR . DIRECTORY_SEPARATOR;
73
+        $mod_path = CORE_DIR.DIRECTORY_SEPARATOR;
74 74
         $module = ucfirst($module);
75 75
         $this->createModulePath($module, $mod_path);
76 76
         $this->createModulePathTree($module, $mod_path);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         // Creates the src folder
92 92
         GeneratorHelper::createDir($mod_path);
93 93
         // Create module path
94
-        GeneratorHelper::createDir($mod_path . $module);
94
+        GeneratorHelper::createDir($mod_path.$module);
95 95
     }
96 96
 
97 97
     /**
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
             "Api", "Api/base", "Config", "Controller", "Models",
109 109
             "Public", "Templates", "Services", "Test", "Doc",
110 110
         ];
111
-        $module_path = $mod_path . $module;
111
+        $module_path = $mod_path.$module;
112 112
         foreach ($paths as $path) {
113
-            GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . $path);
113
+            GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR.$path);
114 114
         }
115 115
         //Creamos las carpetas de los assets
116 116
         $htmlPaths = array("css", "js", "img", "media", "font");
117 117
         foreach ($htmlPaths as $path) {
118
-            GeneratorHelper::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path);
118
+            GeneratorHelper::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path);
119 119
         }
120 120
     }
121 121
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '')
130 130
     {
131
-        $module_path = $mod_path . $module;
131
+        $module_path = $mod_path.$module;
132 132
         $this->generateControllerTemplate($module, $module_path, $force, $controllerType);
133 133
         $this->generateServiceTemplate($module, $module_path, $force);
134 134
         $this->genereateAutoloaderTemplate($module, $module_path, $force);
@@ -146,28 +146,28 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function createModuleModels($module, $path)
148 148
     {
149
-        $module_path = $path . $module;
150
-        $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path);
149
+        $module_path = $path.$module;
150
+        $module_path = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $module_path);
151 151
         //Generamos las clases de propel y la configuración
152
-        $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR .
153
-            "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel ";
154
-        $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path .
155
-            DIRECTORY_SEPARATOR . "Config";
156
-        $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR .
157
-            "Config --output-dir=" . CORE_DIR . " --verbose";
158
-        $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n" . $exec . "build" . $opt . $schemaOpt);
159
-        $ret = shell_exec($exec . "build" . $opt . $schemaOpt);
152
+        $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR.
153
+            "vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel ";
154
+        $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.
155
+            DIRECTORY_SEPARATOR."Config";
156
+        $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR.
157
+            "Config --output-dir=".CORE_DIR." --verbose";
158
+        $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n".$exec."build".$opt.$schemaOpt);
159
+        $ret = shell_exec($exec."build".$opt.$schemaOpt);
160 160
 
161 161
         $this->log->infoLog("[GENERATOR] Generamos clases invocando a propel:\n $ret");
162
-        $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR .
163
-            $module_path . DIRECTORY_SEPARATOR . "Config" . $schemaOpt);
162
+        $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR.
163
+            $module_path.DIRECTORY_SEPARATOR."Config".$schemaOpt);
164 164
         $this->log->infoLog("[GENERATOR] Generamos sql invocando a propel:\n $ret");
165 165
 
166 166
         $configTemplate = $this->tpl->dump("generator/config.propel.template.twig", array(
167 167
             "module" => $module,
168 168
         ));
169
-        $this->writeTemplateToFile($configTemplate, CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . "Config" .
170
-            DIRECTORY_SEPARATOR . "config.php", true);
169
+        $this->writeTemplateToFile($configTemplate, CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR."Config".
170
+            DIRECTORY_SEPARATOR."config.php", true);
171 171
         $this->log->infoLog("Generado config genérico para propel:\n $ret");
172 172
     }
173 173
 
@@ -188,28 +188,28 @@  discard block
 block discarded – undo
188 188
             "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
189 189
             "url" => preg_replace('/(\\\|\/)/', '/', $module),
190 190
             "class" => $class,
191
-            "controllerType" => $class . "Base",
191
+            "controllerType" => $class."Base",
192 192
             "is_base" => false
193 193
         ));
194
-        $controller = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" .
195
-            DIRECTORY_SEPARATOR . "{$class}Controller.php", $force);
194
+        $controller = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller".
195
+            DIRECTORY_SEPARATOR."{$class}Controller.php", $force);
196 196
 
197 197
         $controllerBody = $this->tpl->dump("generator/controller.template.twig", array(
198 198
             "module" => $module,
199 199
             "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
200 200
             "url" => preg_replace('/(\\\|\/)/', '/', $module),
201
-            "class" => $class . "Base",
201
+            "class" => $class."Base",
202 202
             "service" => $class,
203 203
             "controllerType" => $controllerType,
204 204
             "is_base" => true,
205 205
             "domain" => $class,
206 206
         ));
207
-        $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" .
208
-            DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true);
207
+        $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller".
208
+            DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true);
209 209
 
210
-        $filename = $mod_path . DIRECTORY_SEPARATOR . "Test" . DIRECTORY_SEPARATOR . "{$class}Test.php";
210
+        $filename = $mod_path.DIRECTORY_SEPARATOR."Test".DIRECTORY_SEPARATOR."{$class}Test.php";
211 211
         $test = true;
212
-        if(!file_exists($filename)) {
212
+        if (!file_exists($filename)) {
213 213
             $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array(
214 214
                 "module" => $module,
215 215
                 "namespace" => preg_replace('/(\\\|\/)/', '\\', $module),
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
     private function generateBaseApiTemplate($module, $mod_path, $force = false, $apiClass = "")
231 231
     {
232 232
         $created = true;
233
-        $modelPath = $mod_path . $module . DIRECTORY_SEPARATOR . 'Models';
234
-        $api_path = $mod_path . $module . DIRECTORY_SEPARATOR . 'Api';
233
+        $modelPath = $mod_path.$module.DIRECTORY_SEPARATOR.'Models';
234
+        $api_path = $mod_path.$module.DIRECTORY_SEPARATOR.'Api';
235 235
         if (file_exists($modelPath)) {
236 236
             $dir = dir($modelPath);
237 237
             while ($file = $dir->read()) {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         //Generamos el fichero de configuración
260 260
         $this->log->infoLog("Generamos fichero vacío de configuración");
261 261
         return $this->writeTemplateToFile("<?php\n\t",
262
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php",
262
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php",
263 263
             $force);
264 264
     }
265 265
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
         //Generamos el fichero de configuración
275 275
         $this->log->infoLog("Generamos ficheros para assets base");
276 276
         $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n",
277
-            $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css",
277
+            $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css",
278 278
             $force);
279 279
         $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();",
280
-            $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js",
280
+            $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js",
281 281
             $force);
282 282
         return ($css && $js);
283 283
     }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             "class" => $class,
300 300
         ));
301 301
         return $this->writeTemplateToFile($controller,
302
-            $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php",
302
+            $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php",
303 303
             $force);
304 304
     }
305 305
 
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
             "autoloader" => preg_replace('/(\\\|\/)/', '_', $module),
319 319
             "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module),
320 320
         ));
321
-        $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force);
321
+        $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force);
322 322
 
323 323
         $this->log->infoLog("Generamos el phpunit");
324 324
         $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array(
325 325
             "module" => $module,
326 326
         ));
327
-        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force);
327
+        $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force);
328 328
         return $autoload && $phpunit;
329 329
     }
330 330
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
             "db" => $this->config->get("db_name"),
346 346
         ));
347 347
         return $this->writeTemplateToFile($schema,
348
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml",
348
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml",
349 349
             $force);
350 350
     }
351 351
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             "namespace" => preg_replace('/(\\\|\/)/', '', $module),
364 364
         ));
365 365
         return $this->writeTemplateToFile($build_properties,
366
-            $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml",
366
+            $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml",
367 367
             $force);
368 368
     }
369 369
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             "module" => $module,
382 382
         ));
383 383
         return $this->writeTemplateToFile($index,
384
-            $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig",
384
+            $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig",
385 385
             $force);
386 386
     }
387 387
 
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
             try {
400 400
                 $this->cache->storeData($filename, $fileContent, Cache::TEXT, true);
401 401
                 $created = true;
402
-            } catch (\Exception $e) {
402
+            }catch (\Exception $e) {
403 403
                 $this->log->errorLog($e->getMessage());
404 404
             }
405
-        } else {
406
-            $this->log->errorLog($filename . _(' not exists or cant write'));
405
+        }else {
406
+            $this->log->errorLog($filename._(' not exists or cant write'));
407 407
         }
408 408
         return $created;
409 409
     }
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         ));
433 433
 
434 434
         return $this->writeTemplateToFile($controller,
435
-            $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true);
435
+            $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true);
436 436
     }
437 437
 
438 438
     /**
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
             "class" => $class,
456 456
         ));
457 457
 
458
-        return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force);
458
+        return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force);
459 459
     }
460 460
 
461 461
     /**
@@ -469,12 +469,12 @@  discard block
 block discarded – undo
469 469
     {
470 470
         if (file_exists($filename_path)) {
471 471
             $destfolder = basename($filename_path);
472
-            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
472
+            if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) {
473 473
                 if (is_dir($filename_path)) {
474
-                    self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
475
-                } else {
476
-                    if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
477
-                        throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
474
+                    self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
475
+                }else {
476
+                    if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) {
477
+                        throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder);
478 478
                     }
479 479
                 }
480 480
             }
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
         GeneratorHelper::createDir($dst);
494 494
         while (false !== ($file = readdir($dir))) {
495 495
             if (($file != '.') && ($file != '..')) {
496
-                if (is_dir($src . '/' . $file)) {
497
-                    self::copyr($src . '/' . $file, $dst . '/' . $file);
498
-                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
499
-                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
496
+                if (is_dir($src.'/'.$file)) {
497
+                    self::copyr($src.'/'.$file, $dst.'/'.$file);
498
+                } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) {
499
+                    throw new ConfigException("Can't copy ".$src." to ".$dst);
500 500
                 }
501 501
             }
502 502
         }
Please login to merge, or discard this patch.
src/base/types/traits/JsonTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function json($response, $statusCode = 200)
25 25
     {
26
-        if(Config::getParam('profiling.enable')) {
27
-            if(is_array($response)) {
26
+        if (Config::getParam('profiling.enable')) {
27
+            if (is_array($response)) {
28 28
                 $response['profiling'] = Inspector::getStats();
29
-            } elseif($response instanceof JsonResponse) {
29
+            } elseif ($response instanceof JsonResponse) {
30 30
                 $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats());
31 31
             }
32 32
         }
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
         $this->decodeJsonReponse($response);
35 35
 
36 36
         $data = json_encode($response, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING);
37
-        if(Config::getParam('angular.protection', false)) {
38
-            $data = ")]}',\n" . $data;
37
+        if (Config::getParam('angular.protection', false)) {
38
+            $data = ")]}',\n".$data;
39 39
         }
40 40
         $this->setStatus($statusCode);
41 41
         ResponseHelper::setDebugHeaders([]);
Please login to merge, or discard this patch.
src/base/types/traits/OutputTrait.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                 $this->setStatusCode(Template::STATUS_OK);
121 121
                 break;
122 122
             default:
123
-                $this->setStatusCode('HTTP/1.0 ' . $status ?: 200);
123
+                $this->setStatusCode('HTTP/1.0 '.$status ?: 200);
124 124
                 break;
125 125
         }
126 126
         return $this;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         ResponseHelper::setStatusHeader($this->getStatusCode());
139 139
         ResponseHelper::setAuthHeaders($this->isPublicZone());
140 140
         ResponseHelper::setCookieHeaders($cookies);
141
-        header('Content-type: ' . $contentType);
141
+        header('Content-type: '.$contentType);
142 142
 
143 143
     }
144 144
 
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
         Logger::log('Start output response');
155 155
         ob_start();
156 156
         $this->setReponseHeaders($contentType, $cookies);
157
-        header('Content-length: ' . strlen($output));
158
-        header('CRC: ' . crc32($output));
157
+        header('Content-length: '.strlen($output));
158
+        header('CRC: '.crc32($output));
159 159
 
160 160
         $needCache = Cache::needCache();
161 161
         $cache = Cache::getInstance();
162 162
         list($path, $cacheDataName) = $cache->getRequestCacheHash();
163 163
         if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK && null !== $cacheDataName) {
164 164
             Logger::log('Saving output response into cache');
165
-            $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output);
166
-            $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON);
165
+            $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output);
166
+            $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON);
167 167
         } elseif (Request::getInstance()->getMethod() !== 'GET') {
168 168
             $cache->flushCache();
169 169
         }
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
         Logger::log('Close template render');
184 184
         $uri = Request::requestUri();
185 185
         Security::getInstance()->setSessionKey("lastRequest", array(
186
-            "url" => Request::getInstance()->getRootUrl() . $uri,
186
+            "url" => Request::getInstance()->getRootUrl().$uri,
187 187
             "ts" => microtime(true),
188 188
         ));
189 189
         Security::getInstance()->updateSession();
190
-        Logger::log('End request: ' . $uri, LOG_INFO);
190
+        Logger::log('End request: '.$uri, LOG_INFO);
191 191
         exit;
192 192
     }
193 193
 
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
         /////////////////////////////////////////////////////////////
226 226
         // Date in the past sets the value to already have been expired.
227 227
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
228
-        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
228
+        header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
229 229
         header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
230 230
         header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
231 231
         header("Pragma: no-cache");
232 232
         header("Expires: 0");
233 233
         header('Content-Transfer-Encoding: binary');
234
-        header("Content-type: " . $content);
235
-        header("Content-length: " . strlen($data));
236
-        header('Content-Disposition: attachment; filename="' . $filename . '"');
234
+        header("Content-type: ".$content);
235
+        header("Content-length: ".strlen($data));
236
+        header('Content-Disposition: attachment; filename="'.$filename.'"');
237 237
         header("Access-Control-Expose-Headers: Filename");
238
-        header("Filename: " . $filename);
238
+        header("Filename: ".$filename);
239 239
         echo $data;
240 240
         ob_flush();
241 241
         ob_end_clean();
Please login to merge, or discard this patch.
src/base/types/traits/Api/MutationTrait.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -65,21 +65,21 @@  discard block
 block discarded – undo
65 65
         if (count($pks) == 1) {
66 66
             $pks = array_keys($pks);
67 67
             return [
68
-                $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD
68
+                $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD
69 69
             ];
70 70
         } elseif (count($pks) > 1) {
71 71
             $apiPks = [];
72 72
             $principal = '';
73 73
             $sep = 'CONCAT(';
74 74
             foreach ($pks as $pk) {
75
-                $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName();
76
-                $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName();
77
-                $sep = ', "' . Api::API_PK_SEPARATOR . '", ';
75
+                $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName();
76
+                $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName();
77
+                $sep = ', "'.Api::API_PK_SEPARATOR.'", ';
78 78
             }
79 79
             $principal .= ')';
80 80
             $apiPks[$principal] = Api::API_MODEL_KEY_FIELD;
81 81
             return $apiPks;
82
-        } else {
82
+        }else {
83 83
             throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta'));
84 84
         }
85 85
     }
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
         $pks = '';
103 103
         $sep = '';
104 104
         foreach ($tableMap->getPrimaryKeys() as $pk) {
105
-            $pks .= $sep . $pk->getFullyQualifiedName();
105
+            $pks .= $sep.$pk->getFullyQualifiedName();
106 106
             $sep = ', "|", ';
107 107
         }
108
-        $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD;
108
+        $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD;
109 109
     }
110 110
 
111 111
     /**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
             if (null !== $column) {
129 129
                 $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD;
130
-            } else {
130
+            }else {
131 131
                 $this->addClassListName($tableMap);
132 132
             }
133 133
         }
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
      * @param ModelCriteria $query
140 140
      * @param string $action
141 141
      */
142
-    private function addExtraColumns(ModelCriteria &$query, $action)
142
+    private function addExtraColumns(ModelCriteria & $query, $action)
143 143
     {
144 144
         if (Api::API_ACTION_LIST === $action) {
145 145
             $this->addDefaultListField();
146 146
             $this->addPkToList();
147 147
         }
148 148
         if (!empty($this->extraColumns)) {
149
-            if(Config::getParam('api.extrafields.compat', true)) {
149
+            if (Config::getParam('api.extrafields.compat', true)) {
150 150
                 $fields = array_values($this->extraColumns);
151
-            } else {
151
+            }else {
152 152
                 $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD);
153 153
                 $fields = explode(',', $returnFields ?: '');
154 154
                 $fields[] = self::API_MODEL_KEY_FIELD;
155 155
             }
156 156
             foreach ($this->extraColumns as $expression => $columnName) {
157
-                if(empty($fields) || in_array($columnName, $fields)) {
157
+                if (empty($fields) || in_array($columnName, $fields)) {
158 158
                     $query->withColumn($expression, $columnName);
159 159
                 }
160 160
             }
@@ -182,21 +182,21 @@  discard block
 block discarded – undo
182 182
     /**
183 183
      * @param ModelCriteria $query
184 184
      */
185
-    protected function checkI18n(ModelCriteria &$query)
185
+    protected function checkI18n(ModelCriteria & $query)
186 186
     {
187 187
         $this->extractApiLang();
188 188
         $model = $this->getModelNamespace();
189
-        $modelI18n = $model . 'I18n';
189
+        $modelI18n = $model.'I18n';
190 190
         if (method_exists($query, 'useI18nQuery')) {
191 191
             $query->useI18nQuery($this->lang);
192
-            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n) . 'TableMap';
192
+            $modelI18nTableMapClass = str_replace('\\Models\\', '\\Models\\Map\\', $modelI18n).'TableMap';
193 193
             /** @var TableMap $modelI18nTableMap */
194 194
             $modelI18nTableMap = $modelI18nTableMapClass::getTableMap();
195
-            foreach($modelI18nTableMap->getColumns() as $columnMap) {
196
-                if(!$columnMap->isPrimaryKey()) {
197
-                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName(), $columnMap->getPhpName());
198
-                } elseif(!$columnMap->isForeignKey()) {
199
-                    $query->withColumn('IFNULL(' . $modelI18nTableMapClass::TABLE_NAME . '.' . $columnMap->getName() . ', "'.$this->lang.'")', $columnMap->getPhpName());
195
+            foreach ($modelI18nTableMap->getColumns() as $columnMap) {
196
+                if (!$columnMap->isPrimaryKey()) {
197
+                    $query->withColumn($modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName(), $columnMap->getPhpName());
198
+                } elseif (!$columnMap->isForeignKey()) {
199
+                    $query->withColumn('IFNULL('.$modelI18nTableMapClass::TABLE_NAME.'.'.$columnMap->getName().', "'.$this->lang.'")', $columnMap->getPhpName());
200 200
                 }
201 201
             }
202 202
         }
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
      * @param ActiveRecordInterface $model
207 207
      * @param array $data
208 208
      */
209
-    protected function hydrateModelFromRequest(ActiveRecordInterface &$model, array $data = []) {
209
+    protected function hydrateModelFromRequest(ActiveRecordInterface & $model, array $data = []) {
210 210
         $model->fromArray($data);
211 211
         $tableMap = $this->getTableMap();
212 212
         try {
213
-            $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n');
214
-            if(null !== $relateI18n) {
213
+            $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n');
214
+            if (null !== $relateI18n) {
215 215
                 $i18NTableMap = $relateI18n->getLocalTable();
216
-                foreach($i18NTableMap->getColumns() as $columnMap) {
217
-                    $method = 'set' . $columnMap->getPhpName();
218
-                    if(!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
216
+                foreach ($i18NTableMap->getColumns() as $columnMap) {
217
+                    $method = 'set'.$columnMap->getPhpName();
218
+                    if (!($columnMap->isPrimaryKey() && $columnMap->isForeignKey())
219 219
                         &&array_key_exists($columnMap->getPhpName(), $data)
220 220
                         && method_exists($model, $method)) {
221 221
                         $model->$method($data[$columnMap->getPhpName()]);
222 222
                     }
223 223
                 }
224 224
             }
225
-        } catch(\Exception $e) {
225
+        }catch (\Exception $e) {
226 226
             Logger::log($e->getMessage(), LOG_WARNING);
227 227
         }
228 228
     }
Please login to merge, or discard this patch.
src/base/types/helpers/Inspector.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     protected static function calculateStats(array $stats, $ts, $mem = 0, $files = 0) {
29 29
         return [
30 30
             'ts' => round($stats['ts'] - $ts, 4),
31
-            'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4),
31
+            'mem' => round(($stats['mem'] - $mem)/1024/1024, 4),
32 32
             'files' => $stats['files'] - $files,
33 33
             'name' => $stats['name'],
34 34
         ];
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $ts = defined('PSFS_START_TS') ? PSFS_START_TS : 0;
43 43
         $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0;
44 44
         $files = 0;
45
-        foreach(self::$profiling as $key => &$value) {
45
+        foreach (self::$profiling as $key => &$value) {
46 46
             $value = self::calculateStats($value, $ts, $mem, $files);
47 47
         }
48 48
         self::$profiling[] = self::calculateStats(self::collect('Profiling collect ends'), $ts, $mem, $files);
Please login to merge, or discard this patch.