Passed
Branch master (dedd34)
by Fran
02:56
created
src/base/types/Api.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -56,20 +56,20 @@  discard block
 block discarded – undo
56 56
     public function init()
57 57
     {
58 58
         parent::init();
59
-        Logger::log(static::class . ' init', LOG_DEBUG);
59
+        Logger::log(static::class.' init', LOG_DEBUG);
60 60
         $this->domain = $this->getDomain();
61 61
         $this->hydrateRequestData();
62 62
         $this->hydrateOrders();
63
-        if($this instanceof CustomApi === false) {
63
+        if ($this instanceof CustomApi === false) {
64 64
             $this->createConnection($this->getTableMap());
65 65
         }
66 66
         $this->checkFieldType();
67 67
         $this->setLoaded(true);
68
-        Logger::log(static::class . ' loaded', LOG_DEBUG);
68
+        Logger::log(static::class.' loaded', LOG_DEBUG);
69 69
     }
70 70
 
71 71
     private function checkActions($method) {
72
-        switch($method) {
72
+        switch ($method) {
73 73
             default:
74 74
             case 'modelList': $this->action = self::API_ACTION_LIST; break;
75 75
             case 'get': $this->action = self::API_ACTION_GET; break;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
         $code = 200;
95 95
         list($return, $total, $pages) = $this->getList();
96 96
         $message = null;
97
-        if(!$total) {
97
+        if (!$total) {
98 98
             $message = t('No se han encontrado elementos para la búsqueda');
99 99
         }
100 100
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $pages = 1;
120 120
         $message = null;
121 121
         list($code, $return) = $this->getSingleResult($pk);
122
-        if($code !== 200) {
122
+        if ($code !== 200) {
123 123
             $message = t('No se ha encontrado el elemento solicitado');
124 124
         }
125 125
 
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
                 $status = 200;
149 149
                 $saved = TRUE;
150 150
                 $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
151
-            } else {
151
+            }else {
152 152
                 $message = t('No se ha podido guardar el modelo seleccionado');
153 153
             }
154
-        } catch (\Exception $e) {
155
-            $message = t('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage();
154
+        }catch (\Exception $e) {
155
+            $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage();
156 156
             $context = [];
157
-            if(null !== $e->getPrevious()) {
157
+            if (null !== $e->getPrevious()) {
158 158
                 $context[] = $e->getPrevious()->getMessage();
159 159
             }
160 160
             Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -190,18 +190,18 @@  discard block
 block discarded – undo
190 190
                     $updated = TRUE;
191 191
                     $status = 200;
192 192
                     $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
193
-                } else {
193
+                }else {
194 194
                     $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
195 195
                 }
196
-            } catch (\Exception $e) {
196
+            }catch (\Exception $e) {
197 197
                 $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs');
198 198
                 $context = [];
199
-                if(null !== $e->getPrevious()) {
199
+                if (null !== $e->getPrevious()) {
200 200
                     $context[] = $e->getPrevious()->getMessage();
201 201
                 }
202 202
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
203 203
             }
204
-        } else {
204
+        }else {
205 205
             $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar');
206 206
         }
207 207
 
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
                 $this->con->beginTransaction();
230 230
                 $this->hydrateModel($pk);
231 231
                 if (NULL !== $this->model) {
232
-                    if(method_exists('clearAllReferences', $this->model)) {
232
+                    if (method_exists('clearAllReferences', $this->model)) {
233 233
                         $this->model->clearAllReferences(true);
234 234
                     }
235 235
                     $this->model->delete($this->con);
236 236
                     $deleted = TRUE;
237 237
                 }
238
-            } catch (\Exception $e) {
238
+            }catch (\Exception $e) {
239 239
                 $context = [];
240
-                if(null !== $e->getPrevious()) {
240
+                if (null !== $e->getPrevious()) {
241 241
                     $context[] = $e->getPrevious()->getMessage();
242 242
                 }
243 243
                 Logger::log($e->getMessage(), LOG_CRIT, $context);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             $this->saveBulk();
267 267
             $saved = true;
268 268
             $status = 200;
269
-        } catch(\Exception $e) {
269
+        }catch (\Exception $e) {
270 270
             Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData());
271 271
             $message = t('Bulk insert rolled back');
272 272
         }
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
         /** @var CustomerTableMap $tableMap */
280 280
         $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap());
281
-        foreach($this->list->getData() as $data) {
281
+        foreach ($this->list->getData() as $data) {
282 282
             $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data);
283 283
         }
284 284
         return $return;
@@ -295,23 +295,23 @@  discard block
 block discarded – undo
295 295
         try {
296 296
             $this->paginate();
297 297
             if (null !== $this->list) {
298
-                if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
298
+                if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) {
299 299
                     $return = $this->extractDataWithFormat();
300
-                } else {
300
+                }else {
301 301
                     $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false);
302 302
                 }
303 303
                 $total = 0;
304 304
                 $pages = 0;
305
-                if($this->list instanceof PropelModelPager) {
305
+                if ($this->list instanceof PropelModelPager) {
306 306
                     $total = $this->list->getNbResults();
307 307
                     $pages = $this->list->getLastPage();
308
-                } elseif($this->list instanceof ArrayCollection) {
308
+                } elseif ($this->list instanceof ArrayCollection) {
309 309
                     $total = count($return);
310 310
                     $pages = 1;
311 311
                 }
312 312
             }
313
-        } catch (\Exception $e) {
314
-            Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR);
313
+        }catch (\Exception $e) {
314
+            Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR);
315 315
         }
316 316
 
317 317
         return array($return, $total, $pages);
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         $return = array();
330 330
         if (NULL === $model || !method_exists($model, 'toArray')) {
331 331
             $code = 404;
332
-        } else {
332
+        }else {
333 333
             $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true);
334 334
         }
335 335
 
Please login to merge, or discard this patch.
src/base/types/traits/Api/Crud/ApiListTrait.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     protected function hydrateOrders()
38 38
     {
39 39
         if (count($this->query)) {
40
-            Logger::log(static::class . ' gathering query string', LOG_DEBUG);
40
+            Logger::log(static::class.' gathering query string', LOG_DEBUG);
41 41
             foreach ($this->query as $key => $value) {
42 42
                 if ($key === self::API_ORDER_FIELD) {
43 43
                     $orders = json_decode($value, true);
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
      */
56 56
     protected function extractPagination()
57 57
     {
58
-        Logger::log(static::class . ' extract pagination start', LOG_DEBUG);
58
+        Logger::log(static::class.' extract pagination start', LOG_DEBUG);
59 59
         $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1;
60 60
         $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100;
61
-        Logger::log(static::class . ' extract pagination end', LOG_DEBUG);
61
+        Logger::log(static::class.' extract pagination end', LOG_DEBUG);
62 62
         return array($page, (int)$limit);
63 63
     }
64 64
 
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
      * @param ModelCriteria $query
68 68
      * @throws \PSFS\base\exception\ApiException
69 69
      */
70
-    protected function addOrders(ModelCriteria &$query)
70
+    protected function addOrders(ModelCriteria & $query)
71 71
     {
72
-        Logger::log(static::class . ' extract orders start ', LOG_DEBUG);
72
+        Logger::log(static::class.' extract orders start ', LOG_DEBUG);
73 73
         $orderAdded = FALSE;
74 74
         $tableMap = $this->getTableMap();
75 75
         foreach ($this->order->getOrders() as $field => $direction) {
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
                 $orderAdded = TRUE;
78 78
                 if ($direction === Order::ASC) {
79 79
                     $query->addAscendingOrderByColumn($column->getPhpName());
80
-                } else {
80
+                }else {
81 81
                     $query->addDescendingOrderByColumn($column->getPhpName());
82 82
                 }
83 83
             }
84 84
         }
85 85
         if (!$orderAdded) {
86 86
             $pks = $this->getPkDbName();
87
-            foreach(array_keys($pks) as $key) {
87
+            foreach (array_keys($pks) as $key) {
88 88
                 $query->addAscendingOrderByColumn($key);
89 89
             }
90 90
         }
91
-        Logger::log(static::class . ' extract orders end', LOG_DEBUG);
91
+        Logger::log(static::class.' extract orders end', LOG_DEBUG);
92 92
     }
93 93
 
94 94
     /**
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @param ModelCriteria $query
98 98
      */
99
-    protected function addFilters(ModelCriteria &$query)
99
+    protected function addFilters(ModelCriteria & $query)
100 100
     {
101 101
         if (count($this->query) > 0) {
102 102
             $tableMap = $this->getTableMap();
103 103
             foreach ($this->query as $field => $value) {
104 104
                 if (self::API_COMBO_FIELD === $field) {
105 105
                     ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value);
106
-                } elseif(!preg_match('/^__/', $field)) {
106
+                } elseif (!preg_match('/^__/', $field)) {
107 107
                     ApiHelper::addModelField($tableMap, $query, $field, $value);
108 108
                 }
109 109
             }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
             list($page, $limit) = $this->extractPagination();
124 124
             if ($limit === -1) {
125 125
                 $this->list = $query->find($this->con);
126
-            } else {
126
+            }else {
127 127
                 $this->list = $query->paginate($page, $limit, $this->con);
128 128
             }
129 129
             $this->checkReturnFields($this->list->getQuery());
130
-        } catch (\Exception $e) {
130
+        }catch (\Exception $e) {
131 131
             Logger::log($e->getMessage(), LOG_ERR);
132 132
         }
133 133
     }
Please login to merge, or discard this patch.
src/base/types/helpers/AdminHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
         $excluded_modules = explode(',', strtoupper(Config::getParam('hide.modules', '')));
48 48
         foreach ($systemRoutes as $params) {
49 49
             $module = strtoupper($params['module']);
50
-            if(in_array($module, $excluded_modules) && $module !== 'PSFS') {
50
+            if (in_array($module, $excluded_modules) && $module !== 'PSFS') {
51 51
                 continue;
52 52
             }
53 53
             if (isset($params['http']) && Request::VERB_GET === $params['http']
Please login to merge, or discard this patch.
src/base/types/traits/Router/ModulesTrait.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
         if ($files->hasResults()) {
55 55
             foreach ($files->getIterator() as $file) {
56 56
                 if ($namespace !== Router::PSFS_BASE_NAMESPACE && method_exists($file, 'getRelativePathname')) {
57
-                    $filename = '\\' . str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
58
-                } else {
57
+                    $filename = '\\'.str_replace('/', '\\', str_replace($origen, '', $file->getRelativePathname()));
58
+                }else {
59 59
                     $filename = str_replace('/', '\\', str_replace($origen, '', $file->getPathname()));
60 60
                 }
61
-                $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing, $namespace);
61
+                $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing, $namespace);
62 62
             }
63 63
         }
64 64
         $this->initializeFinder();
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             if (!is_array($this->domains)) {
112 112
                 $this->domains = [];
113 113
             }
114
-            $domain = '@' . $class->getConstant('DOMAIN') . '/';
114
+            $domain = '@'.$class->getConstant('DOMAIN').'/';
115 115
             if (!array_key_exists($domain, $this->domains)) {
116 116
                 $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain);
117 117
             }
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
     private function loadExternalAutoloader($hydrateRoute, SplFileInfo $modulePath, $externalModulePath, &$routing = [])
139 139
     {
140 140
         $extModule = $modulePath->getBasename();
141
-        $moduleAutoloader = realpath($externalModulePath . DIRECTORY_SEPARATOR . $extModule . DIRECTORY_SEPARATOR . 'autoload.php');
141
+        $moduleAutoloader = realpath($externalModulePath.DIRECTORY_SEPARATOR.$extModule.DIRECTORY_SEPARATOR.'autoload.php');
142 142
         if (file_exists($moduleAutoloader)) {
143 143
             include_once $moduleAutoloader;
144 144
             if ($hydrateRoute) {
145
-                $routing = $this->inspectDir($externalModulePath . DIRECTORY_SEPARATOR . $extModule, '\\' . $extModule, $routing);
145
+                $routing = $this->inspectDir($externalModulePath.DIRECTORY_SEPARATOR.$extModule, '\\'.$extModule, $routing);
146 146
             }
147 147
         }
148 148
     }
@@ -158,18 +158,18 @@  discard block
 block discarded – undo
158 158
         $modulesToIgnore = explode(',', Config::getParam('hide.modules', ''));
159 159
         try {
160 160
             $module = preg_replace('/(\\\|\/)/', DIRECTORY_SEPARATOR, $module);
161
-            $externalModulePath = VENDOR_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'src';
161
+            $externalModulePath = VENDOR_DIR.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'src';
162 162
             if (file_exists($externalModulePath)) {
163 163
                 $externalModule = $this->finder->directories()->in($externalModulePath)->depth(0);
164 164
                 if ($externalModule->hasResults()) {
165 165
                     foreach ($externalModule->getIterator() as $modulePath) {
166
-                        if(!in_array(strtoupper($modulePath->getRelativePathname()), $modulesToIgnore)) {
166
+                        if (!in_array(strtoupper($modulePath->getRelativePathname()), $modulesToIgnore)) {
167 167
                             $this->loadExternalAutoloader($hydrateRoute, $modulePath, $externalModulePath, $routing);
168 168
                         }
169 169
                     }
170 170
                 }
171 171
             }
172
-        } catch (Exception $e) {
172
+        }catch (Exception $e) {
173 173
             Logger::log($e->getMessage(), LOG_WARNING);
174 174
         }
175 175
     }
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
     public function domainExists($domainToCheck) {
182 182
         $exists = false;
183 183
         $domains = array_keys($this->getDomains());
184
-        foreach($domains as $domain) {
184
+        foreach ($domains as $domain) {
185 185
             $cleanDomain = strtolower(str_replace(['@', '/', '\\'], '', $domain));
186
-            if($cleanDomain === strtolower($domainToCheck)) {
186
+            if ($cleanDomain === strtolower($domainToCheck)) {
187 187
                 $exists = true;
188 188
                 break;
189 189
             }
Please login to merge, or discard this patch.
src/base/Router.php 1 patch
Spacing   +24 added lines, -24 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
         }
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
      */
80 80
     private function debugLoad()
81 81
     {
82
-                if(!Config::getParam('skip.route_generation', false)) {
82
+                if (!Config::getParam('skip.route_generation', false)) {
83 83
                     Logger::log('Begin routes load');
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);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      */
270 270
     private function checkPreActions($class, $method)
271 271
     {
272
-        $preAction = 'pre' . ucfirst($method);
272
+        $preAction = 'pre'.ucfirst($method);
273 273
         if (method_exists($class, $preAction)) {
274 274
             Inspector::stats('[Router] Pre action invoked', Inspector::SCOPE_DEBUG);
275 275
             try {
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                     Logger::log(t('Pre action failed'), LOG_ERR, [error_get_last()]);
278 278
                     error_clear_last();
279 279
                 }
280
-            } catch (Exception $e) {
280
+            }catch (Exception $e) {
281 281
                 Logger::log($e->getMessage(), LOG_ERR, [$class, $method]);
282 282
             }
283 283
         }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
      */
295 295
     protected function executeCachedRoute($route, $action, $class, $params = NULL)
296 296
     {
297
-        Inspector::stats('[Router] Executing route ' . $route, Inspector::SCOPE_DEBUG);
297
+        Inspector::stats('[Router] Executing route '.$route, Inspector::SCOPE_DEBUG);
298 298
         $action['params'] = array_merge($action['params'], $params, Request::getInstance()->getQueryParams());
299 299
         Security::getInstance()->setSessionKey(Cache::CACHE_SESSION_VAR, $action);
300 300
         $cache = Cache::needCache();
@@ -302,15 +302,15 @@  discard block
 block discarded – undo
302 302
         $return = null;
303 303
         if (FALSE !== $cache && $action['http'] === 'GET' && Config::getParam('debug') === FALSE) {
304 304
             list($path, $cacheDataName) = $this->cache->getRequestCacheHash();
305
-            $cachedData = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $cache);
305
+            $cachedData = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $cache);
306 306
             if (NULL !== $cachedData) {
307
-                $headers = $this->cache->readFromCache('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', $cache, null, Cache::JSON);
307
+                $headers = $this->cache->readFromCache('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', $cache, null, Cache::JSON);
308 308
                 Template::getInstance()->renderCache($cachedData, $headers);
309 309
                 $execute = FALSE;
310 310
             }
311 311
         }
312 312
         if ($execute) {
313
-            Inspector::stats('[Router] Start executing action ' . $route, Inspector::SCOPE_DEBUG);
313
+            Inspector::stats('[Router] Start executing action '.$route, Inspector::SCOPE_DEBUG);
314 314
             $this->checkPreActions($class, $action['method']);
315 315
             $return = call_user_func_array([$class, $action['method']], $params);
316 316
             if (false === $return) {
Please login to merge, or discard this patch.
src/base/types/traits/Api/DocumentorHelperTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param true $isArray
30 30
      * @return array
31 31
      */
32
-    public function processPayload(array|string $namespace, bool $isArray): array
32
+    public function processPayload(array | string $namespace, bool $isArray): array
33 33
     {
34 34
         if (false !== strpos($namespace, '[') && false !== strpos($namespace, ']')) {
35 35
             $namespace = str_replace(']', '', str_replace('[', '', $namespace));
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             list($isArray, $payload) = $this->processPayload($namespace, $isArray);
103 103
             $reflector = new ReflectionClass($namespace);
104 104
             $shortName = $reflector->getShortName();
105
-        } else {
105
+        }else {
106 106
             $namespace = $model;
107 107
             $shortName = $model;
108 108
         }
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
                     if ($module === $requestModule && !preg_match('/^ROOT/i', $module)) {
178 178
                         $modules = [
179 179
                             'name' => $module,
180
-                            'path' => realpath(dirname($info['base'] . DIRECTORY_SEPARATOR . '..')),
180
+                            'path' => realpath(dirname($info['base'].DIRECTORY_SEPARATOR.'..')),
181 181
                         ];
182 182
                     }
183
-                } catch (Exception $e) {
183
+                }catch (Exception $e) {
184 184
                     $modules[] = $e->getMessage();
185 185
                 }
186 186
             }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) {
224 224
                 $payload = $this->extractDtoProperties($namespace);
225 225
             }
226
-        } catch (Exception $e) {
226
+        }catch (Exception $e) {
227 227
             Logger::log($e->getMessage(), LOG_ERR);
228 228
         }
229 229
 
Please login to merge, or discard this patch.
src/base/types/helpers/I18nHelper.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
         // TODO check more en locales
45 45
         if (strtolower($locale) === 'en') {
46 46
             $locale = 'en_GB';
47
-        } else {
48
-            $locale = $locale . '_' . strtoupper($locale);
47
+        }else {
48
+            $locale = $locale.'_'.strtoupper($locale);
49 49
         }
50 50
         $defaultLocales = explode(',', Config::getParam('i18n.locales', ''));
51 51
         if (!in_array($locale, array_merge($defaultLocales, self::$langs))) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $translations = array();
65 65
         if (file_exists($absoluteFileName)) {
66 66
             @include($absoluteFileName);
67
-        } else {
67
+        }else {
68 68
             Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE);
69 69
         }
70 70
 
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
     public static function setLocale(string $default = null, string $customKey = null, bool $force = false): void
82 82
     {
83 83
         $locale = $force ? $default : self::extractLocale($default);
84
-        Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG);
84
+        Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG);
85 85
         // Load translations
86
-        putenv("LC_ALL=" . $locale);
86
+        putenv("LC_ALL=".$locale);
87 87
         setlocale(LC_ALL, $locale);
88 88
         // Load the locale path
89
-        $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale';
90
-        Logger::log('Set locale dir ' . $localePath);
89
+        $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale';
90
+        Logger::log('Set locale dir '.$localePath);
91 91
         GeneratorHelper::createDir($localePath);
92 92
         bindtextdomain('translations', $localePath);
93 93
         textdomain('translations');
94 94
         bind_textdomain_codeset('translations', 'UTF-8');
95 95
         Security::getInstance()->setSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY, substr($locale, 0, 2));
96
-        if($force) t('', $customKey, true);
96
+        if ($force) t('', $customKey, true);
97 97
     }
98 98
 
99 99
     /**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'],
154 154
             ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'],
155 155
             ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'],
156
-            ['n', 'N', 'c', 'C',],
156
+            ['n', 'N', 'c', 'C', ],
157 157
         ];
158 158
 
159 159
         $text = htmlspecialchars($string);
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public static function findTranslations(string $path, string $locale): array
175 175
     {
176
-        $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
177
-        $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;
176
+        $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
177
+        $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR;
178 178
 
179 179
         $translations = array();
180 180
         if (file_exists($path)) {
181 181
             $directory = dir($path);
182 182
             while (false !== ($fileName = $directory->read())) {
183 183
                 GeneratorHelper::createDir($localePath);
184
-                if (!file_exists($localePath . 'translations.po')) {
185
-                    file_put_contents($localePath . 'translations.po', '');
184
+                if (!file_exists($localePath.'translations.po')) {
185
+                    file_put_contents($localePath.'translations.po', '');
186 186
                 }
187
-                $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName);
188
-                $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " .
189
-                    $inspectPath . DIRECTORY_SEPARATOR .
187
+                $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName);
188
+                $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ".
189
+                    $inspectPath.DIRECTORY_SEPARATOR.
190 190
                     "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po";
191
-                if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) {
192
-                    $res = t('Revisando directorio: ') . $inspectPath;
193
-                    $res .= t('Comando ejecutado: ') . $cmdPhp;
191
+                if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) {
192
+                    $res = t('Revisando directorio: ').$inspectPath;
193
+                    $res .= t('Comando ejecutado: ').$cmdPhp;
194 194
                     $res .= shell_exec($cmdPhp);
195 195
                     usleep(10);
196 196
                     $translations[] = $res;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,7 +93,9 @@
 block discarded – undo
93 93
         textdomain('translations');
94 94
         bind_textdomain_codeset('translations', 'UTF-8');
95 95
         Security::getInstance()->setSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY, substr($locale, 0, 2));
96
-        if($force) t('', $customKey, true);
96
+        if($force) {
97
+            t('', $customKey, true);
98
+        }
97 99
     }
98 100
 
99 101
     /**
Please login to merge, or discard this patch.
src/base/extension/CustomTranslateExtension.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         // Gather always the base translations
50 50
         $standardTranslations = [];
51
-        self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale . '.json']);
51
+        self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', self::$locale.'.json']);
52 52
         if (file_exists(self::$filename)) {
53 53
             $standardTranslations = json_decode(file_get_contents(self::$filename), true);
54 54
         }
@@ -67,32 +67,32 @@  discard block
 block discarded – undo
67 67
         $session_locale = $session->getSessionKey(I18nHelper::PSFS_SESSION_LANGUAGE_KEY);
68 68
         self::$locale = $forceReload ? $session_locale : I18nHelper::extractLocale($session_locale);
69 69
         $version = $session->getSessionKey(self::LOCALE_CACHED_VERSION);
70
-        $configVersion = self::$locale . '_' . Config::getParam('cache.var', 'v1');
70
+        $configVersion = self::$locale.'_'.Config::getParam('cache.var', 'v1');
71 71
         if ($forceReload) {
72 72
             Inspector::stats('[translationsCheckLoad] Force translations reload', Inspector::SCOPE_DEBUG);
73 73
             self::dropInstance();
74 74
             $version = null;
75 75
             self::$translations = [];
76 76
         }
77
-        if(count(self::$translations) === 0) {
77
+        if (count(self::$translations) === 0) {
78 78
             Inspector::stats('[translationsCheckLoad] Extracting translations', Inspector::SCOPE_DEBUG);
79 79
             self::$generate = (boolean)Config::getParam('i18n.autogenerate', false);
80
-            if(null !== $version && $version === $configVersion) {
80
+            if (null !== $version && $version === $configVersion) {
81 81
                 Inspector::stats('[translationsCheckLoad] Translations loaded from session', Inspector::SCOPE_DEBUG);
82 82
                 self::$translations = $session->getSessionKey(self::LOCALE_CACHED_TAG);
83
-            } else {
83
+            }else {
84 84
                 if (!$useBase) {
85 85
                     $customKey = $customKey ?: $session->getSessionKey(self::CUSTOM_LOCALE_SESSION_KEY);
86 86
                 }
87 87
                 $standardTranslations = self::extractBaseTranslations();
88 88
                 // If the project has custom translations, gather them
89 89
                 if (null !== $customKey) {
90
-                    Logger::log('[' . self::class . '] Custom key detected: ' . $customKey, LOG_INFO);
91
-                    self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale . '.json']);
90
+                    Logger::log('['.self::class.'] Custom key detected: '.$customKey, LOG_INFO);
91
+                    self::$filename = implode(DIRECTORY_SEPARATOR, [LOCALE_DIR, 'custom', $customKey, self::$locale.'.json']);
92 92
                 }
93 93
                 // Finally we merge base and custom translations to complete all the i18n set
94 94
                 if (file_exists(self::$filename)) {
95
-                    Logger::log('[' . self::class . '] Custom locale detected: ' . $customKey . ' [' . self::$locale . ']', LOG_INFO);
95
+                    Logger::log('['.self::class.'] Custom locale detected: '.$customKey.' ['.self::$locale.']', LOG_INFO);
96 96
                     self::$translations = array_merge($standardTranslations, json_decode(file_get_contents(self::$filename), true));
97 97
                     $session->setSessionKey(self::LOCALE_CACHED_TAG, self::$translations);
98 98
                     $session->setSessionKey(self::LOCALE_CACHED_VERSION, $configVersion);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function getFilters()
119 119
     {
120 120
         return array(
121
-            new TwigFilter('trans', function ($message) {
121
+            new TwigFilter('trans', function($message) {
122 122
                 return self::_($message);
123 123
             }),
124 124
         );
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public static function _($message, $customKey = null, $forceReload = false)
142 142
     {
143
-        if(0 === count(self::$translations) || $forceReload) {
143
+        if (0 === count(self::$translations) || $forceReload) {
144 144
             self::translationsCheckLoad($customKey, $forceReload);
145 145
         }
146 146
         if (is_array(self::$translations) && array_key_exists($message, self::$translations)) {
147 147
             $translation = self::$translations[$message];
148
-        } else {
148
+        }else {
149 149
             $translation = gettext($message);
150 150
         }
151 151
         if (self::$generate) {
Please login to merge, or discard this patch.