Passed
Push — master ( 61315a...6ce89b )
by Fran
09:52
created
src/base/types/Form.php 3 patches
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,6 +42,10 @@  discard block
 block discarded – undo
42 42
          * @return Form
43 43
          */
44 44
         public function setEncType($enctype) { $this->enctype = $enctype; return $this; }
45
+
46
+        /**
47
+         * @param string|null $action
48
+         */
45 49
         public function setAction($action) { $this->action = $action; return $this; }
46 50
         public function setMethod($method) { $this->method = $method; return $this; }
47 51
         public function setAttrs(array $attrs) { $this->attrs = $attrs; return $this; }
@@ -466,7 +470,7 @@  discard block
 block discarded – undo
466 470
         }
467 471
 
468 472
         /**
469
-         * @param $token_field
473
+         * @param string $token_field
470 474
          * @return bool
471 475
          */
472 476
         protected function existsFormToken($token_field) {
@@ -494,7 +498,7 @@  discard block
 block discarded – undo
494 498
         /**
495 499
          * Método que extrae el valor de un campo del formulario del modelo
496 500
          * @param $field
497
-         * @param $value
501
+         * @param ObjectCollection $value
498 502
          * @param $type
499 503
          * @return mixed
500 504
          */
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     use PSFS\base\Singleton;
13 13
     use PSFS\base\types\interfaces\FormType;
14 14
 
15
-    abstract class Form extends Singleton implements FormType{
15
+    abstract class Form extends Singleton implements FormType {
16 16
 
17 17
         /**
18 18
          * Variables de formulario
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
         public function __construct($model = null)
33 33
         {
34
-            if(null !== $model) {
34
+            if (null !== $model) {
35 35
                 $this->model = $model;
36 36
             }
37 37
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
          */
123 123
         public function getFieldValue($name) {
124 124
             $value = null;
125
-            if (null !== $this->getField($name)){
125
+            if (null !== $this->getField($name)) {
126 126
                 $field = $this->getField($name);
127 127
                 $value = (array_key_exists('value', $field) && null !== $field['value']) ? $field['value'] : null;
128 128
             }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                 $model->save();
324 324
                 $save = true;
325 325
                 Logger::getInstance()->infoLog(get_class($this->model)." guardado con id ".$this->model->getPrimaryKey());
326
-            } catch (\Exception $e) {
326
+            }catch (\Exception $e) {
327 327
                 Logger::getInstance()->errorLog($e->getMessage());
328 328
                 throw new FormException($e->getMessage(), $e->getCode(), $e);
329 329
             }
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
             if (array_key_exists($key, $data[$form_name])) {
370 370
                 if (preg_match("/id/i", $key) && ($data[$form_name][$key] === 0 || $data[$form_name][$key] === "%" || $data[$form_name][$key] === "")) {
371 371
                     $field["value"] = null;
372
-                } else {
372
+                }else {
373 373
                     $field["value"] = $data[$form_name][$key];
374 374
                 }
375
-            } else {
375
+            }else {
376 376
                 unset($field["value"]);
377 377
             }
378 378
             return array($data, $field);
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
                 if (array_key_exists('class_id', $field) && method_exists($class, "get".$field["class_id"])) {
417 417
                     $method = "get".$field["class_id"];
418 418
                     $data[] = $class->$method();
419
-                } else {
419
+                }else {
420 420
                     $data[] = $class->getPrimaryKey();
421 421
                 }
422
-            } else {
422
+            }else {
423 423
                 $data[] = $val;
424 424
             }
425 425
 
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
                             $field["value"] = $value;
450 450
                         } elseif ($value instanceof \DateTime) {
451 451
                             $field["value"] = $value->format("Y-m-d H:i:s");
452
-                        } else {
452
+                        }else {
453 453
                             $field["value"] = $value->getPrimaryKey();
454 454
                         }
455 455
                     }
456
-                } else {
456
+                }else {
457 457
                     $field["value"] = $value;
458 458
                 }
459 459
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,7 +156,9 @@  discard block
 block discarded – undo
156 156
             //Validamos los campos del formulario
157 157
             if ($valid && count($this->fields) > 0) {
158 158
                 foreach ($this->fields as $key => &$field) {
159
-                    if ($key === $token_field || $key === self::SEPARATOR) continue;
159
+                    if ($key === $token_field || $key === self::SEPARATOR) {
160
+                        continue;
161
+                    }
160 162
                     list($field, $valid) = $this->checkFieldValidation($field, $key);
161 163
                 }
162 164
             }
@@ -442,7 +444,7 @@  discard block
 block discarded – undo
442 444
                     //Si es una relación múltiple
443 445
                     if ($value instanceof ObjectCollection) {
444 446
                         $field = $this->computeModelFieldValue($field, $value, $type);
445
-                    }else { //O una relación unitaria
447
+                    } else { //O una relación unitaria
446 448
                         if (method_exists($value, "__toString")) {
447 449
                             $field["value"] = $value;
448 450
                         } elseif ($value instanceof \DateTime) {
Please login to merge, or discard this patch.
src/controller/Admin.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      * Servicio que devuelve los parámetros disponibles
303 303
      * @route /admin/config/params
304 304
      * @visible false
305
-     * @return mixed
305
+     * @return string|null
306 306
      */
307 307
     public function getConfigParams() {
308 308
         $response = array_merge(Config::$required, Config::$optional);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      * Servicio que devuelve los parámetros disponibles
331 331
      * @route /admin/routes/show
332 332
      * @visible false
333
-     * @return mixed
333
+     * @return string|null
334 334
      */
335 335
     public function getRouting()
336 336
     {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -175,7 +175,9 @@
 block discarded – undo
175 175
      */
176 176
     public function getTranslations($locale = '') {
177 177
         //Idioma por defecto
178
-        if(empty($locale)) $locale = $this->config->get("default_language");
178
+        if(empty($locale)) {
179
+            $locale = $this->config->get("default_language");
180
+        }
179 181
 
180 182
         //Generamos las traducciones de las plantillas
181 183
         $translations = $this->tpl->regenerateTemplates();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @package PSFS\controller
21 21
  * @domain ROOT
22 22
  */
23
-class Admin extends AuthAdminController{
23
+class Admin extends AuthAdminController {
24 24
 
25 25
     const DOMAIN = 'ROOT';
26 26
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 Logger::getInstance()->infoLog("Configuración guardada correctamente");
85 85
                 $this->security->setFlash("callback_message", _("Usuario agregado correctamente"));
86 86
                 $this->security->setFlash("callback_route", $this->getRoute("admin"), true);
87
-            } else {
87
+            }else {
88 88
                 throw new \HttpException('Error al guardar los administradores, prueba a cambiar los permisos', 403);
89 89
             }
90 90
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
                 $cookies = array(
151 151
                     array(
152 152
                         "name" => Security::getInstance()->getHash(),
153
-                        "value" => base64_encode($form->getFieldValue("user") . ":" . $form->getFieldValue("pass")),
153
+                        "value" => base64_encode($form->getFieldValue("user").":".$form->getFieldValue("pass")),
154 154
                         "expire" => time() + 3600,
155 155
                         "http" => true,
156 156
                     )
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                     'status_message' => _("Acceso permitido... redirigiendo!!"),
162 162
                     'delay' => 1,
163 163
                 );
164
-            } else {
164
+            }else {
165 165
                 $form->setError("user", _("El usuario no tiene acceso a la web"));
166 166
             }
167 167
         }
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function getTranslations($locale = '') {
179 179
         //Idioma por defecto
180
-        if(empty($locale)) $locale = $this->config->get("default_language");
180
+        if (empty($locale)) $locale = $this->config->get("default_language");
181 181
 
182 182
         //Generamos las traducciones de las plantillas
183 183
         $translations = $this->tpl->regenerateTemplates();
184 184
 
185
-        $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
186
-        $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
185
+        $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
186
+        $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
187 187
 
188 188
         //Localizamos xgettext
189 189
         $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale));
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
         $form = new ConfigForm();
231 231
         $form->build();
232 232
         $form->hydrate();
233
-        if($form->isValid()) {
233
+        if ($form->isValid()) {
234 234
             $debug = Config::getInstance()->getDebugMode();
235 235
             $newDebug = $form->getFieldValue("debug");
236
-            if(Config::save($form->getData(), $form->getExtraData())) {
236
+            if (Config::save($form->getData(), $form->getExtraData())) {
237 237
                 Logger::getInstance()->infoLog(_('Configuración guardada correctamente'));
238 238
                 //Verificamos si tenemos que limpiar la cache del DocumentRoot
239
-                if(boolval($debug) !== boolval($newDebug)) {
239
+                if (boolval($debug) !== boolval($newDebug)) {
240 240
                     Config::clearDocumentRoot();
241 241
                 }
242 242
                 $this->security->setFlash("callback_message", _("Configuración actualizada correctamente"));
243 243
                 $this->security->setFlash("callback_route", $this->getRoute("admin-config", true));
244
-            } else {
244
+            }else {
245 245
                 throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403);
246 246
             }
247 247
         }
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
             $type = $form->getFieldValue("controllerType");
301 301
             try {
302 302
                 $this->gen->createStructureModule($module, $force, $type);
303
-                $this->security->setFlash("callback_message", str_replace("%s",$module, _("Módulo %s generado correctamente")));
303
+                $this->security->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente")));
304 304
                 $this->security->setFlash("callback_route", $this->getRoute("admin-module", true));
305
-            } catch(\Exception $e) {
306
-                Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]");
305
+            }catch (\Exception $e) {
306
+                Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]");
307 307
                 throw new ConfigException('Error al generar el módulo, prueba a cambiar los permisos', 403);
308 308
             }
309 309
         }
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
     public function getConfigParams() {
326 326
         $response = array_merge(Config::$required, Config::$optional);
327 327
         $domains = Router::getInstance()->getDomains();
328
-        foreach($domains as $domain => $routes) {
328
+        foreach ($domains as $domain => $routes) {
329 329
             $pDomain = str_replace('@', '', $domain);
330 330
             $pDomain = str_replace('/', '', $pDomain);
331
-            $response[] = strtolower($pDomain) . '.api.secret';
331
+            $response[] = strtolower($pDomain).'.api.secret';
332 332
         }
333 333
         return $this->json($response);
334 334
     }
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
         $selected = '';
372 372
         $monthOpen = null;
373
-        if($this->getRequest()->getMethod() == 'POST')
373
+        if ($this->getRequest()->getMethod() == 'POST')
374 374
         {
375 375
             $selected = $this->getRequest()->get("log");
376 376
             list($log, $monthOpen) = $this->srv->formatLogFile($selected);
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             $router->simpatize();
399 399
             $this->security->setFlash("callback_message", _("Rutas generadas correctamente"));
400 400
             $this->security->setFlash("callback_route", $this->getRoute("admin", true));
401
-        } catch(\Exception $e) {
401
+        }catch (\Exception $e) {
402 402
             Logger::getInstance()->errorLog($e->getMessage());
403 403
             $this->security->setFlash("callback_message", _("Algo no ha salido bien, revisa los logs"));
404 404
             $this->security->setFlash("callback_route", $this->getRoute("admin", true));
Please login to merge, or discard this patch.
src/base/dto/Dto.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
             try {
21 21
                 $reflectionClass = new \ReflectionClass($this);
22 22
                 $properties = $reflectionClass->getProperties();
23
-                if(count($properties) > 0) {
23
+                if (count($properties) > 0) {
24 24
                     /** @var \ReflectionProperty $property */
25
-                    foreach($properties as $property) {
25
+                    foreach ($properties as $property) {
26 26
                         $dto[$property->getName()] = $property->getValue($this);
27 27
                     }
28 28
                 }
29
-            } catch(\Exception $e) {
29
+            }catch (\Exception $e) {
30 30
                 Logger::getInstance(get_class($this))->errorLog($e->getMessage());
31 31
             }
32 32
             return $dto;
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
          */
48 48
         public function fromArray(array $object = array())
49 49
         {
50
-            if(count($object) > 0) {
51
-                foreach($object as $key => $value) {
52
-                    if(property_exists($this, $key)) {
50
+            if (count($object) > 0) {
51
+                foreach ($object as $key => $value) {
52
+                    if (property_exists($this, $key)) {
53 53
                         $this->$key = $value;
54 54
                     }
55 55
                 }
Please login to merge, or discard this patch.
src/base/dto/Order.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
         {
32 32
             $order = array();
33 33
             if (count($order) > 0) {
34
-                foreach($this->fields as $field => $direction) {
35
-                    if(strtolower($fieldToRemove) === strtolower($field)) {
34
+                foreach ($this->fields as $field => $direction) {
35
+                    if (strtolower($fieldToRemove) === strtolower($field)) {
36 36
                         continue;
37 37
                     }
38 38
                     $order[$field] = $direction;
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
          */
61 61
         public static function parseDirection($direction = Order::ASC)
62 62
         {
63
-            if(preg_match('/^asc$/i', $direction)) {
63
+            if (preg_match('/^asc$/i', $direction)) {
64 64
                 return Order::ASC;
65
-            } else {
65
+            }else {
66 66
                 return Order::DESC;
67 67
             }
68 68
         }
Please login to merge, or discard this patch.
src/base/extension/AssetsParser.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@
 block discarded – undo
303 303
         $js = file_get_contents($file);
304 304
         try {
305 305
             $data .= ";\n".$js;
306
-        }catch (\Exception $e) {
306
+        } catch (\Exception $e) {
307 307
             throw new ConfigException($e->getMessage());
308 308
         }
309 309
         return $data;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             foreach ($this->compiled_files as $file) {
198 198
                 echo "\t\t<script type='text/javascript' src='{$file}'></script>\n";
199 199
             }
200
-        } else {
200
+        }else {
201 201
             echo "\t\t<script type='text/javascript' src='/js/".$this->hash.".js'></script>\n";
202 202
         }
203 203
     }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             foreach ($this->compiled_files as $file) {
212 212
                 echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>";
213 213
             }
214
-        } else {
214
+        }else {
215 215
             echo "\t\t<link href='/css/".$this->hash.".css' rel='stylesheet' media='screen, print'>";
216 216
         }
217 217
     }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                     $this->log->infoLog("$orig copiado a $dest");
237 237
                 }
238 238
             }
239
-        } catch (\Exception $e) {
239
+        }catch (\Exception $e) {
240 240
             $this->log->errorLog($e->getMessage());
241 241
         }
242 242
     }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             if ($this->debug) {
266 266
                 $data = file_get_contents($file);
267 267
                 $this->storeContents($base.$file_path, $data);
268
-            } else {
268
+            }else {
269 269
                 $data .= file_get_contents($file);
270 270
             }
271 271
             $this->compiled_files[] = "/css/".$file_path;
Please login to merge, or discard this patch.
src/base/extension/AssetsTokenParser.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
         $tmp = array();
136 136
         if (NULL === $node) {
137 137
             $node = $value;
138
-        }else {
138
+        } else {
139 139
             $tmp = $this->getTmpAttribute($node);
140 140
         }
141 141
         $tmp[] = $value->getAttribute("value");
Please login to merge, or discard this patch.
src/base/extension/TemplateFunctions.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
             $router = Router::getInstance();
53 53
             try {
54 54
                 return $router->getRoute($path, $absolute, $params);
55
-            } catch (\Exception $e)
55
+            }catch (\Exception $e)
56 56
             {
57 57
                 return $router->getRoute('', $absolute, $params);
58 58
             }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
          * @param string $path
137 137
          * @param $domains
138 138
          *
139
-         * @return mixed
139
+         * @return string
140 140
          */
141 141
         private static function extractPathname($path, $domains)
142 142
         {
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -179,8 +179,11 @@
 block discarded – undo
179 179
         private static function putResourceContent($name, $filename_path, $base, $file_path)
180 180
         {
181 181
             $data = file_get_contents($filename_path);
182
-            if (!empty($name)) file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);
183
-            else file_put_contents($base.$file_path, $data);
182
+            if (!empty($name)) {
183
+                file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data);
184
+            } else {
185
+                file_put_contents($base.$file_path, $data);
186
+            }
184 187
         }
185 188
 
186 189
         /**
Please login to merge, or discard this patch.
src/base/types/SingletonTrait.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
             $class = get_called_class();
23 23
             if (!array_key_exists($class, self::$instance) || !self::$instance[$class] instanceof $class) {
24 24
                 self::$instance[$class] = new $class(func_get_args());
25
-                if (method_exists(self::$instance[$class], "init")) self::$instance[$class]->init();
25
+                if (method_exists(self::$instance[$class], "init")) {
26
+                    self::$instance[$class]->init();
27
+                }
26 28
             }
27 29
             return self::$instance[$class];
28 30
         }
Please login to merge, or discard this patch.
src/command/CreateModule.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,12 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
             public function infoLog($msg)
31 31
             {
32
-                if ($this->verbosity) $this->log->writeln($msg);
32
+                if ($this->verbosity) {
33
+                    $this->log->writeln($msg);
34
+                }
33 35
             }
34 36
         }
35 37
     }
36 38
 
37
-    if (!isset($console)) $console = new Application();
39
+    if (!isset($console)) {
40
+        $console = new Application();
41
+    }
38 42
     $console
39 43
         ->register('psfs:create:module')
40 44
         ->setDefinition(array(
@@ -58,7 +62,7 @@  discard block
 block discarded – undo
58 62
                 {
59 63
                     \PSFS\services\GeneratorService::getInstance()->createStructureModule($module, $log);
60 64
                 }
61
-            }catch (\Exception $e)
65
+            } catch (\Exception $e)
62 66
             {
63 67
                 $output->writeln($e->getMessage());
64 68
                 $output->writeln($e->getTraceAsString());
Please login to merge, or discard this patch.