@@ -45,7 +45,7 @@ |
||
45 | 45 | public static function handleFatal() |
46 | 46 | { |
47 | 47 | $error = error_get_last(); |
48 | - if(null !== $error) { |
|
48 | + if (null !== $error) { |
|
49 | 49 | self::render($error["type"], $error["message"], $error["file"], $error["line"]); |
50 | 50 | } |
51 | 51 | } |
@@ -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 | } |
@@ -25,10 +25,10 @@ |
||
25 | 25 | { |
26 | 26 | $packageRoot = rtrim($packageRoot, '/'); |
27 | 27 | $route = preg_replace('/\/\d+/u', '/D', $request->route()); |
28 | - $path = $packageRoot . '/Route/' . $route . '/' . $request->method() . '.php'; |
|
28 | + $path = $packageRoot.'/Route/'.$route.'/'.$request->method().'.php'; |
|
29 | 29 | if (file_exists($path)) { |
30 | 30 | require $path; |
31 | - $controllerClass = $request->package() . '\\Route_' . str_replace('/', '_', $route) . '\\' . $request->method(); |
|
31 | + $controllerClass = $request->package().'\\Route_'.str_replace('/', '_', $route).'\\'.$request->method(); |
|
32 | 32 | /** |
33 | 33 | * @var BaseController $controller |
34 | 34 | */ |
@@ -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. |
@@ -32,7 +32,7 @@ |
||
32 | 32 | /** |
33 | 33 | * Get file content. |
34 | 34 | * |
35 | - * @return string|mixed |
|
35 | + * @return string |
|
36 | 36 | */ |
37 | 37 | public function read() |
38 | 38 | { |
@@ -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 | } |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct(string $appRoot) |
24 | 24 | { |
25 | - $appRoot = rtrim($appRoot, '/') . '/'; |
|
25 | + $appRoot = rtrim($appRoot, '/').'/'; |
|
26 | 26 | $this->packageRoot = $appRoot; |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Register autoload to app/$package/src dir's. |
30 | 30 | */ |
31 | - spl_autoload_register(function ($path) use ($appRoot) { |
|
31 | + spl_autoload_register(function($path) use ($appRoot) { |
|
32 | 32 | $path = explode('\\', $path); |
33 | - array_shift($path); // Vendor |
|
34 | - $package = $appRoot . 'package/' . array_shift($path); // Package |
|
35 | - $path = $package . '/src/' . implode('/', $path) . '.php'; |
|
33 | + array_shift($path); // Vendor |
|
34 | + $package = $appRoot.'package/'.array_shift($path); // Package |
|
35 | + $path = $package.'/src/'.implode('/', $path).'.php'; |
|
36 | 36 | if (file_exists($path)) { |
37 | 37 | require_once $path; |
38 | 38 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $request = new Request($languageList, $packageList, $url); |
55 | 55 | |
56 | - $this->packageRoot .= 'package/' . $request->package() . '/'; |
|
56 | + $this->packageRoot .= 'package/'.$request->package().'/'; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Process request. |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * Path to router class. |
67 | 67 | */ |
68 | - $path = $this->packageRoot . 'CustomRoute.php'; |
|
68 | + $path = $this->packageRoot.'CustomRoute.php'; |
|
69 | 69 | if (file_exists($path)) { |
70 | 70 | require $path; |
71 | 71 | /** |
72 | 72 | * Name of router class. |
73 | 73 | */ |
74 | - $route = $request->package() . '\\CustomRoute'; |
|
74 | + $route = $request->package().'\\CustomRoute'; |
|
75 | 75 | /** |
76 | 76 | * @var IRoute $route |
77 | 77 | */ |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $response->setStatusCode(404); |
99 | 99 | |
100 | 100 | $content = '404 Not Found'; |
101 | - if (file_exists($this->packageRoot . '/view/404.html.php')) { |
|
101 | + if (file_exists($this->packageRoot.'/view/404.html.php')) { |
|
102 | 102 | $content = (new Native($this->packageRoot))->getContent('404.html.php'); |
103 | 103 | } |
104 | 104 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function header(string $name, string $value): bool |
60 | 60 | { |
61 | 61 | if (!empty($name) && !empty($value) && !headers_sent()) { |
62 | - header($name . ': ' . $value); |
|
62 | + header($name.': '.$value); |
|
63 | 63 | return true; |
64 | 64 | } |
65 | 65 | return false; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $statusTexts = [ |
99 | 99 | 100 => 'Continue', |
100 | 100 | 101 => 'Switching Protocols', |
101 | - 102 => 'Processing', // RFC2518 |
|
101 | + 102 => 'Processing', // RFC2518 |
|
102 | 102 | 200 => 'OK', |
103 | 103 | 201 => 'Created', |
104 | 104 | 202 => 'Accepted', |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | 204 => 'No Content', |
107 | 107 | 205 => 'Reset Content', |
108 | 108 | 206 => 'Partial Content', |
109 | - 207 => 'Multi-Status', // RFC4918 |
|
110 | - 208 => 'Already Reported', // RFC5842 |
|
111 | - 226 => 'IM Used', // RFC3229 |
|
109 | + 207 => 'Multi-Status', // RFC4918 |
|
110 | + 208 => 'Already Reported', // RFC5842 |
|
111 | + 226 => 'IM Used', // RFC3229 |
|
112 | 112 | 300 => 'Multiple Choices', |
113 | 113 | 301 => 'Moved Permanently', |
114 | 114 | 302 => 'Found', |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | 304 => 'Not Modified', |
117 | 117 | 305 => 'Use Proxy', |
118 | 118 | 307 => 'Temporary Redirect', |
119 | - 308 => 'Permanent Redirect', // RFC7238 |
|
119 | + 308 => 'Permanent Redirect', // RFC7238 |
|
120 | 120 | 400 => 'Bad Request', |
121 | 121 | 401 => 'Unauthorized', |
122 | 122 | 402 => 'Payment Required', |
@@ -135,26 +135,26 @@ discard block |
||
135 | 135 | 415 => 'Unsupported Media Type', |
136 | 136 | 416 => 'Range Not Satisfiable', |
137 | 137 | 417 => 'Expectation Failed', |
138 | - 418 => 'I\'m a teapot', // RFC2324 |
|
139 | - 422 => 'Unprocessable Entity', // RFC4918 |
|
140 | - 423 => 'Locked', // RFC4918 |
|
141 | - 424 => 'Failed Dependency', // RFC4918 |
|
142 | - 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
|
143 | - 426 => 'Upgrade Required', // RFC2817 |
|
144 | - 428 => 'Precondition Required', // RFC6585 |
|
145 | - 429 => 'Too Many Requests', // RFC6585 |
|
146 | - 431 => 'Request Header Fields Too Large', // RFC6585 |
|
138 | + 418 => 'I\'m a teapot', // RFC2324 |
|
139 | + 422 => 'Unprocessable Entity', // RFC4918 |
|
140 | + 423 => 'Locked', // RFC4918 |
|
141 | + 424 => 'Failed Dependency', // RFC4918 |
|
142 | + 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
|
143 | + 426 => 'Upgrade Required', // RFC2817 |
|
144 | + 428 => 'Precondition Required', // RFC6585 |
|
145 | + 429 => 'Too Many Requests', // RFC6585 |
|
146 | + 431 => 'Request Header Fields Too Large', // RFC6585 |
|
147 | 147 | 500 => 'Internal Server Error', |
148 | 148 | 501 => 'Not Implemented', |
149 | 149 | 502 => 'Bad Gateway', |
150 | 150 | 503 => 'Service Unavailable', |
151 | 151 | 504 => 'Gateway Timeout', |
152 | 152 | 505 => 'HTTP Version Not Supported', |
153 | - 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
|
154 | - 507 => 'Insufficient Storage', // RFC4918 |
|
155 | - 508 => 'Loop Detected', // RFC5842 |
|
156 | - 510 => 'Not Extended', // RFC2774 |
|
157 | - 511 => 'Network Authentication Required', // RFC6585 |
|
153 | + 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
|
154 | + 507 => 'Insufficient Storage', // RFC4918 |
|
155 | + 508 => 'Loop Detected', // RFC5842 |
|
156 | + 510 => 'Not Extended', // RFC2774 |
|
157 | + 511 => 'Network Authentication Required', // RFC6585 |
|
158 | 158 | ]; |
159 | 159 | $statusText = $statusTexts[$statusCode]; |
160 | 160 | } |
@@ -176,13 +176,13 @@ discard block |
||
176 | 176 | { |
177 | 177 | $server = filter_input_array(INPUT_SERVER); |
178 | 178 | if ('' == $url && isset($server['REQUEST_URI'])) { |
179 | - $url = '/' . trim($server['REQUEST_URI'], '/'); |
|
179 | + $url = '/'.trim($server['REQUEST_URI'], '/'); |
|
180 | 180 | preg_match('/^[\\a-zA-Z0-9-\._~:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=%]*$/iD', $url, $match); |
181 | 181 | $url = $match[1] ?? ''; |
182 | 182 | } |
183 | 183 | |
184 | 184 | if (!headers_sent()) { |
185 | - header('Location: ' . $url, true, $statusCode); |
|
185 | + header('Location: '.$url, true, $statusCode); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | echo sprintf('<!DOCTYPE html> |