@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public static function handleFatal() |
| 48 | 48 | { |
| 49 | 49 | $error = error_get_last(); |
| 50 | - if(null !== $error) { |
|
| 50 | + if (null !== $error) { |
|
| 51 | 51 | self::render($error["type"], $error["message"], $error["file"], $error["line"]); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ob_clean(); |
| 80 | 80 | } |
| 81 | 81 | $data = [ |
| 82 | - 'message' => 'From ' . $className . ' ' . $message, |
|
| 82 | + 'message' => 'From '.$className.' '.$message, |
|
| 83 | 83 | 'code' => $code, |
| 84 | 84 | 'file' => $file, |
| 85 | 85 | 'line' => $line, |
@@ -43,20 +43,20 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $stack = debug_backtrace(); |
| 45 | 45 | foreach ($stack as $item) { |
| 46 | - if (false !== stripos($item['file'], DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR)) { |
|
| 47 | - $cacheName = pathinfo($item['file'], PATHINFO_DIRNAME) . '/' . $name; |
|
| 48 | - $cacheName = explode('Route' . DIRECTORY_SEPARATOR, $cacheName)[1]; |
|
| 49 | - $cacheName = 'route_' . str_replace(['/', '\\'], '_', $cacheName); |
|
| 46 | + if (false !== stripos($item['file'], DIRECTORY_SEPARATOR.'Route'.DIRECTORY_SEPARATOR)) { |
|
| 47 | + $cacheName = pathinfo($item['file'], PATHINFO_DIRNAME).'/'.$name; |
|
| 48 | + $cacheName = explode('Route'.DIRECTORY_SEPARATOR, $cacheName)[1]; |
|
| 49 | + $cacheName = 'route_'.str_replace(['/', '\\'], '_', $cacheName); |
|
| 50 | 50 | break; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | - $cacheName .= '_' . $this->language . '.html.php'; |
|
| 55 | - $path = $this->packageRoot . '/view/_cache/' . str_replace('/', '_', $cacheName); |
|
| 54 | + $cacheName .= '_'.$this->language.'.html.php'; |
|
| 55 | + $path = $this->packageRoot.'/view/_cache/'.str_replace('/', '_', $cacheName); |
|
| 56 | 56 | |
| 57 | 57 | $exist = file_exists($path); |
| 58 | 58 | if (!$this->cache || !$exist) { |
| 59 | - $code = $this->compile($name . '/view.html.php', true, true, true); |
|
| 59 | + $code = $this->compile($name.'/view.html.php', true, true, true); |
|
| 60 | 60 | |
| 61 | 61 | $code = preg_replace(['/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'], ['>', '<', '\\1'], $code); |
| 62 | 62 | |
@@ -103,18 +103,18 @@ discard block |
||
| 103 | 103 | $path = ''; |
| 104 | 104 | $stack = debug_backtrace(); |
| 105 | 105 | foreach ($stack as $item) { |
| 106 | - if (false !== stripos($item['file'], DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR)) { |
|
| 107 | - $path = pathinfo($item['file'], PATHINFO_DIRNAME) . '/view.html.php'; |
|
| 106 | + if (false !== stripos($item['file'], DIRECTORY_SEPARATOR.'Route'.DIRECTORY_SEPARATOR)) { |
|
| 107 | + $path = pathinfo($item['file'], PATHINFO_DIRNAME).'/view.html.php'; |
|
| 108 | 108 | if ($processLang) { |
| 109 | - $storagePath = str_replace('view.html.php', '_lang/' . $this->language . '.php', $path); |
|
| 109 | + $storagePath = str_replace('view.html.php', '_lang/'.$this->language.'.php', $path); |
|
| 110 | 110 | } |
| 111 | 111 | break; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } else { |
| 115 | - $path = $this->packageRoot . '/view/' . $name; |
|
| 115 | + $path = $this->packageRoot.'/view/'.$name; |
|
| 116 | 116 | if ($processLang) { |
| 117 | - $storagePath = str_replace('view.html.php', '', $path) . '_lang/' . $this->language . '.php'; |
|
| 117 | + $storagePath = str_replace('view.html.php', '', $path).'_lang/'.$this->language.'.php'; |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | foreach ($matchList[1] as $key => $template) { |
| 163 | 163 | if (!empty($matchList[0][$key]) && false !== strpos($code, $matchList[0][$key])) { |
| 164 | 164 | $template = trim($template); |
| 165 | - $code = str_replace($matchList[0][$key], $this->compile($template . '/view.html.php', true, true, false), $code); |
|
| 165 | + $code = str_replace($matchList[0][$key], $this->compile($template.'/view.html.php', true, true, false), $code); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | preg_match_all('/<!-- extends (.*) -->/', $code, $matchList); |
| 173 | 173 | if (isset($matchList[1][0])) { |
| 174 | 174 | $template = trim($matchList[1][0]); |
| 175 | - $parentHtml = $this->compile($template . '/view.html.php', true, true, false); |
|
| 175 | + $parentHtml = $this->compile($template.'/view.html.php', true, true, false); |
|
| 176 | 176 | |
| 177 | 177 | $code = str_replace($matchList[0][0], '', $code); |
| 178 | 178 | $parentHtml = str_replace('<!-- section -->', $code, $parentHtml); |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $packageRoot = rtrim($packageRoot, '/'); |
| 28 | 28 | $route = preg_replace('/\/\d+/u', '/D', $request->route()); |
| 29 | - $path = $packageRoot . '/Route/' . $route . '/' . $request->method() . '.php'; |
|
| 29 | + $path = $packageRoot.'/Route/'.$route.'/'.$request->method().'.php'; |
|
| 30 | 30 | if (file_exists($path)) { |
| 31 | 31 | require $path; |
| 32 | - $controllerClass = $request->package() . '\\Route_' . str_replace('/', '_', $route) . '\\' . $request->method(); |
|
| 32 | + $controllerClass = $request->package().'\\Route_'.str_replace('/', '_', $route).'\\'.$request->method(); |
|
| 33 | 33 | /** |
| 34 | 34 | * @var BaseController $controller |
| 35 | 35 | */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | throw new RouteException(sprintf('Route: the method "%s" does not exist', $handler)); |
| 51 | 51 | } |
| 52 | 52 | } else { |
| 53 | - throw new RouteException(sprintf('Route: path "%s" does not exist', $request->package() . '/Route/' . $route . '/' . $request->method() . '.php')); |
|
| 53 | + throw new RouteException(sprintf('Route: path "%s" does not exist', $request->package().'/Route/'.$route.'/'.$request->method().'.php')); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | \ No newline at end of file |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function header(string $name, string $value): bool |
| 74 | 74 | { |
| 75 | 75 | if (!empty($name) && !empty($value) && !headers_sent()) { |
| 76 | - header($name . ': ' . $value); |
|
| 76 | + header($name.': '.$value); |
|
| 77 | 77 | return true; |
| 78 | 78 | } |
| 79 | 79 | return false; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $statusTexts = [ |
| 113 | 113 | 100 => 'Continue', |
| 114 | 114 | 101 => 'Switching Protocols', |
| 115 | - 102 => 'Processing', // RFC2518 |
|
| 115 | + 102 => 'Processing', // RFC2518 |
|
| 116 | 116 | 200 => 'OK', |
| 117 | 117 | 201 => 'Created', |
| 118 | 118 | 202 => 'Accepted', |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | 204 => 'No Content', |
| 121 | 121 | 205 => 'Reset Content', |
| 122 | 122 | 206 => 'Partial Content', |
| 123 | - 207 => 'Multi-Status', // RFC4918 |
|
| 124 | - 208 => 'Already Reported', // RFC5842 |
|
| 125 | - 226 => 'IM Used', // RFC3229 |
|
| 123 | + 207 => 'Multi-Status', // RFC4918 |
|
| 124 | + 208 => 'Already Reported', // RFC5842 |
|
| 125 | + 226 => 'IM Used', // RFC3229 |
|
| 126 | 126 | 300 => 'Multiple Choices', |
| 127 | 127 | 301 => 'Moved Permanently', |
| 128 | 128 | 302 => 'Found', |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | 304 => 'Not Modified', |
| 131 | 131 | 305 => 'Use Proxy', |
| 132 | 132 | 307 => 'Temporary Redirect', |
| 133 | - 308 => 'Permanent Redirect', // RFC7238 |
|
| 133 | + 308 => 'Permanent Redirect', // RFC7238 |
|
| 134 | 134 | 400 => 'Bad Request', |
| 135 | 135 | 401 => 'Unauthorized', |
| 136 | 136 | 402 => 'Payment Required', |
@@ -149,26 +149,26 @@ discard block |
||
| 149 | 149 | 415 => 'Unsupported Media Type', |
| 150 | 150 | 416 => 'Range Not Satisfiable', |
| 151 | 151 | 417 => 'Expectation Failed', |
| 152 | - 418 => 'I\'m a teapot', // RFC2324 |
|
| 153 | - 422 => 'Unprocessable Entity', // RFC4918 |
|
| 154 | - 423 => 'Locked', // RFC4918 |
|
| 155 | - 424 => 'Failed Dependency', // RFC4918 |
|
| 156 | - 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
|
| 157 | - 426 => 'Upgrade Required', // RFC2817 |
|
| 158 | - 428 => 'Precondition Required', // RFC6585 |
|
| 159 | - 429 => 'Too Many Requests', // RFC6585 |
|
| 160 | - 431 => 'Request Header Fields Too Large', // RFC6585 |
|
| 152 | + 418 => 'I\'m a teapot', // RFC2324 |
|
| 153 | + 422 => 'Unprocessable Entity', // RFC4918 |
|
| 154 | + 423 => 'Locked', // RFC4918 |
|
| 155 | + 424 => 'Failed Dependency', // RFC4918 |
|
| 156 | + 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
|
| 157 | + 426 => 'Upgrade Required', // RFC2817 |
|
| 158 | + 428 => 'Precondition Required', // RFC6585 |
|
| 159 | + 429 => 'Too Many Requests', // RFC6585 |
|
| 160 | + 431 => 'Request Header Fields Too Large', // RFC6585 |
|
| 161 | 161 | 500 => 'Internal Server Error', |
| 162 | 162 | 501 => 'Not Implemented', |
| 163 | 163 | 502 => 'Bad Gateway', |
| 164 | 164 | 503 => 'Service Unavailable', |
| 165 | 165 | 504 => 'Gateway Timeout', |
| 166 | 166 | 505 => 'HTTP Version Not Supported', |
| 167 | - 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
|
| 168 | - 507 => 'Insufficient Storage', // RFC4918 |
|
| 169 | - 508 => 'Loop Detected', // RFC5842 |
|
| 170 | - 510 => 'Not Extended', // RFC2774 |
|
| 171 | - 511 => 'Network Authentication Required', // RFC6585 |
|
| 167 | + 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
|
| 168 | + 507 => 'Insufficient Storage', // RFC4918 |
|
| 169 | + 508 => 'Loop Detected', // RFC5842 |
|
| 170 | + 510 => 'Not Extended', // RFC2774 |
|
| 171 | + 511 => 'Network Authentication Required', // RFC6585 |
|
| 172 | 172 | ]; |
| 173 | 173 | $statusText = $statusTexts[$statusCode]; |
| 174 | 174 | } |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | $this->is404 = false; |
| 192 | 192 | $server = filter_input_array(INPUT_SERVER); |
| 193 | 193 | if ('' == $url && isset($server['REQUEST_URI'])) { |
| 194 | - $url = '/' . trim($server['REQUEST_URI'], '/'); |
|
| 194 | + $url = '/'.trim($server['REQUEST_URI'], '/'); |
|
| 195 | 195 | preg_match('/^[\\a-zA-Z0-9-\._~:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=%]*$/iD', $url, $match); |
| 196 | 196 | $url = $match[1] ?? ''; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | if (!headers_sent()) { |
| 200 | - header('Location: ' . $url, true, $statusCode); |
|
| 200 | + header('Location: '.$url, true, $statusCode); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | echo sprintf('<!DOCTYPE html> |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __construct(string &$packageRoot, Request &$request) |
| 23 | 23 | { |
| 24 | - $this->packageRoot =& $packageRoot; |
|
| 25 | - $this->request =& $request; |
|
| 24 | + $this->packageRoot = & $packageRoot; |
|
| 25 | + $this->request = & $request; |
|
| 26 | 26 | $this->response = new Response(); |
| 27 | - $this->data['request'] =& $this->request; |
|
| 27 | + $this->data['request'] = & $this->request; |
|
| 28 | 28 | $this->deleteJsonKeys = true; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | protected function setResponse(Response &$response) |
| 59 | 59 | { |
| 60 | - $this->response =& $response; |
|
| 60 | + $this->response = & $response; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | private function deleteArrayKeys(&$arr): array |
| 144 | 144 | { |
| 145 | 145 | $lst = []; |
| 146 | - foreach($arr as $k => $v){ |
|
| 146 | + foreach ($arr as $k => $v) { |
|
| 147 | 147 | if (is_array($v)) { |
| 148 | 148 | $lst[] = $this->deleteArrayKeys($v); |
| 149 | 149 | } else { |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct(string $appRoot) |
| 26 | 26 | { |
| 27 | - $appRoot = rtrim($appRoot, '/') . '/'; |
|
| 27 | + $appRoot = rtrim($appRoot, '/').'/'; |
|
| 28 | 28 | $this->packageRoot = $appRoot; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Register autoload to app/package/$package/src dir's. |
| 32 | 32 | */ |
| 33 | - spl_autoload_register(function ($path) use ($appRoot) { |
|
| 33 | + spl_autoload_register(function($path) use ($appRoot) { |
|
| 34 | 34 | $path = explode('\\', $path); |
| 35 | - array_shift($path); // Vendor |
|
| 36 | - $package = $appRoot . 'package/' . array_shift($path); // Package |
|
| 37 | - $path = $package . '/src/' . implode('/', $path) . '.php'; |
|
| 35 | + array_shift($path); // Vendor |
|
| 36 | + $package = $appRoot.'package/'.array_shift($path); // Package |
|
| 37 | + $path = $package.'/src/'.implode('/', $path).'.php'; |
|
| 38 | 38 | if (file_exists($path)) { |
| 39 | 39 | require_once $path; |
| 40 | 40 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $request = new Request($languageList, $packageList, $url); |
| 58 | 58 | |
| 59 | - $this->packageRoot .= 'package/' . $request->package() . '/'; |
|
| 59 | + $this->packageRoot .= 'package/'.$request->package().'/'; |
|
| 60 | 60 | |
| 61 | 61 | try { |
| 62 | 62 | /** |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * Path to custom router class. |
| 68 | 68 | */ |
| 69 | - $path = $this->packageRoot . 'CustomRoute.php'; |
|
| 69 | + $path = $this->packageRoot.'CustomRoute.php'; |
|
| 70 | 70 | if (file_exists($path)) { |
| 71 | 71 | require $path; |
| 72 | - $route = $request->package() . '\\CustomRoute'; |
|
| 72 | + $route = $request->package().'\\CustomRoute'; |
|
| 73 | 73 | /** |
| 74 | 74 | * @var IRoute $route |
| 75 | 75 | */ |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $this->response->setStatusCode(404); |
| 109 | 109 | $content = '404 Not Found'; |
| 110 | - if (file_exists($this->packageRoot . '/view/404.html.php')) { |
|
| 110 | + if (file_exists($this->packageRoot.'/view/404.html.php')) { |
|
| 111 | 111 | $content = (new Native($this->packageRoot))->getContent('404.html.php'); |
| 112 | 112 | } |
| 113 | 113 | $this->response->setContent($content); |