Completed
Push — master ( 75d5d0...c9b7ea )
by Mihail
02:29
created
src/Ffcms/Core/App.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -6,11 +6,8 @@
 block discarded – undo
6 6
 use Ffcms\Core\Cache\MemoryObject;
7 7
 use Ffcms\Core\Debug\DebugMeasure;
8 8
 use Ffcms\Core\Debug\Manager as Debug;
9
-use Ffcms\Core\Exception\ForbiddenException;
10
-use Ffcms\Core\Exception\JsonException;
11 9
 use Ffcms\Core\Exception\NativeException;
12 10
 use Ffcms\Core\Exception\NotFoundException;
13
-use Ffcms\Core\Exception\SyntaxException;
14 11
 use Ffcms\Core\Exception\TemplateException;
15 12
 use Ffcms\Core\Helper\Security;
16 13
 use Ffcms\Core\Helper\Type\Obj;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -185,22 +185,22 @@  discard block
 block discarded – undo
185 185
         $html = null;
186 186
         // lets try to get html full content to page render
187 187
         try {
188
-            $this->startMeasure(__METHOD__ . '::callback');
188
+            $this->startMeasure(__METHOD__.'::callback');
189 189
             /** @var \Ffcms\Core\Arch\Controller $callClass */
190 190
             $callClass = null;
191
-            $callMethod = 'action' . self::$Request->getAction();
191
+            $callMethod = 'action'.self::$Request->getAction();
192 192
 
193 193
             // define callback class namespace/name full path
194
-            $cName = (self::$Request->getCallbackAlias() ?? '\Apps\Controller\\' . env_name . '\\' . self::$Request->getController());
194
+            $cName = (self::$Request->getCallbackAlias() ?? '\Apps\Controller\\'.env_name.'\\'.self::$Request->getController());
195 195
             if (!class_exists($cName))
196
-                throw new NotFoundException('Callback class not found: ' . App::$Security->strip_tags($cName));
196
+                throw new NotFoundException('Callback class not found: '.App::$Security->strip_tags($cName));
197 197
 
198 198
             $callClass = new $cName;
199 199
             // check if callback method (action) is exist in class object
200 200
             if (!method_exists($callClass, $callMethod))
201
-                throw new NotFoundException('Method "' . App::$Security->strip_tags($callMethod) . '()" not founded in "' . get_class($callClass) . '"');
201
+                throw new NotFoundException('Method "'.App::$Security->strip_tags($callMethod).'()" not founded in "'.get_class($callClass).'"');
202 202
 
203
-            $this->stopMeasure(__METHOD__ . '::callback');
203
+            $this->stopMeasure(__METHOD__.'::callback');
204 204
             $params = [];
205 205
             if (!Str::likeEmpty(self::$Request->getID())) {
206 206
                 $params[] = self::$Request->getID();
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
                     'current' => count($params)
225 225
                 ]));
226 226
 
227
-            $this->startMeasure($cName . '::' . $callMethod);
227
+            $this->startMeasure($cName.'::'.$callMethod);
228 228
             // make callback call to action in controller and get response
229 229
             $actionResponse = call_user_func_array([$callClass, $callMethod], $params);
230
-            $this->stopMeasure($cName . '::' . $callMethod);
230
+            $this->stopMeasure($cName.'::'.$callMethod);
231 231
 
232 232
             // set response to controller attribute
233 233
             if (!Str::likeEmpty($actionResponse))
Please login to merge, or discard this patch.
Braces   +23 added lines, -15 removed lines patch added patch discarded remove patch
@@ -192,20 +192,23 @@  discard block
 block discarded – undo
192 192
 
193 193
             // define callback class namespace/name full path
194 194
             $cName = (self::$Request->getCallbackAlias() ?? '\Apps\Controller\\' . env_name . '\\' . self::$Request->getController());
195
-            if (!class_exists($cName))
196
-                throw new NotFoundException('Callback class not found: ' . App::$Security->strip_tags($cName));
195
+            if (!class_exists($cName)) {
196
+                            throw new NotFoundException('Callback class not found: ' . App::$Security->strip_tags($cName));
197
+            }
197 198
 
198 199
             $callClass = new $cName;
199 200
             // check if callback method (action) is exist in class object
200
-            if (!method_exists($callClass, $callMethod))
201
-                throw new NotFoundException('Method "' . App::$Security->strip_tags($callMethod) . '()" not founded in "' . get_class($callClass) . '"');
201
+            if (!method_exists($callClass, $callMethod)) {
202
+                            throw new NotFoundException('Method "' . App::$Security->strip_tags($callMethod) . '()" not founded in "' . get_class($callClass) . '"');
203
+            }
202 204
 
203 205
             $this->stopMeasure(__METHOD__ . '::callback');
204 206
             $params = [];
205 207
             if (!Str::likeEmpty(self::$Request->getID())) {
206 208
                 $params[] = self::$Request->getID();
207
-                if (!Str::likeEmpty(self::$Request->getAdd()))
208
-                    $params[] = self::$Request->getAdd();
209
+                if (!Str::likeEmpty(self::$Request->getAdd())) {
210
+                                    $params[] = self::$Request->getAdd();
211
+                }
209 212
             }
210 213
 
211 214
             // get instance of callback object (class::method) as reflection
@@ -213,16 +216,18 @@  discard block
 block discarded – undo
213 216
             $argCount = 0;
214 217
             // calculate method defined arguments count
215 218
             foreach ($instance->getParameters() as $arg) {
216
-                if (!$arg->isOptional())
217
-                    $argCount++;
219
+                if (!$arg->isOptional()) {
220
+                                    $argCount++;
221
+                }
218 222
             }
219 223
             // compare method arg count with passed
220
-            if (count($params) < $argCount)
221
-                throw new NotFoundException(__('Arguments for method %method% is not enough. Expected: %required%, got: %current%.', [
224
+            if (count($params) < $argCount) {
225
+                            throw new NotFoundException(__('Arguments for method %method% is not enough. Expected: %required%, got: %current%.', [
222 226
                     'method' => $callMethod,
223 227
                     'required' => $argCount,
224 228
                     'current' => count($params)
225 229
                 ]));
230
+            }
226 231
 
227 232
             $this->startMeasure($cName . '::' . $callMethod);
228 233
             // make callback call to action in controller and get response
@@ -230,17 +235,20 @@  discard block
 block discarded – undo
230 235
             $this->stopMeasure($cName . '::' . $callMethod);
231 236
 
232 237
             // set response to controller attribute
233
-            if (!Str::likeEmpty($actionResponse))
234
-                $callClass->setOutput($actionResponse);
238
+            if (!Str::likeEmpty($actionResponse)) {
239
+                            $callClass->setOutput($actionResponse);
240
+            }
235 241
 
236 242
             // build full compiled output html data with default layout and widgets
237 243
             $html = $callClass->buildOutput();
238 244
         } catch (\Exception $e) {
239 245
             // check if exception is system-based throw
240
-            if ($e instanceof TemplateException)
241
-                $html = $e->display();
242
-            else // or hook exception to system based :)))
246
+            if ($e instanceof TemplateException) {
247
+                            $html = $e->display();
248
+            } else {
249
+                // or hook exception to system based :)))
243 250
                 $html = (new NativeException($e->getMessage()))->display();
251
+            }
244 252
         }
245 253
 
246 254
         // set full rendered content to response builder
Please login to merge, or discard this patch.
src/Ffcms/Core/Exception/TemplateException.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,9 @@
 block discarded – undo
36 36
         }
37 37
         
38 38
         // add notification in debug bar if exist
39
-        if (App::$Debug !== null)
40
-            App::$Debug->addException($this);
39
+        if (App::$Debug !== null) {
40
+                    App::$Debug->addException($this);
41
+        }
41 42
 
42 43
         // return rendered result
43 44
         return $this->buildFakePage();
Please login to merge, or discard this patch.
src/Ffcms/Core/Network/Request.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
         $basePath = trim(App::$Properties->get('basePath'), '/');
62 62
         if ($basePath !== null && Str::length($basePath) > 0) {
63
-            $basePath = '/' . $basePath;
63
+            $basePath = '/'.$basePath;
64 64
         }
65 65
 
66 66
         if (!defined('env_no_uri') || env_no_uri === false) {
67
-            $basePath .= '/' . strtolower(env_name);
67
+            $basePath .= '/'.strtolower(env_name);
68 68
         }
69 69
 
70 70
         // we never try to use path's without friendly url's
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             } else {
91 91
                 // try to find language in pathway
92 92
                 foreach (App::$Properties->get('languages') as $lang) {
93
-                    if (Str::startsWith('/' . $lang, $this->getPathInfo())) {
93
+                    if (Str::startsWith('/'.$lang, $this->getPathInfo())) {
94 94
                         $this->language = $lang;
95 95
                         $this->languageInPath = true;
96 96
                     }
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
                     // parse query string
118 118
                     $queryString = null;
119 119
                     if (count($this->query->all()) > 0) {
120
-                        $queryString = '?' . http_build_query($this->query->all());
120
+                        $queryString = '?'.http_build_query($this->query->all());
121 121
                     }
122 122
 
123 123
                     // build response with redirect to language-based path
124
-                    $response = new Redirect($this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString);
124
+                    $response = new Redirect($this->getSchemeAndHttpHost().$this->basePath.'/'.$userLang.$this->getPathInfo().$queryString);
125 125
                     $response->send();
126 126
                     exit();
127 127
                 }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         if (array_key_exists($pathway, $routing['Redirect'])) {
181 181
             $target = $this->getSchemeAndHttpHost(); // . $this->getBasePath() . '/' . rtrim($routing['Redirect'][$pathway], '/');
182 182
             if ($this->getBasePath() !== null && !Str::likeEmpty($this->getBasePath())) {
183
-                $target .= '/' . $this->getBasePath();
183
+                $target .= '/'.$this->getBasePath();
184 184
             }
185 185
             $target .= rtrim($routing['Redirect'][$pathway], '/');
186 186
             $redirect = new Redirect($target);
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
             // find "new path" as binding uri slug
207 207
             $binding = array_search($pathway, $map, true);
208 208
             // build url to redirection
209
-            $url = $this->getSchemeAndHttpHost() . $this->getBasePath() . '/';
209
+            $url = $this->getSchemeAndHttpHost().$this->getBasePath().'/';
210 210
             if (App::$Properties->get('multiLanguage')) {
211
-                $url .= $this->language . '/';
211
+                $url .= $this->language.'/';
212 212
             }
213 213
             $url .= ltrim($binding, '/');
214 214
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     {
303 303
         $route = $this->languageInPath ? Str::sub(parent::getPathInfo(), Str::length($this->language) + 1) : parent::getPathInfo();
304 304
         if (!Str::startsWith('/', $route))
305
-            $route = '/' . $route;
305
+            $route = '/'.$route;
306 306
         return $route;
307 307
     }
308 308
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
      */
467 467
     public function getFullUrl(): string
468 468
     {
469
-        return $this->getSchemeAndHttpHost() . $this->getRequestUri();
469
+        return $this->getSchemeAndHttpHost().$this->getRequestUri();
470 470
     }
471 471
 
472 472
     /**
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -301,8 +301,9 @@  discard block
 block discarded – undo
301 301
     public function getPathInfo()
302 302
     {
303 303
         $route = $this->languageInPath ? Str::sub(parent::getPathInfo(), Str::length($this->language) + 1) : parent::getPathInfo();
304
-        if (!Str::startsWith('/', $route))
305
-            $route = '/' . $route;
304
+        if (!Str::startsWith('/', $route)) {
305
+                    $route = '/' . $route;
306
+        }
306 307
         return $route;
307 308
     }
308 309
 
@@ -445,8 +446,9 @@  discard block
 block discarded – undo
445 446
     public function getPathWithoutControllerAction(): ?string
446 447
     {
447 448
         $path = trim($this->getPathInfo(), '/');
448
-        if ($this->aliasPathTarget !== null)
449
-            $path = trim($this->aliasPathTarget, '/');
449
+        if ($this->aliasPathTarget !== null) {
450
+                    $path = trim($this->aliasPathTarget, '/');
451
+        }
450 452
 
451 453
         $pathArray = explode('/', $path);
452 454
         if ($pathArray[0] === Str::lowerCase($this->getController())) {
Please login to merge, or discard this patch.