@@ -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> |
@@ -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 | } |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | |
43 | 43 | $stack = debug_backtrace(); |
44 | 44 | foreach ($stack as $item) { |
45 | - if (false !== stripos($item['file'], DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR)) { |
|
46 | - $cacheName = pathinfo($item['file'], PATHINFO_DIRNAME) . '/' . $name; |
|
47 | - $cacheName = explode('Route' . DIRECTORY_SEPARATOR, $cacheName)[1]; |
|
48 | - $cacheName = 'route_' . str_replace(['/', '\\'], '_', $cacheName); |
|
45 | + if (false !== stripos($item['file'], DIRECTORY_SEPARATOR.'Route'.DIRECTORY_SEPARATOR)) { |
|
46 | + $cacheName = pathinfo($item['file'], PATHINFO_DIRNAME).'/'.$name; |
|
47 | + $cacheName = explode('Route'.DIRECTORY_SEPARATOR, $cacheName)[1]; |
|
48 | + $cacheName = 'route_'.str_replace(['/', '\\'], '_', $cacheName); |
|
49 | 49 | break; |
50 | 50 | } |
51 | 51 | } |
52 | 52 | } |
53 | - $cacheName .= '_' . $this->language . '.html.php'; |
|
54 | - $path = $this->packageRoot . '/view/_cache/' . str_replace('/', '_', $cacheName); |
|
53 | + $cacheName .= '_'.$this->language.'.html.php'; |
|
54 | + $path = $this->packageRoot.'/view/_cache/'.str_replace('/', '_', $cacheName); |
|
55 | 55 | |
56 | 56 | if (!$this->cache || !file_exists($path)) { |
57 | - $code = $this->compile($name . '/view.html.php', true, true, true); |
|
57 | + $code = $this->compile($name.'/view.html.php', true, true, true); |
|
58 | 58 | |
59 | 59 | $fh = fopen($path, 'wb'); |
60 | 60 | if (flock($fh, LOCK_EX)) { |
@@ -94,18 +94,18 @@ discard block |
||
94 | 94 | $path = ''; |
95 | 95 | $stack = debug_backtrace(); |
96 | 96 | foreach ($stack as $item) { |
97 | - if (false !== stripos($item['file'], DIRECTORY_SEPARATOR . 'Route' . DIRECTORY_SEPARATOR)) { |
|
98 | - $path = pathinfo($item['file'], PATHINFO_DIRNAME) . '/view.html.php'; |
|
97 | + if (false !== stripos($item['file'], DIRECTORY_SEPARATOR.'Route'.DIRECTORY_SEPARATOR)) { |
|
98 | + $path = pathinfo($item['file'], PATHINFO_DIRNAME).'/view.html.php'; |
|
99 | 99 | if ($processLang) { |
100 | - $storagePath = str_replace('view.html.php', '_lang/' . $this->language . '/data.php', $path); |
|
100 | + $storagePath = str_replace('view.html.php', '_lang/'.$this->language.'/data.php', $path); |
|
101 | 101 | } |
102 | 102 | break; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | } else { |
106 | - $path = $this->packageRoot . '/view/' . $name; |
|
106 | + $path = $this->packageRoot.'/view/'.$name; |
|
107 | 107 | if ($processLang) { |
108 | - $storagePath = str_replace('view.html.php', '', $path) . '_lang/' . $this->language . '/data.php'; |
|
108 | + $storagePath = str_replace('view.html.php', '', $path).'_lang/'.$this->language.'/data.php'; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | foreach ($matchList[1] as $key => $template) { |
139 | 139 | if (!empty($matchList[0][$key]) && false !== strpos($code, $matchList[0][$key])) { |
140 | 140 | $template = trim($template); |
141 | - $code = str_replace($matchList[0][$key], $this->compile($template . '/view.html.php', true, true, false), $code); |
|
141 | + $code = str_replace($matchList[0][$key], $this->compile($template.'/view.html.php', true, true, false), $code); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | preg_match_all('/<!-- extends (.*) -->/', $code, $matchList); |
149 | 149 | if (isset($matchList[1][0])) { |
150 | 150 | $template = trim($matchList[1][0]); |
151 | - $parentHtml = $this->compile($template . '/view.html.php', true, true, false); |
|
151 | + $parentHtml = $this->compile($template.'/view.html.php', true, true, false); |
|
152 | 152 | |
153 | 153 | $code = str_replace($matchList[0][0], '', $code); |
154 | 154 | $parentHtml = str_replace('<!-- section -->', $code, $parentHtml); |