@@ -25,7 +25,7 @@ |
||
25 | 25 | * @param $className |
26 | 26 | */ |
27 | 27 | spl_autoload_register( |
28 | - function ($className) { |
|
28 | + function($className) { |
|
29 | 29 | if ($className === 'O2System\Kernel') { |
30 | 30 | require __DIR__ . DIRECTORY_SEPARATOR . 'Kernel.php'; |
31 | 31 | } elseif (strpos($className, 'O2System\Kernel\\') === false) { |
@@ -114,24 +114,24 @@ |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | $rules = [ |
117 | - '/^(ox)$/' => '\1\2en', // ox |
|
118 | - '/([m|l])ouse$/' => '\1ice', // mouse, louse |
|
119 | - '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index |
|
120 | - '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address |
|
121 | - '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency |
|
122 | - '/(hive)$/' => '\1s', // archive, hive |
|
123 | - '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife |
|
124 | - '/sis$/' => 'ses', // basis, diagnosis |
|
125 | - '/([ti])um$/' => '\1a', // datum, medium |
|
126 | - '/(p)erson$/' => '\1eople', // person, salesperson |
|
127 | - '/(m)an$/' => '\1en', // man, woman, spokesman |
|
128 | - '/(c)hild$/' => '\1hildren', // child |
|
129 | - '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato |
|
130 | - '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
131 | - '/(alias|status|virus)$/' => '\1es', // alias |
|
132 | - '/(octop)us$/' => '\1i', // octopus |
|
133 | - '/(ax|cris|test)is$/' => '\1es', // axis, crisis |
|
134 | - '/s$/' => 's', // no change (compatibility) |
|
117 | + '/^(ox)$/' => '\1\2en', // ox |
|
118 | + '/([m|l])ouse$/' => '\1ice', // mouse, louse |
|
119 | + '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index |
|
120 | + '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address |
|
121 | + '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency |
|
122 | + '/(hive)$/' => '\1s', // archive, hive |
|
123 | + '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife |
|
124 | + '/sis$/' => 'ses', // basis, diagnosis |
|
125 | + '/([ti])um$/' => '\1a', // datum, medium |
|
126 | + '/(p)erson$/' => '\1eople', // person, salesperson |
|
127 | + '/(m)an$/' => '\1en', // man, woman, spokesman |
|
128 | + '/(c)hild$/' => '\1hildren', // child |
|
129 | + '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato |
|
130 | + '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
131 | + '/(alias|status|virus)$/' => '\1es', // alias |
|
132 | + '/(octop)us$/' => '\1i', // octopus |
|
133 | + '/(ax|cris|test)is$/' => '\1es', // axis, crisis |
|
134 | + '/s$/' => 's', // no change (compatibility) |
|
135 | 135 | '/$/' => 's', |
136 | 136 | ]; |
137 | 137 |
@@ -43,30 +43,30 @@ discard block |
||
43 | 43 | if (is_array($name)) { |
44 | 44 | // always leave 'name' in last place, as the loop will break otherwise, due to $$item |
45 | 45 | foreach (['value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name'] as $item) { |
46 | - if (isset($name[ $item ])) { |
|
47 | - $$item = $name[ $item ]; |
|
46 | + if (isset($name[$item])) { |
|
47 | + $$item = $name[$item]; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | 52 | if ($prefix === '' && function_exists('config')) { |
53 | - $prefix = config()->offsetGet('cookie')[ 'prefix' ]; |
|
53 | + $prefix = config()->offsetGet('cookie')['prefix']; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($domain === '' && function_exists('config')) { |
57 | - $domain = config()->offsetGet('cookie')[ 'domain' ]; |
|
57 | + $domain = config()->offsetGet('cookie')['domain']; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($path === '' && function_exists('config')) { |
61 | - $path = config()->offsetGet('cookie')[ 'path' ]; |
|
61 | + $path = config()->offsetGet('cookie')['path']; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | if ($secure === null && function_exists('config')) { |
65 | - $secure = config()->offsetGet('cookie')[ 'secure' ]; |
|
65 | + $secure = config()->offsetGet('cookie')['secure']; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | if ($httponly === null && function_exists('config')) { |
69 | - $httponly = config()->offsetGet('cookie')[ 'httpOnly' ]; |
|
69 | + $httponly = config()->offsetGet('cookie')['httpOnly']; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if ( ! is_numeric($expire) OR $expire < 0) { |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function get_cookie($name) |
101 | 101 | { |
102 | - if (isset($_COOKIE[ $name ])) { |
|
103 | - return $_COOKIE[ $name ]; |
|
102 | + if (isset($_COOKIE[$name])) { |
|
103 | + return $_COOKIE[$name]; |
|
104 | 104 | } elseif (function_exists('config')) { |
105 | - $prefix = config()->offsetGet('cookie')[ 'prefix' ]; |
|
106 | - if (isset($_COOKIE[ $prefix . $name ])) { |
|
107 | - return $_COOKIE[ $prefix . $name ]; |
|
105 | + $prefix = config()->offsetGet('cookie')['prefix']; |
|
106 | + if (isset($_COOKIE[$prefix . $name])) { |
|
107 | + return $_COOKIE[$prefix . $name]; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | function delete_cookie($name, $domain = '', $path = '/', $prefix = '') |
129 | 129 | { |
130 | 130 | if ($prefix === '' && function_exists('config')) { |
131 | - $prefix = config()->offsetGet('cookie')[ 'prefix' ]; |
|
131 | + $prefix = config()->offsetGet('cookie')['prefix']; |
|
132 | 132 | } |
133 | 133 | |
134 | - if (isset($_COOKIE[ $prefix . $name ])) { |
|
135 | - unset($_COOKIE[ $prefix . $name ]); |
|
134 | + if (isset($_COOKIE[$prefix . $name])) { |
|
135 | + unset($_COOKIE[$prefix . $name]); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return set_cookie($name, '', -1, $domain, $path, $prefix); |
@@ -63,7 +63,7 @@ |
||
63 | 63 | $this->path = PATH_CACHE . 'logs' . DIRECTORY_SEPARATOR; |
64 | 64 | } else { |
65 | 65 | $this->path = dirname( |
66 | - $_SERVER[ 'SCRIPT_FILENAME' ] |
|
66 | + $_SERVER['SCRIPT_FILENAME'] |
|
67 | 67 | ) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR; |
68 | 68 | } |
69 | 69 |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | $args = func_get_args(); |
47 | 47 | |
48 | 48 | if (count($args)) { |
49 | - if (kernel()->services->has($args[ 0 ])) { |
|
50 | - if (isset($args[ 1 ]) and is_array($args[ 1 ])) { |
|
51 | - return kernel()->services->get($args[ 0 ], $args[ 1 ]); |
|
49 | + if (kernel()->services->has($args[0])) { |
|
50 | + if (isset($args[1]) and is_array($args[1])) { |
|
51 | + return kernel()->services->get($args[0], $args[1]); |
|
52 | 52 | } |
53 | 53 | |
54 | - return kernel()->services->get($args[ 0 ]); |
|
54 | + return kernel()->services->get($args[0]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return false; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | if (count($args)) { |
99 | 99 | if (services()->has('language')) { |
100 | - $language =& services()->get('language'); |
|
100 | + $language = & services()->get('language'); |
|
101 | 101 | |
102 | 102 | return call_user_func_array([&$language, 'getLine'], $args); |
103 | 103 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | if (count($args)) { |
127 | 127 | if (services()->has('logger')) { |
128 | - $logger =& services('logger'); |
|
128 | + $logger = & services('logger'); |
|
129 | 129 | |
130 | 130 | return call_user_func_array([&$logger, 'log'], $args); |
131 | 131 | } |
@@ -91,7 +91,7 @@ |
||
91 | 91 | $newValue = []; |
92 | 92 | |
93 | 93 | foreach ($value as $key => $val) { |
94 | - $newValue[ camelcase($key) ] = $val; |
|
94 | + $newValue[camelcase($key)] = $val; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | parent::offsetSet(camelcase($offset), new self($newValue)); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getOption($name, $default = null) |
54 | 54 | { |
55 | - if ( ! isset($this->options[ $name ])) { |
|
55 | + if ( ! isset($this->options[$name])) { |
|
56 | 56 | return $default; |
57 | 57 | } |
58 | 58 | |
59 | - return $this->options[ $name ]; |
|
59 | + return $this->options[$name]; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // ------------------------------------------------------------------------ |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function setOption($name, $value) |
75 | 75 | { |
76 | - $this->options[ $name ] = $value; |
|
76 | + $this->options[$name] = $value; |
|
77 | 77 | |
78 | 78 | return $this; |
79 | 79 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | break; |
65 | 65 | case 'PATH_INFO': |
66 | 66 | default: |
67 | - $this->string = isset($_SERVER[ $protocol ]) |
|
68 | - ? $_SERVER[ $protocol ] |
|
67 | + $this->string = isset($_SERVER[$protocol]) |
|
68 | + ? $_SERVER[$protocol] |
|
69 | 69 | : $this->parseRequestUri(); |
70 | 70 | break; |
71 | 71 | } |
@@ -90,23 +90,23 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function parseRequestUri() |
92 | 92 | { |
93 | - if ( ! isset($_SERVER[ 'REQUEST_URI' ], $_SERVER[ 'SCRIPT_NAME' ])) { |
|
93 | + if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])) { |
|
94 | 94 | return ''; |
95 | 95 | } |
96 | 96 | |
97 | - $uri = parse_url($_SERVER[ 'REQUEST_URI' ]); |
|
98 | - $query = isset($uri[ 'query' ]) |
|
99 | - ? $uri[ 'query' ] |
|
97 | + $uri = parse_url($_SERVER['REQUEST_URI']); |
|
98 | + $query = isset($uri['query']) |
|
99 | + ? $uri['query'] |
|
100 | 100 | : ''; |
101 | - $uri = isset($uri[ 'path' ]) |
|
102 | - ? $uri[ 'path' ] |
|
101 | + $uri = isset($uri['path']) |
|
102 | + ? $uri['path'] |
|
103 | 103 | : ''; |
104 | 104 | |
105 | - if (isset($_SERVER[ 'SCRIPT_NAME' ][ 0 ])) { |
|
106 | - if (strpos($uri, $_SERVER[ 'SCRIPT_NAME' ]) === 0) { |
|
107 | - $uri = (string)substr($uri, strlen($_SERVER[ 'SCRIPT_NAME' ])); |
|
108 | - } elseif (strpos($uri, dirname($_SERVER[ 'SCRIPT_NAME' ])) === 0) { |
|
109 | - $uri = (string)substr($uri, strlen(dirname($_SERVER[ 'SCRIPT_NAME' ]))); |
|
105 | + if (isset($_SERVER['SCRIPT_NAME'][0])) { |
|
106 | + if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0) { |
|
107 | + $uri = (string)substr($uri, strlen($_SERVER['SCRIPT_NAME'])); |
|
108 | + } elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0) { |
|
109 | + $uri = (string)substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME']))); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | // URI is found, and also fixes the QUERY_STRING server var and $_GET array. |
115 | 115 | if (trim($uri, '/') === '' AND strncmp($query, '/', 1) === 0) { |
116 | 116 | $query = explode('?', $query, 2); |
117 | - $uri = $query[ 0 ]; |
|
117 | + $uri = $query[0]; |
|
118 | 118 | |
119 | - $_SERVER[ 'QUERY_STRING' ] = isset($query[ 1 ]) |
|
120 | - ? $query[ 1 ] |
|
119 | + $_SERVER['QUERY_STRING'] = isset($query[1]) |
|
120 | + ? $query[1] |
|
121 | 121 | : ''; |
122 | 122 | } else { |
123 | - $_SERVER[ 'QUERY_STRING' ] = $query; |
|
123 | + $_SERVER['QUERY_STRING'] = $query; |
|
124 | 124 | } |
125 | 125 | |
126 | - parse_str($_SERVER[ 'QUERY_STRING' ], $_GET); |
|
126 | + parse_str($_SERVER['QUERY_STRING'], $_GET); |
|
127 | 127 | |
128 | 128 | if ($uri === '/' || $uri === '') { |
129 | 129 | return '/'; |
@@ -184,21 +184,21 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function parseQueryString() |
186 | 186 | { |
187 | - $uri = isset($_SERVER[ 'QUERY_STRING' ]) |
|
188 | - ? $_SERVER[ 'QUERY_STRING' ] |
|
187 | + $uri = isset($_SERVER['QUERY_STRING']) |
|
188 | + ? $_SERVER['QUERY_STRING'] |
|
189 | 189 | : @getenv('QUERY_STRING'); |
190 | 190 | |
191 | 191 | if (trim($uri, '/') === '') { |
192 | 192 | return ''; |
193 | 193 | } elseif (strncmp($uri, '/', 1) === 0) { |
194 | 194 | $uri = explode('?', $uri, 2); |
195 | - $_SERVER[ 'QUERY_STRING' ] = isset($uri[ 1 ]) |
|
196 | - ? $uri[ 1 ] |
|
195 | + $_SERVER['QUERY_STRING'] = isset($uri[1]) |
|
196 | + ? $uri[1] |
|
197 | 197 | : ''; |
198 | - $uri = rawurldecode($uri[ 0 ]); |
|
198 | + $uri = rawurldecode($uri[0]); |
|
199 | 199 | } |
200 | 200 | |
201 | - parse_str($_SERVER[ 'QUERY_STRING' ], $_GET); |
|
201 | + parse_str($_SERVER['QUERY_STRING'], $_GET); |
|
202 | 202 | |
203 | 203 | return $this->removeRelativeDirectory($uri); |
204 | 204 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $validSegments = array_filter($validSegments); |
235 | 235 | array_unshift($validSegments, null); |
236 | 236 | |
237 | - unset($validSegments[ 0 ]); |
|
237 | + unset($validSegments[0]); |
|
238 | 238 | |
239 | 239 | $this->segments = $validSegments; |
240 | 240 | $this->string = implode('/', $this->segments); |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | |
274 | 274 | // Convert programatic characters to entities and return |
275 | 275 | return str_replace( |
276 | - ['$', '(', ')', '%28', '%29', $config->offsetGet('suffix')], // Bad |
|
277 | - ['$', '(', ')', '(', ')', ''], // Good |
|
276 | + ['$', '(', ')', '%28', '%29', $config->offsetGet('suffix')], // Bad |
|
277 | + ['$', '(', ')', '(', ')', ''], // Good |
|
278 | 278 | $segment |
279 | 279 | ); |
280 | 280 | } |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function __construct($string = null) |
96 | 96 | { |
97 | - $this->origin = isset($_SERVER[ 'HTTP_HOST' ]) |
|
98 | - ? $_SERVER[ 'HTTP_HOST' ] |
|
99 | - : $_SERVER[ 'SERVER_NAME' ]; |
|
97 | + $this->origin = isset($_SERVER['HTTP_HOST']) |
|
98 | + ? $_SERVER['HTTP_HOST'] |
|
99 | + : $_SERVER['SERVER_NAME']; |
|
100 | 100 | $this->scheme = is_https() |
101 | 101 | ? 'https' |
102 | 102 | : 'http'; |
103 | 103 | |
104 | - $paths = explode('.php', $_SERVER[ 'PHP_SELF' ]); |
|
105 | - $paths = explode('/', trim($paths[ 0 ], '/')); |
|
104 | + $paths = explode('.php', $_SERVER['PHP_SELF']); |
|
105 | + $paths = explode('/', trim($paths[0], '/')); |
|
106 | 106 | array_pop($paths); |
107 | 107 | |
108 | 108 | $this->path = empty($paths) |
@@ -112,26 +112,26 @@ discard block |
||
112 | 112 | if (isset($string)) { |
113 | 113 | $this->string = trim($string, '/'); |
114 | 114 | $metadata = parse_url($string); |
115 | - $metadata[ 'path' ] = empty($metadata[ 'path' ]) |
|
115 | + $metadata['path'] = empty($metadata['path']) |
|
116 | 116 | ? null |
117 | - : $metadata[ 'path' ]; |
|
117 | + : $metadata['path']; |
|
118 | 118 | |
119 | - $this->scheme = empty($metadata[ 'scheme' ]) |
|
119 | + $this->scheme = empty($metadata['scheme']) |
|
120 | 120 | ? $this->scheme |
121 | - : $metadata[ 'scheme' ]; |
|
121 | + : $metadata['scheme']; |
|
122 | 122 | |
123 | - if ($metadata[ 'path' ] === $this->string) { |
|
123 | + if ($metadata['path'] === $this->string) { |
|
124 | 124 | $paths = explode('/', $this->string); |
125 | - $this->origin = $paths[ 0 ]; |
|
125 | + $this->origin = $paths[0]; |
|
126 | 126 | |
127 | 127 | $this->path = implode('/', array_slice($paths, 1)); |
128 | - } elseif (isset($metadata[ 'host' ])) { |
|
129 | - $this->path = trim($metadata[ 'path' ]); |
|
130 | - $this->origin = $metadata[ 'host' ]; |
|
128 | + } elseif (isset($metadata['host'])) { |
|
129 | + $this->path = trim($metadata['path']); |
|
130 | + $this->origin = $metadata['host']; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - $directories = explode('/', str_replace('\\', '/', dirname($_SERVER[ 'SCRIPT_FILENAME' ]))); |
|
134 | + $directories = explode('/', str_replace('\\', '/', dirname($_SERVER['SCRIPT_FILENAME']))); |
|
135 | 135 | $paths = explode('/', $this->path); |
136 | 136 | $paths = array_intersect($paths, $directories); |
137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | if (preg_match('/(:)([0-9]+)/', $this->string, $matches)) { |
146 | - $this->port = $matches[ 2 ]; |
|
146 | + $this->port = $matches[2]; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | if (filter_var($this->origin, FILTER_VALIDATE_IP) !== false) { |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | if ((($ordinalNumber % 100) >= 11) && (($ordinalNumber % 100) <= 13)) { |
195 | 195 | $ordinalKey = $ordinalNumber . 'th'; |
196 | 196 | } else { |
197 | - $ordinalKey = $ordinalNumber . $ordinalEnds[ $ordinalNumber % 10 ]; |
|
197 | + $ordinalKey = $ordinalNumber . $ordinalEnds[$ordinalNumber % 10]; |
|
198 | 198 | } |
199 | 199 | |
200 | - $this->subDomains[ $ordinalKey ] = $subdomain; |
|
200 | + $this->subDomains[$ordinalKey] = $subdomain; |
|
201 | 201 | |
202 | - unset($this->subDomains[ $key ]); |
|
202 | + unset($this->subDomains[$key]); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | foreach ($this->tlds as $key => $tld) { |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | if ((($ordinalNumber % 100) >= 11) && (($ordinalNumber % 100) <= 13)) { |
209 | 209 | $ordinalKey = $ordinalNumber . 'th'; |
210 | 210 | } else { |
211 | - $ordinalKey = $ordinalNumber . $ordinalEnds[ $ordinalNumber % 10 ]; |
|
211 | + $ordinalKey = $ordinalNumber . $ordinalEnds[$ordinalNumber % 10]; |
|
212 | 212 | } |
213 | 213 | |
214 | - $this->tlds[ $ordinalKey ] = $tld; |
|
214 | + $this->tlds[$ordinalKey] = $tld; |
|
215 | 215 | |
216 | - unset($this->tlds[ $key ]); |
|
216 | + unset($this->tlds[$key]); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function getSubDomain($level = '3rd') |
314 | 314 | { |
315 | - if (isset($this->subDomains[ $level ])) { |
|
316 | - return $this->subDomains[ $level ]; |
|
315 | + if (isset($this->subDomains[$level])) { |
|
316 | + return $this->subDomains[$level]; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | return false; |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | { |
357 | 357 | if (is_null($level)) { |
358 | 358 | return implode('.', $this->tlds); |
359 | - } elseif (isset($this->tlds[ $level ])) { |
|
360 | - return $this->tlds[ $level ]; |
|
359 | + } elseif (isset($this->tlds[$level])) { |
|
360 | + return $this->tlds[$level]; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | return false; |