Passed
Push — master ( d2956c...9cde44 )
by Fran
03:15
created
src/base/Service.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@
 block discarded – undo
125 125
     }
126 126
 
127 127
     /**
128
-     * @param $header
129
-     * @param null $content
128
+     * @param string $header
129
+     * @param string $content
130 130
      *
131 131
      * @return $this
132 132
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
         $this->url = NULL;
178 178
         $this->params = array();
179 179
         $this->headers = array();
180
-        Logger::log("Context service for " . get_called_class() . " cleared!");
180
+        Logger::log("Context service for ".get_called_class()." cleared!");
181 181
     }
182 182
 
183 183
     /**
Please login to merge, or discard this patch.
src/base/Singleton.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,9 +135,11 @@
 block discarded – undo
135 135
                 $cacheService->storeData($cacheFilename, $properties, Cache::JSON);
136 136
             }
137 137
             /** @var \ReflectionProperty $property */
138
-            if (!empty($properties) && is_array($properties)) foreach ($properties as $property => $class) {
138
+            if (!empty($properties) && is_array($properties)) {
139
+                foreach ($properties as $property => $class) {
139 140
                 $this->load($property, true, $class);
140 141
             }
142
+            }
141 143
             $this->setLoaded();
142 144
         } else {
143 145
             Logger::log(get_class($this) . ' already loaded', LOG_INFO);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct()
22 22
     {
23
-        Logger::log(get_class($this) . ' constructor invoked');
23
+        Logger::log(get_class($this).' constructor invoked');
24 24
         $this->init();
25 25
     }
26 26
 
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
         $calledClass = get_called_class();
91 91
         try {
92 92
             $instance = InjectorHelper::constructInyectableInstance($variable, $singleton, $classNameSpace, $calledClass);
93
-            $setter = "set" . ucfirst($variable);
93
+            $setter = "set".ucfirst($variable);
94 94
             if (method_exists($calledClass, $setter)) {
95 95
                 $this->$setter($instance);
96
-            } else {
96
+            }else {
97 97
                 $this->$variable = $instance;
98 98
             }
99
-        } catch (\Exception $e) {
100
-            Logger::log($e->getMessage() . ': ' . $e->getFile() . ' [' . $e->getLine() . ']', LOG_ERR);
99
+        }catch (\Exception $e) {
100
+            Logger::log($e->getMessage().': '.$e->getFile().' ['.$e->getLine().']', LOG_ERR);
101 101
         }
102 102
         return $this;
103 103
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     public function init()
109 109
     {
110 110
         if (!$this->isLoaded()) {
111
-            $cacheFilename = "reflections" . DIRECTORY_SEPARATOR . sha1(get_class($this)) . ".json";
111
+            $cacheFilename = "reflections".DIRECTORY_SEPARATOR.sha1(get_class($this)).".json";
112 112
             /** @var \PSFS\base\Cache $cacheService */
113 113
             $cacheService = Cache::getInstance();
114 114
             /** @var \PSFS\base\config\Config $configService */
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
                 $this->load($property, true, $class);
124 124
             }
125 125
             $this->setLoaded();
126
-        } else {
127
-            Logger::log(get_class($this) . ' already loaded', LOG_INFO);
126
+        }else {
127
+            Logger::log(get_class($this).' already loaded', LOG_INFO);
128 128
         }
129 129
     }
130 130
 }
Please login to merge, or discard this patch.
src/autoload.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
             $path = str_replace("\\", DIRECTORY_SEPARATOR, $class);
22 22
 
23 23
             // filepath
24
-            $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php";
24
+            $abs_path = SOURCE_DIR.DIRECTORY_SEPARATOR.$path.".php";
25 25
             if (!file_exists($abs_path)) {
26
-                pre('→ ' . $class);
27
-                pre('→ ' . $path);
28
-                pre('→ ' . $abs_path);
26
+                pre('→ '.$class);
27
+                pre('→ '.$path);
28
+                pre('→ '.$abs_path);
29 29
             }
30 30
 
31 31
             // require the file
Please login to merge, or discard this patch.
src/base/Cache.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     /**
123 123
      * Método que guarda en fichero los datos pasados
124
-     * @param $path
124
+     * @param string $path
125 125
      * @param $data
126 126
      * @param int $transform
127 127
      * @param boolean $absolutePath
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
     /**
158 158
      * Método estático que revisa si se necesita cachear la respuesta de un servicio o no
159
-     * @return integer|boolean
159
+     * @return integer
160 160
      */
161 161
     public static function needCache()
162 162
     {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use PSFS\base\config\Config;
5 5
 use PSFS\base\exception\ConfigException;
6
-use PSFS\base\types\helpers\RequestHelper;
7 6
 use PSFS\base\types\SingletonTrait;
8 7
 
9 8
 /**
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     private function saveTextToFile($data, $path, $absolute = false)
32 32
     {
33
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
33
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
34 34
         $filename = basename($absolutePath);
35 35
         Config::createDir(str_replace($filename, "", $absolutePath));
36 36
         if (false === file_put_contents($absolutePath, $data)) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function getDataFromFile($path, $transform = Cache::TEXT, $absolute = false)
50 50
     {
51 51
         $data = null;
52
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
52
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
53 53
         if (file_exists($absolutePath)) {
54 54
             $data = file_get_contents($absolutePath);
55 55
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function hasExpiredCache($path, $expires = 300, $absolute = false)
67 67
     {
68
-        $absolutePath = ($absolute) ? $path : CACHE_DIR . DIRECTORY_SEPARATOR . $path;
68
+        $absolutePath = ($absolute) ? $path : CACHE_DIR.DIRECTORY_SEPARATOR.$path;
69 69
         $lasModificationDate = filemtime($absolutePath);
70 70
         return ($lasModificationDate + $expires <= time());
71 71
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 break;
89 89
             case Cache::GZIP:
90 90
                 // TODO implementar
91
-                if(function_exists('gzuncompress')) {
91
+                if (function_exists('gzuncompress')) {
92 92
                     $data = gzuncompress($data ?: '');
93 93
                 }
94 94
                 break;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 $data = Cache::transformData($data, Cache::GZIP);
114 114
                 break;
115 115
             case Cache::GZIP:
116
-                if(function_exists('gzcompress')) {
116
+                if (function_exists('gzcompress')) {
117 117
                     $data = gzcompress($data ?: '');
118 118
                 }
119 119
                 break;
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
     public function readFromCache($path, $expires = 300, callable $function, $transform = Cache::TEXT)
146 146
     {
147 147
         $data = null;
148
-        if (file_exists(CACHE_DIR . DIRECTORY_SEPARATOR . $path)) {
148
+        if (file_exists(CACHE_DIR.DIRECTORY_SEPARATOR.$path)) {
149 149
             if (null !== $function && $this->hasExpiredCache($path, $expires)) {
150 150
                 $data = call_user_func($function);
151 151
                 $this->storeData($path, $data, $transform);
152
-            } else {
152
+            }else {
153 153
                 $data = $this->getDataFromFile($path, $transform);
154 154
             }
155 155
         }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     private static function checkAdminSite() {
163 163
         $isAdminRequest = false;
164 164
         $lastRequest = Security::getInstance()->getSessionKey("lastRequest");
165
-        if(null !== $lastRequest) {
165
+        if (null !== $lastRequest) {
166 166
             $url = str_replace(Request::getInstance()->getRootUrl(true), '', $lastRequest['url']);
167 167
             $isAdminRequest = preg_match('/^\/admin\//i', $url);
168 168
         }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     public static function needCache()
177 177
     {
178 178
         $needCache = false;
179
-        if(!self::checkAdminSite()) {
179
+        if (!self::checkAdminSite()) {
180 180
             $action = Security::getInstance()->getSessionKey("__CACHE__");
181 181
             if (null !== $action && array_key_exists("cache", $action) && $action["cache"] > 0) {
182 182
                 $needCache = $action["cache"];
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         $hash = "";
195 195
         $action = Security::getInstance()->getSessionKey("__CACHE__");
196 196
         if (null !== $action && $action["cache"] > 0) {
197
-            $hash = $action["http"] . " " . $action["slug"];
197
+            $hash = $action["http"]." ".$action["slug"];
198 198
         }
199 199
         return sha1($hash);
200 200
     }
Please login to merge, or discard this patch.
src/command/CreateDocumentRoot.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@
 block discarded – undo
32 32
                 'robots' => 'robots.txt',
33 33
             ];
34 34
             foreach ($files as $templates => $filename) {
35
-                $text = \PSFS\base\Template::getInstance()->dump("generator/html/". $templates . '.html.twig');
36
-                if(false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
37
-                    $output->writeln('Can\t create the file ' . $filename);
38
-                } else {
39
-                    $output->writeln($filename . ' created successfully');
35
+                $text = \PSFS\base\Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
36
+                if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
37
+                    $output->writeln('Can\t create the file '.$filename);
38
+                }else {
39
+                    $output->writeln($filename.' created successfully');
40 40
                 }
41 41
             }
42 42
 
43 43
             //Export base locale translations
44
-            if(!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
44
+            if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
45 45
                 \PSFS\base\config\Config::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
46
-                \PSFS\Services\GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
46
+                \PSFS\Services\GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
47 47
             }
48 48
 
49 49
             $output->writeln("Document root generado en ".$path);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
     use Symfony\Component\Console\Input\InputInterface;
7 7
     use Symfony\Component\Console\Output\OutputInterface;
8 8
 
9
-    if (!isset($console)) $console = new Application();
9
+    if (!isset($console)) {
10
+        $console = new Application();
11
+    }
10 12
     $console
11 13
         ->register('psfs:create:root')
12 14
         ->setDefinition(array(
@@ -16,7 +18,9 @@  discard block
 block discarded – undo
16 18
         ->setCode(function(InputInterface $input, OutputInterface $output) {
17 19
             // Creates the html path
18 20
             $path = $input->getArgument('path');
19
-            if (empty($path)) $path = WEB_DIR;
21
+            if (empty($path)) {
22
+                $path = WEB_DIR;
23
+            }
20 24
             \PSFS\base\config\Config::createDir($path);
21 25
             $paths = array("js", "css", "img", "media", "font");
22 26
             foreach ($paths as $htmlPath) {
Please login to merge, or discard this patch.
src/controller/ConfigController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      * @GET
21 21
      * @route /admin/config/params
22 22
      * @visible false
23
-     * @return mixed
23
+     * @return string|null
24 24
      */
25 25
     public function getConfigParams() {
26 26
         $response = array_merge(Config::$required, Config::$optional);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
     public function getConfigParams() {
26 26
         $response = array_merge(Config::$required, Config::$optional);
27 27
         $domains = Router::getInstance()->getDomains();
28
-        foreach($domains as $domain => $routes) {
28
+        foreach ($domains as $domain => $routes) {
29 29
             $pDomain = str_replace('@', '', $domain);
30 30
             $pDomain = str_replace('/', '', $pDomain);
31
-            $response[] = strtolower($pDomain) . '.api.secret';
31
+            $response[] = strtolower($pDomain).'.api.secret';
32 32
         }
33 33
         return $this->json($response);
34 34
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function config()
44 44
     {
45
-        Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri());
45
+        Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri());
46 46
         /* @var $form \PSFS\base\config\ConfigForm */
47 47
         $form = new ConfigForm(Router::getInstance()->getRoute('admin-config'), Config::$required, Config::$optional, Config::getInstance()->dumpConfig());
48 48
         $form->build();
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 }
80 80
                 Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente"));
81 81
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true));
82
-            } else {
82
+            }else {
83 83
                 throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
84 84
             }
85 85
         }
Please login to merge, or discard this patch.
src/controller/RouteController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      * @GET
29 29
      * @route /admin/routes/show
30 30
      * @visible false
31
-     * @return mixed
31
+     * @return string|null
32 32
      */
33 33
     public function getRouting()
34 34
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
             $router->simpatize();
52 52
             Security::getInstance()->setFlash("callback_message", _("Rutas generadas correctamente"));
53 53
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
54
-        } catch(\Exception $e) {
54
+        }catch (\Exception $e) {
55 55
             Logger::log($e->getMessage(), LOG_ERR);
56 56
             Security::getInstance()->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs"));
57 57
             Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-routes", true));
Please login to merge, or discard this patch.
src/controller/I18nController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@
 block discarded – undo
38 38
         //Generating the templates translations
39 39
         $translations = $this->tpl->regenerateTemplates();
40 40
 
41
-        $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
42
-        $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
41
+        $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
42
+        $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
43 43
 
44 44
         //xgettext localizations
45 45
         $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale));
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@
 block discarded – undo
33 33
     public function getTranslations($locale)
34 34
     {
35 35
         //Default locale
36
-        if (null === $locale) $locale = $this->config->get("default_language");
36
+        if (null === $locale) {
37
+            $locale = $this->config->get("default_language");
38
+        }
37 39
 
38 40
         //Generating the templates translations
39 41
         $translations = $this->tpl->regenerateTemplates();
Please login to merge, or discard this patch.
src/controller/GeneratorController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function generateModule()
32 32
     {
33
-        Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri());
33
+        Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri());
34 34
         /* @var $form \PSFS\base\config\ConfigForm */
35 35
         $form = new ModuleForm();
36 36
         $form->build();
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
                 $this->gen->createStructureModule($module, $force, $type, (bool)$is_module);
62 62
                 Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
63 63
                 Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true));
64
-            } catch (\Exception $e) {
64
+            }catch (\Exception $e) {
65 65
                 pre($e->getMessage(), true);
66
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
66
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
67 67
                 throw new ConfigException('Error al generar el módulo, prueba a cambiar los permisos', 403);
68 68
             }
69 69
         }
Please login to merge, or discard this patch.