@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function parseRequest() |
65 | 65 | { |
66 | - $argv = $_SERVER[ 'argv' ]; |
|
66 | + $argv = $_SERVER['argv']; |
|
67 | 67 | |
68 | - if ($_SERVER[ 'SCRIPT_NAME' ] === $_SERVER[ 'argv' ][ 0 ]) { |
|
68 | + if ($_SERVER['SCRIPT_NAME'] === $_SERVER['argv'][0]) { |
|
69 | 69 | array_shift($argv); |
70 | 70 | |
71 | 71 | if (empty($argv)) { |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $this->string = str_replace(['/', '\\', ':'], '/', $argv[ 0 ]); |
|
76 | + $this->string = str_replace(['/', '\\', ':'], '/', $argv[0]); |
|
77 | 77 | $this->commands = explode('/', $this->string); |
78 | 78 | |
79 | - if (strpos($this->commands[ 0 ], '--') !== false |
|
80 | - || strpos($this->commands[ 0 ], '-') !== false |
|
79 | + if (strpos($this->commands[0], '--') !== false |
|
80 | + || strpos($this->commands[0], '-') !== false |
|
81 | 81 | ) { |
82 | 82 | $options = $this->commands; |
83 | 83 | $this->commands = []; |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | |
97 | 97 | if (strpos($option, '=') !== false) { |
98 | 98 | $optionParts = explode('=', $option); |
99 | - $option = $optionParts[ 0 ]; |
|
100 | - $value = $optionParts[ 1 ]; |
|
99 | + $option = $optionParts[0]; |
|
100 | + $value = $optionParts[1]; |
|
101 | 101 | } else { |
102 | 102 | $value = current($options); |
103 | 103 | } |
@@ -111,21 +111,21 @@ discard block |
||
111 | 111 | if (strpos($value, '--') === false |
112 | 112 | || strpos($value, '-') === false |
113 | 113 | ) { |
114 | - $_GET[ $option ] = $value; |
|
114 | + $_GET[$option] = $value; |
|
115 | 115 | } else { |
116 | - $_GET[ $option ] = null; |
|
116 | + $_GET[$option] = null; |
|
117 | 117 | } |
118 | 118 | } else { |
119 | 119 | $keys = array_keys($_GET); |
120 | 120 | if (count($keys)) { |
121 | 121 | $key = end($keys); |
122 | - $_GET[ $key ] = $option; |
|
122 | + $_GET[$key] = $option; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | 127 | if (array_key_exists('verbose', $_GET) or array_key_exists('v', $_GET)) { |
128 | - $_ENV[ 'VERBOSE' ] = true; |
|
128 | + $_ENV['VERBOSE'] = true; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->parseCommands($this->commands); |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | |
83 | 83 | if (is_array($lastError)) { |
84 | 84 | $this->errorHandler( |
85 | - $lastError[ 'type' ], |
|
86 | - $lastError[ 'message' ], |
|
87 | - $lastError[ 'file' ], |
|
88 | - $lastError[ 'line' ] |
|
85 | + $lastError['type'], |
|
86 | + $lastError['message'], |
|
87 | + $lastError['file'], |
|
88 | + $lastError['line'] |
|
89 | 89 | ); |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Execute shutdown service |
93 | - if(services()->has('shutdown')) { |
|
93 | + if (services()->has('shutdown')) { |
|
94 | 94 | shutdown()->execute(); |
95 | 95 | } |
96 | 96 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $error = new ErrorException($errstr, $errno, $errfile, $errline); |
135 | 135 | |
136 | 136 | // Logged the error |
137 | - if(services()->has('logger')) { |
|
137 | + if (services()->has('logger')) { |
|
138 | 138 | logger()->error( |
139 | 139 | implode( |
140 | 140 | ' ', |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | $errors = require(str_replace('Cli', 'Config', __DIR__) . DIRECTORY_SEPARATOR . 'Errors.php'); |
371 | 371 | } |
372 | 372 | |
373 | - if (isset($errors[ $code ])) { |
|
374 | - $languageKey = $errors[ $code ]; |
|
373 | + if (isset($errors[$code])) { |
|
374 | + $languageKey = $errors[$code]; |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | $languageKey = strtoupper($code . '_' . $languageKey); |
@@ -383,10 +383,10 @@ discard block |
||
383 | 383 | ]; |
384 | 384 | |
385 | 385 | $this->statusCode = $code; |
386 | - $this->reasonPhrase = $error[ 'title' ]; |
|
386 | + $this->reasonPhrase = $error['title']; |
|
387 | 387 | |
388 | 388 | if (is_string($vars)) { |
389 | - $error[ 'message' ] = $vars; |
|
389 | + $error['message'] = $vars; |
|
390 | 390 | } elseif (is_array($vars)) { |
391 | 391 | $error = array_merge($error, $vars); |
392 | 392 | } |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | $this->write( |
395 | 395 | (new Format()) |
396 | 396 | ->setContextualClass(Format::DANGER) |
397 | - ->setString($error[ 'code' ] . ' - ' . $error[ 'title' ]) |
|
397 | + ->setString($error['code'] . ' - ' . $error['title']) |
|
398 | 398 | ->setNewLinesAfter(1) |
399 | 399 | ); |
400 | 400 | |
401 | 401 | $this->write( |
402 | 402 | (new Format()) |
403 | - ->setString($error[ 'message' ]) |
|
403 | + ->setString($error['message']) |
|
404 | 404 | ->setNewLinesAfter(1) |
405 | 405 | ); |
406 | 406 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function verbose($text, $type = 'stdout') |
421 | 421 | { |
422 | - if (isset($_ENV[ 'VERBOSE' ]) and $_ENV[ 'VERBOSE' ] === true) { |
|
422 | + if (isset($_ENV['VERBOSE']) and $_ENV['VERBOSE'] === true) { |
|
423 | 423 | $this->write($text, $type); |
424 | 424 | } |
425 | 425 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $this->services = new Kernel\Containers\Services(); |
57 | 57 | |
58 | - if (isset($_ENV[ 'DEBUG_STAGE' ]) and $_ENV[ 'DEBUG_STAGE' ] === 'DEVELOPER') { |
|
58 | + if (isset($_ENV['DEBUG_STAGE']) and $_ENV['DEBUG_STAGE'] === 'DEVELOPER') { |
|
59 | 59 | $this->services->load(Gear\Profiler::class); |
60 | 60 | if (profiler() !== false) { |
61 | 61 | profiler()->watch('Starting Kernel Services'); |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function &__get($property) |
149 | 149 | { |
150 | - $get[ $property ] = null; |
|
150 | + $get[$property] = null; |
|
151 | 151 | |
152 | 152 | if (isset($this->{$property})) { |
153 | - $get[ $property ] =& $this->{$property}; |
|
153 | + $get[$property] = & $this->{$property}; |
|
154 | 154 | } elseif ($this->services->has($property)) { |
155 | - $get[ $property ] = $this->services->get($property); |
|
155 | + $get[$property] = $this->services->get($property); |
|
156 | 156 | } |
157 | 157 | |
158 | - return $get[ $property ]; |
|
158 | + return $get[$property]; |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -155,7 +155,7 @@ |
||
155 | 155 | { |
156 | 156 | $arguments = array_values($arguments); |
157 | 157 | array_unshift($arguments, null); |
158 | - unset($arguments[ 0 ]); |
|
158 | + unset($arguments[0]); |
|
159 | 159 | |
160 | 160 | $this->requestMethodArgs = $arguments; |
161 | 161 |
@@ -155,7 +155,7 @@ |
||
155 | 155 | { |
156 | 156 | $arguments = array_values($arguments); |
157 | 157 | array_unshift($arguments, null); |
158 | - unset($arguments[ 0 ]); |
|
158 | + unset($arguments[0]); |
|
159 | 159 | |
160 | 160 | $this->requestMethodArgs = $arguments; |
161 | 161 |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $this->path = $path; |
85 | 85 | $this->closure = $closure; |
86 | 86 | $this->domain = is_null($domain) |
87 | - ? isset($_SERVER[ 'HTTP_HOST' ]) |
|
88 | - ? @$_SERVER[ 'HTTP_HOST' ] |
|
89 | - : @$_SERVER[ 'SERVER_NAME' ] |
|
87 | + ? isset($_SERVER['HTTP_HOST']) |
|
88 | + ? @$_SERVER['HTTP_HOST'] |
|
89 | + : @$_SERVER['SERVER_NAME'] |
|
90 | 90 | : $domain; |
91 | 91 | |
92 | 92 | // Remove www |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | if (preg_match_all("/{(.*)}/", $this->domain, $matches)) { |
98 | - foreach ($matches[ 1 ] as $match) { |
|
98 | + foreach ($matches[1] as $match) { |
|
99 | 99 | $this->closureParameters[] = $match; |
100 | 100 | } |
101 | 101 | } |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function isValidDomain() |
204 | 204 | { |
205 | - $domain = isset($_SERVER[ 'HTTP_HOST' ]) |
|
206 | - ? $_SERVER[ 'HTTP_HOST' ] |
|
207 | - : $_SERVER[ 'SERVER_NAME' ]; |
|
205 | + $domain = isset($_SERVER['HTTP_HOST']) |
|
206 | + ? $_SERVER['HTTP_HOST'] |
|
207 | + : $_SERVER['SERVER_NAME']; |
|
208 | 208 | |
209 | 209 | if ($this->domain === $domain) { |
210 | 210 | return true; |
@@ -243,22 +243,22 @@ discard block |
||
243 | 243 | if (($class = $parameter->getClass()) instanceof \ReflectionClass) { |
244 | 244 | $className = $class->getName(); |
245 | 245 | if (class_exists($className)) { |
246 | - if (isset($matches[ $parameter->name ])) { |
|
247 | - $parameters[ $index ] = new $className($matches[ $parameter->name ]); |
|
246 | + if (isset($matches[$parameter->name])) { |
|
247 | + $parameters[$index] = new $className($matches[$parameter->name]); |
|
248 | 248 | } |
249 | 249 | } |
250 | - } elseif (isset($matches[ $parameter->name ])) { |
|
251 | - $parameters[ $index ] = $matches[ $parameter->name ]; |
|
250 | + } elseif (isset($matches[$parameter->name])) { |
|
251 | + $parameters[$index] = $matches[$parameter->name]; |
|
252 | 252 | } else { |
253 | - $parameters[ $index ] = null; |
|
253 | + $parameters[$index] = null; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } else { |
257 | 257 | foreach ($closure->getParameters() as $index => $parameter) { |
258 | - if (isset($matches[ $index ])) { |
|
259 | - $parameters[ $index ] = $matches[ $index ]; |
|
258 | + if (isset($matches[$index])) { |
|
259 | + $parameters[$index] = $matches[$index]; |
|
260 | 260 | } else { |
261 | - $parameters[ $index ] = null; |
|
261 | + $parameters[$index] = null; |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | $parameters = []; |
311 | 311 | |
312 | 312 | for ($i = 0; $i <= count($pathParts); $i++) { |
313 | - if (isset($pathParts[ $i ]) && isset($stringParts[ $i ])) { |
|
314 | - if ($pathParts[ $i ] == $stringParts[ $i ]) { |
|
315 | - $matches[ $i ] = $stringParts[ $i ]; |
|
313 | + if (isset($pathParts[$i]) && isset($stringParts[$i])) { |
|
314 | + if ($pathParts[$i] == $stringParts[$i]) { |
|
315 | + $matches[$i] = $stringParts[$i]; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | - if (isset($pathParts[ $i ])) { |
|
320 | - if (preg_match("/{(.*)}/", $pathParts[ $i ])) { |
|
321 | - $index = str_replace(['{$', '}'], '', $pathParts[ $i ]); |
|
322 | - $parameters[ $index ] = isset($stringParts[ $i ]) ? $stringParts[ $i ] : null; |
|
319 | + if (isset($pathParts[$i])) { |
|
320 | + if (preg_match("/{(.*)}/", $pathParts[$i])) { |
|
321 | + $index = str_replace(['{$', '}'], '', $pathParts[$i]); |
|
322 | + $parameters[$index] = isset($stringParts[$i]) ? $stringParts[$i] : null; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | |
96 | 96 | if (is_array($lastError)) { |
97 | 97 | $this->errorHandler( |
98 | - $lastError[ 'type' ], |
|
99 | - $lastError[ 'message' ], |
|
100 | - $lastError[ 'file' ], |
|
101 | - $lastError[ 'line' ] |
|
98 | + $lastError['type'], |
|
99 | + $lastError['message'], |
|
100 | + $lastError['file'], |
|
101 | + $lastError['line'] |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | } |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | if (strpos($mimeType, '/') === false) { |
230 | 230 | $extension = ltrim($mimeType, '.'); |
231 | 231 | // Is this extension supported? |
232 | - if (isset($mimes[ $extension ])) { |
|
233 | - $mimeType =& $mimes[ $extension ]; |
|
232 | + if (isset($mimes[$extension])) { |
|
233 | + $mimeType = & $mimes[$extension]; |
|
234 | 234 | if (is_array($mimeType)) { |
235 | 235 | $mimeType = current($mimeType); |
236 | 236 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function addHeader($name, $value) |
262 | 262 | { |
263 | - $this->headers[ $name ] = $value; |
|
263 | + $this->headers[$name] = $value; |
|
264 | 264 | |
265 | 265 | return $this; |
266 | 266 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $reasonPhrase = $this->reasonPhrase; |
280 | 280 | |
281 | 281 | if (is_ajax()) { |
282 | - $contentType = isset($_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ]) ? $_SERVER[ 'HTTP_X_REQUESTED_CONTENT_TYPE' ] : 'application/json'; |
|
282 | + $contentType = isset($_SERVER['HTTP_X_REQUESTED_CONTENT_TYPE']) ? $_SERVER['HTTP_X_REQUESTED_CONTENT_TYPE'] : 'application/json'; |
|
283 | 283 | $this->setContentType($contentType); |
284 | 284 | } |
285 | 285 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | 'status' => (int)$statusCode, |
290 | 290 | 'reason' => $reasonPhrase, |
291 | 291 | 'success' => $statusCode >= 200 && $statusCode < 300 ? true : false, |
292 | - 'message' => isset($data[ 'message' ]) ? $data[ 'message' ] : '', |
|
292 | + 'message' => isset($data['message']) ? $data['message'] : '', |
|
293 | 293 | 'result' => [], |
294 | 294 | ]; |
295 | 295 | |
@@ -299,49 +299,49 @@ discard block |
||
299 | 299 | |
300 | 300 | if (is_array($data) and count($data)) { |
301 | 301 | if (is_numeric(key($data))) { |
302 | - $response[ 'result' ] = $data; |
|
302 | + $response['result'] = $data; |
|
303 | 303 | } elseif (is_string(key($data))) { |
304 | 304 | if (array_key_exists('success', $data)) { |
305 | - $response[ 'success' ] = $data[ 'success' ]; |
|
306 | - unset($data[ 'success' ]); |
|
305 | + $response['success'] = $data['success']; |
|
306 | + unset($data['success']); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | if (array_key_exists('message', $data)) { |
310 | - $response[ 'message' ] = $data[ 'message' ]; |
|
311 | - unset($data[ 'message' ]); |
|
310 | + $response['message'] = $data['message']; |
|
311 | + unset($data['message']); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | if (array_key_exists('timestamp', $data)) { |
315 | - $response[ 'timestamp' ] = $data[ 'timestamp' ]; |
|
316 | - unset($data[ 'timestamp' ]); |
|
315 | + $response['timestamp'] = $data['timestamp']; |
|
316 | + unset($data['timestamp']); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | if (array_key_exists('metadata', $data)) { |
320 | - $response[ 'metadata' ] = $data[ 'metadata' ]; |
|
321 | - unset($data[ 'metadata' ]); |
|
320 | + $response['metadata'] = $data['metadata']; |
|
321 | + unset($data['metadata']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | if (array_key_exists('errors', $data)) { |
325 | - $response[ 'errors' ] = $data[ 'errors' ]; |
|
325 | + $response['errors'] = $data['errors']; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | if (array_key_exists('error', $data)) { |
329 | - $response[ 'error' ] = $data[ 'error' ]; |
|
329 | + $response['error'] = $data['error']; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | if (array_key_exists('data', $data)) { |
333 | - if ($data[ 'data' ] instanceof \ArrayIterator) { |
|
334 | - $data[ 'data' ] = $data[ 'data' ]->getArrayCopy(); |
|
333 | + if ($data['data'] instanceof \ArrayIterator) { |
|
334 | + $data['data'] = $data['data']->getArrayCopy(); |
|
335 | 335 | } |
336 | 336 | |
337 | - if (is_array($data[ 'data' ])) { |
|
338 | - if (is_string(key($data[ 'data' ]))) { |
|
339 | - $response[ 'result' ] = [$data[ 'data' ]]; |
|
340 | - } elseif (is_numeric(key($data[ 'data' ]))) { |
|
341 | - $response[ 'result' ] = $data[ 'data' ]; |
|
337 | + if (is_array($data['data'])) { |
|
338 | + if (is_string(key($data['data']))) { |
|
339 | + $response['result'] = [$data['data']]; |
|
340 | + } elseif (is_numeric(key($data['data']))) { |
|
341 | + $response['result'] = $data['data']; |
|
342 | 342 | } |
343 | 343 | } else { |
344 | - $response[ 'result' ] = [$data[ 'data' ]]; |
|
344 | + $response['result'] = [$data['data']]; |
|
345 | 345 | } |
346 | 346 | } else { |
347 | 347 | $response['result'] = $data; |
@@ -349,32 +349,32 @@ discard block |
||
349 | 349 | } |
350 | 350 | } elseif (is_object($data)) { |
351 | 351 | if (isset($data->success)) { |
352 | - $response[ 'success' ] = $data->success; |
|
352 | + $response['success'] = $data->success; |
|
353 | 353 | unset($data->success); |
354 | 354 | } |
355 | 355 | |
356 | 356 | if (isset($data->message)) { |
357 | - $response[ 'message' ] = $data->message; |
|
357 | + $response['message'] = $data->message; |
|
358 | 358 | unset($data->message); |
359 | 359 | } |
360 | 360 | |
361 | 361 | if (isset($data->timestamp)) { |
362 | - $response[ 'timestamp' ] = $data->timestamp; |
|
362 | + $response['timestamp'] = $data->timestamp; |
|
363 | 363 | unset($data->timestamp); |
364 | 364 | } |
365 | 365 | |
366 | 366 | if (isset($data->metadata)) { |
367 | - $response[ 'metadata' ] = $data->metadata; |
|
367 | + $response['metadata'] = $data->metadata; |
|
368 | 368 | unset($data->metadata); |
369 | 369 | } |
370 | 370 | |
371 | 371 | if (isset($data->errors)) { |
372 | - $response[ 'errors' ] = $data->errors; |
|
372 | + $response['errors'] = $data->errors; |
|
373 | 373 | unset($data->errors); |
374 | 374 | } |
375 | 375 | |
376 | 376 | if (isset($data->error)) { |
377 | - $response[ 'error' ] = $data->error; |
|
377 | + $response['error'] = $data->error; |
|
378 | 378 | unset($data->error); |
379 | 379 | } |
380 | 380 | |
@@ -385,12 +385,12 @@ discard block |
||
385 | 385 | |
386 | 386 | if (is_array($data->data)) { |
387 | 387 | if (is_string(key($data->data))) { |
388 | - $response[ 'result' ] = [$data->data]; |
|
388 | + $response['result'] = [$data->data]; |
|
389 | 389 | } elseif (is_numeric(key($data->data))) { |
390 | - $response[ 'result' ] = $data->data; |
|
390 | + $response['result'] = $data->data; |
|
391 | 391 | } |
392 | 392 | } else { |
393 | - $response[ 'result' ] = [$data->data]; |
|
393 | + $response['result'] = [$data->data]; |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | } |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | foreach (headers_list() as $header) { |
418 | 418 | $headerParts = explode(':', $header); |
419 | 419 | $headerParts = array_map('trim', $headerParts); |
420 | - $headers[ $headerParts[ 0 ] ] = $headerParts[ 1 ]; |
|
421 | - header_remove($header[ 0 ]); |
|
420 | + $headers[$headerParts[0]] = $headerParts[1]; |
|
421 | + header_remove($header[0]); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | if (count($headers)) { |
@@ -592,21 +592,21 @@ discard block |
||
592 | 592 | ]; |
593 | 593 | |
594 | 594 | $this->statusCode = $code; |
595 | - $this->reasonPhrase = $error[ 'title' ]; |
|
595 | + $this->reasonPhrase = $error['title']; |
|
596 | 596 | |
597 | 597 | if (is_string($vars)) { |
598 | 598 | $vars = ['message' => $vars]; |
599 | - } elseif (is_array($vars) and empty($vars[ 'message' ])) { |
|
600 | - $vars[ 'message' ] = $error[ 'message' ]; |
|
599 | + } elseif (is_array($vars) and empty($vars['message'])) { |
|
600 | + $vars['message'] = $error['message']; |
|
601 | 601 | } |
602 | 602 | |
603 | - if (isset($vars[ 'message' ])) { |
|
604 | - $error[ 'message' ] = $vars[ 'message' ]; |
|
603 | + if (isset($vars['message'])) { |
|
604 | + $error['message'] = $vars['message']; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | if (is_ajax() or $this->mimeType !== 'text/html') { |
608 | 608 | $this->statusCode = $code; |
609 | - $this->reasonPhrase = $error[ 'title' ]; |
|
609 | + $this->reasonPhrase = $error['title']; |
|
610 | 610 | $this->send($vars); |
611 | 611 | |
612 | 612 | exit(EXIT_ERROR); |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | static $_is_php; |
26 | 26 | $version = (string)$version; |
27 | 27 | |
28 | - if ( ! isset($_is_php[ $version ])) { |
|
29 | - $_is_php[ $version ] = version_compare(PHP_VERSION, $version, '>='); |
|
28 | + if ( ! isset($_is_php[$version])) { |
|
29 | + $_is_php[$version] = version_compare(PHP_VERSION, $version, '>='); |
|
30 | 30 | } |
31 | 31 | |
32 | - return $_is_php[ $version ]; |
|
32 | + return $_is_php[$version]; |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function is_https() |
133 | 133 | { |
134 | - if ( ! empty($_SERVER[ 'HTTPS' ]) && strtolower($_SERVER[ 'HTTPS' ]) !== 'off') { |
|
134 | + if ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
|
135 | 135 | return true; |
136 | - } elseif (isset($_SERVER[ 'HTTP_X_FORWARDED_PROTO' ]) && $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] === 'https') { |
|
136 | + } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
137 | 137 | return true; |
138 | - } elseif ( ! empty($_SERVER[ 'HTTP_FRONT_END_HTTPS' ]) && strtolower( |
|
139 | - $_SERVER[ 'HTTP_FRONT_END_HTTPS' ] |
|
138 | + } elseif ( ! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower( |
|
139 | + $_SERVER['HTTP_FRONT_END_HTTPS'] |
|
140 | 140 | ) !== 'off' |
141 | 141 | ) { |
142 | 142 | return true; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | */ |
175 | 175 | function is_ajax() |
176 | 176 | { |
177 | - return ( ! empty($_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) && strtolower( |
|
178 | - $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] |
|
177 | + return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower( |
|
178 | + $_SERVER['HTTP_X_REQUESTED_WITH'] |
|
179 | 179 | ) === 'xmlhttprequest'); |
180 | 180 | } |
181 | 181 | } |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | // every control character except newline (dec 10), |
202 | 202 | // carriage return (dec 13) and horizontal tab (dec 09) |
203 | 203 | if ($url_encoded) { |
204 | - $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 |
|
205 | - $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 |
|
204 | + $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 |
|
205 | + $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 |
|
206 | 206 | } |
207 | 207 | |
208 | - $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 |
|
208 | + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 |
|
209 | 209 | |
210 | 210 | do { |
211 | 211 | $str = preg_replace($non_displayables, '', $str, -1, $count); |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | $matches_regex = explode('_', $header_key); |
287 | 287 | if (count($matches_regex) > 0 and strlen($header_key) > 2) { |
288 | 288 | foreach ($matches_regex as $match_key => $match_value) { |
289 | - $matches_regex[ $match_key ] = ucfirst($match_value); |
|
289 | + $matches_regex[$match_key] = ucfirst($match_value); |
|
290 | 290 | } |
291 | 291 | $header_key = implode('-', $matches_regex); |
292 | 292 | } |
293 | - $headers[ $header_key ] = $server_value; |
|
293 | + $headers[$header_key] = $server_value; |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | function path_to_url($path) |
311 | 311 | { |
312 | 312 | $path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path); |
313 | - $root_dir = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $_SERVER[ 'DOCUMENT_ROOT' ]); |
|
314 | - $base_dir = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, dirname($_SERVER[ 'SCRIPT_FILENAME' ])); |
|
313 | + $root_dir = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT']); |
|
314 | + $base_dir = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_FILENAME'])); |
|
315 | 315 | |
316 | 316 | $root_dir = rtrim($root_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
317 | 317 | $base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | |
327 | 327 | $base_url = is_https() ? 'https' : 'http'; |
328 | 328 | |
329 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
330 | - $base_url .= '://' . $_SERVER[ 'HTTP_HOST' ]; |
|
331 | - } elseif (isset($_SERVER[ 'SERVER_NAME' ])) { |
|
329 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
330 | + $base_url .= '://' . $_SERVER['HTTP_HOST']; |
|
331 | + } elseif (isset($_SERVER['SERVER_NAME'])) { |
|
332 | 332 | |
333 | 333 | // Add server name |
334 | - $base_url .= '://' . $_SERVER[ 'SERVER_NAME' ]; |
|
334 | + $base_url .= '://' . $_SERVER['SERVER_NAME']; |
|
335 | 335 | |
336 | 336 | // Add server port if needed |
337 | - $base_url .= $_SERVER[ 'SERVER_PORT' ] !== '80' ? ':' . $_SERVER[ 'SERVER_PORT' ] : ''; |
|
337 | + $base_url .= $_SERVER['SERVER_PORT'] !== '80' ? ':' . $_SERVER['SERVER_PORT'] : ''; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // Add base path |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | $base_url = str_replace(DIRECTORY_SEPARATOR, '/', $base_url); |
343 | 343 | $base_url = trim($base_url, '/') . '/'; |
344 | 344 | |
345 | - if(strpos($path, 'resources') !== false && defined('PATH_RESOURCES')) { |
|
345 | + if (strpos($path, 'resources') !== false && defined('PATH_RESOURCES')) { |
|
346 | 346 | $path_url = 'resources' . '/' . str_replace(PATH_RESOURCES, '', $path); |
347 | - } elseif(strpos($path, 'public') !== false && defined('PATH_PUBLIC')) { |
|
347 | + } elseif (strpos($path, 'public') !== false && defined('PATH_PUBLIC')) { |
|
348 | 348 | $path_url = str_replace(PATH_PUBLIC, '', $path); |
349 | - } elseif(strpos($path, 'storage') !== false && defined('PATH_RESOURCES')) { |
|
349 | + } elseif (strpos($path, 'storage') !== false && defined('PATH_RESOURCES')) { |
|
350 | 350 | $path_url = 'storage' . '/' . str_replace(PATH_RESOURCES, '', $path); |
351 | 351 | } else { |
352 | 352 | $path_url = str_replace($base_dir, '', $path); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $segments = explode('\\', $class); |
422 | 422 | |
423 | 423 | if (count($segments) > 1) { |
424 | - if ($segments[ 0 ] === $segments[ 1 ]) { |
|
424 | + if ($segments[0] === $segments[1]) { |
|
425 | 425 | array_shift($segments); |
426 | 426 | } |
427 | 427 | } |
@@ -494,27 +494,27 @@ discard block |
||
494 | 494 | foreach (explode("\n", $raw_headers) as $i => $h) { |
495 | 495 | $h = explode(':', $h, 2); |
496 | 496 | |
497 | - if (isset($h[ 1 ])) { |
|
498 | - if ( ! isset($headers[ $h[ 0 ] ])) { |
|
499 | - $headers[ $h[ 0 ] ] = trim($h[ 1 ]); |
|
500 | - } elseif (is_array($headers[ $h[ 0 ] ])) { |
|
501 | - $headers[ $h[ 0 ] ] = array_merge($headers[ $h[ 0 ] ], [trim($h[ 1 ])]); // [+] |
|
497 | + if (isset($h[1])) { |
|
498 | + if ( ! isset($headers[$h[0]])) { |
|
499 | + $headers[$h[0]] = trim($h[1]); |
|
500 | + } elseif (is_array($headers[$h[0]])) { |
|
501 | + $headers[$h[0]] = array_merge($headers[$h[0]], [trim($h[1])]); // [+] |
|
502 | 502 | } else { |
503 | - $headers[ $h[ 0 ] ] = array_merge([$headers[ $h[ 0 ] ]], [trim($h[ 1 ])]); // [+] |
|
503 | + $headers[$h[0]] = array_merge([$headers[$h[0]]], [trim($h[1])]); // [+] |
|
504 | 504 | } |
505 | 505 | |
506 | - $key = $h[ 0 ]; // [+] |
|
506 | + $key = $h[0]; // [+] |
|
507 | 507 | } else // [+] |
508 | 508 | { // [+] |
509 | - if (substr($h[ 0 ], 0, 1) == "\t") // [+] |
|
509 | + if (substr($h[0], 0, 1) == "\t") // [+] |
|
510 | 510 | { |
511 | - $headers[ $key ] .= "\r\n\t" . trim($h[ 0 ]); |
|
511 | + $headers[$key] .= "\r\n\t" . trim($h[0]); |
|
512 | 512 | } // [+] |
513 | 513 | elseif ( ! $key) // [+] |
514 | 514 | { |
515 | - $headers[ 0 ] = trim($h[ 0 ]); |
|
515 | + $headers[0] = trim($h[0]); |
|
516 | 516 | } |
517 | - trim($h[ 0 ]); // [+] |
|
517 | + trim($h[0]); // [+] |
|
518 | 518 | } // [+] |
519 | 519 | } |
520 | 520 | |
@@ -732,8 +732,8 @@ discard block |
||
732 | 732 | |
733 | 733 | $string = null; |
734 | 734 | |
735 | - if (isset($errors[ $code ])) { |
|
736 | - $string = $errors[ $code ]; |
|
735 | + if (isset($errors[$code])) { |
|
736 | + $string = $errors[$code]; |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | return strtoupper($string); |
@@ -63,7 +63,7 @@ |
||
63 | 63 | $service = new SplServiceRegistry($serviceClassName); |
64 | 64 | } elseif (class_exists($serviceClassName = 'O2System\Kernel\\' . $className)) { |
65 | 65 | $service = new SplServiceRegistry($serviceClassName); |
66 | - } elseif(class_exists($className)) { |
|
66 | + } elseif (class_exists($className)) { |
|
67 | 67 | $service = new SplServiceRegistry($serviceClassName); |
68 | 68 | } |
69 | 69 | } |