@@ -58,7 +58,7 @@ |
||
58 | 58 | if (isset($_SERVER[$key])) { |
59 | 59 | return $_SERVER[$key]; |
60 | 60 | } else { |
61 | - $key = 'HTTP_' . $key; |
|
61 | + $key = 'HTTP_'.$key; |
|
62 | 62 | return $_SERVER[$key] ?? $default; |
63 | 63 | } |
64 | 64 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | |
79 | 79 | // PHP_AUTH_USER/PHP_AUTH_PW |
80 | 80 | if (isset($headers['PHP_AUTH_USER'])) { |
81 | - $headers['AUTHORIZATION'] = 'Basic ' . base64_encode($headers['PHP_AUTH_USER'] . ':' . $headers['PHP_AUTH_PW']); |
|
81 | + $headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']); |
|
82 | 82 | } elseif (isset($headers['PHP_AUTH_DIGEST'])) { |
83 | 83 | $headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST']; |
84 | 84 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | /** |
66 | 66 | * Request URL. |
67 | 67 | */ |
68 | - $this->url = '/' . $url; |
|
68 | + $this->url = '/'.$url; |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Get method. |
@@ -3,11 +3,11 @@ |
||
3 | 3 | * Autoload without composer. |
4 | 4 | */ |
5 | 5 | $srcRoot = dirname(__FILE__); |
6 | -spl_autoload_register(function ($path) use ($srcRoot) { |
|
7 | - $root = rtrim($srcRoot, '/') . '/'; |
|
6 | +spl_autoload_register(function($path) use ($srcRoot) { |
|
7 | + $root = rtrim($srcRoot, '/').'/'; |
|
8 | 8 | $path = str_replace('Pivasic\\Test\\', '', $path); |
9 | 9 | $path = str_replace('Pivasic\\', '', $path); |
10 | - $path = $root . $path . '.php'; |
|
10 | + $path = $root.$path.'.php'; |
|
11 | 11 | if (file_exists($path)) { |
12 | 12 | require_once $path; |
13 | 13 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | throw new FileException(sprintf('Unable to write in the "%s" directory', $directory)); |
84 | 84 | } |
85 | 85 | |
86 | - $target = rtrim($directory, '/\\') . DIRECTORY_SEPARATOR . ('' == $name ? $this->getBasename() : $this->getName($name)); |
|
86 | + $target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.('' == $name ? $this->getBasename() : $this->getName($name)); |
|
87 | 87 | |
88 | 88 | return new self($target, false); |
89 | 89 | } |
@@ -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> |