@@ -59,7 +59,7 @@ |
||
| 59 | 59 | * @return DataAccess |
| 60 | 60 | * @throws ReflectionException |
| 61 | 61 | */ |
| 62 | - public static function new(string $object, ?Middleware $middleware = null):DataAccess |
|
| 62 | + public static function new(string $object, ?Middleware $middleware = null) : DataAccess |
|
| 63 | 63 | { |
| 64 | 64 | return new self($object, $middleware); |
| 65 | 65 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param array|Config $extra |
| 112 | 112 | * @return array|null |
| 113 | 113 | */ |
| 114 | - public static function loadConfig(string $path, $extra = []):?array |
|
| 114 | + public static function loadConfig(string $path, $extra = []): ?array |
|
| 115 | 115 | { |
| 116 | 116 | if (!file_exists($path)) { |
| 117 | 117 | $path = PathResolver::resolve($path); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | if ($path) { |
| 123 | 123 | $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); |
| 124 | - if (in_array($ext, ['yaml','yml','json','php','ini'])) { |
|
| 124 | + if (in_array($ext, ['yaml', 'yml', 'json', 'php', 'ini'])) { |
|
| 125 | 125 | return ContentLoader::{'load'.ucfirst($ext)}($path, $extra); |
| 126 | 126 | } |
| 127 | 127 | return ContentLoader::loadJson($path, $extra); |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * @param boolean $ignoreCase |
| 47 | 47 | * @return array|null |
| 48 | 48 | */ |
| 49 | - public function match(string $url, bool $ignoreCase = true):?array |
|
| 49 | + public function match(string $url, bool $ignoreCase = true): ?array |
|
| 50 | 50 | { |
| 51 | - $match = '#^'. $this->match.'$#'. ($ignoreCase?'i':''); |
|
| 51 | + $match = '#^'.$this->match.'$#'.($ignoreCase ? 'i' : ''); |
|
| 52 | 52 | $parameter = []; |
| 53 | 53 | if (preg_match($match, $url, $parameter, PREG_UNMATCHED_AS_NULL) > 0) { |
| 54 | 54 | return array_slice($parameter, 1); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return $parameters; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function getParameter(string $name):?Parameter |
|
| 82 | + public function getParameter(string $name): ?Parameter |
|
| 83 | 83 | { |
| 84 | 84 | foreach ($this->parameter as $parameter) { |
| 85 | 85 | if ($parameter->getIndexName() === $name) { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param integer $index |
| 130 | 130 | * @return Parameter|null |
| 131 | 131 | */ |
| 132 | - public function getParameterByIndex(int $index):?Parameter |
|
| 132 | + public function getParameterByIndex(int $index): ?Parameter |
|
| 133 | 133 | { |
| 134 | 134 | foreach ($this->parameter as $parameter) { |
| 135 | 135 | if ($parameter->getIndex() === $index) { |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | protected static function valueToString(string $key, $value, int $deep):string |
| 68 | 68 | { |
| 69 | 69 | if (is_string($value) && strlen($value) > static::$dumpStringLength) { |
| 70 | - return $key.'='.json_encode(substr($value, 0, static::$dumpStringLength), JSON_UNESCAPED_UNICODE) .'... ,'; |
|
| 70 | + return $key.'='.json_encode(substr($value, 0, static::$dumpStringLength), JSON_UNESCAPED_UNICODE).'... ,'; |
|
| 71 | 71 | } elseif (is_bool($value)) { |
| 72 | 72 | return $key.'='.($value ? 'true' : 'false').' ,'; |
| 73 | 73 | } else { |
| 74 | - return $key.'='.self::parameterToString($value, $deep - 1) .' ,'; |
|
| 74 | + return $key.'='.self::parameterToString($value, $deep - 1).' ,'; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $argsDump = ''; |
| 120 | 120 | if (!empty($trace['args'])) { |
| 121 | 121 | foreach ($trace['args'] as $arg) { |
| 122 | - $argsDump .= self::parameterToString($arg) .','; |
|
| 122 | + $argsDump .= self::parameterToString($arg).','; |
|
| 123 | 123 | } |
| 124 | 124 | $argsDump = rtrim($argsDump, ','); |
| 125 | 125 | } |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | public static function dumpThrowable(Throwable $e) |
| 131 | 131 | { |
| 132 | - $dump = get_class($e).':'. $e->getMessage() .PHP_EOL; |
|
| 133 | - $dump .= 'At: ' . $e->getFile().':'.$e->getLine().PHP_EOL; |
|
| 132 | + $dump = get_class($e).':'.$e->getMessage().PHP_EOL; |
|
| 133 | + $dump .= 'At: '.$e->getFile().':'.$e->getLine().PHP_EOL; |
|
| 134 | 134 | $dump .= static::dumpTrace($e->getTrace()); |
| 135 | 135 | return $dump; |
| 136 | 136 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | parse_str($query, $this->query); |
| 39 | 39 | } |
| 40 | 40 | $url = parse_url($url, PHP_URL_PATH); |
| 41 | - $this->uri = '/' . trim($url, '\/'); |
|
| 41 | + $this->uri = '/'.trim($url, '\/'); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function getQuery():array |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | if (strpos($url, $indexFile) === 0) { |
| 60 | 60 | // for /index.php/ |
| 61 | - $url = substr($url, strlen($indexFile));// for /index.php?/ |
|
| 61 | + $url = substr($url, strlen($indexFile)); // for /index.php?/ |
|
| 62 | 62 | if (strpos($url, '?/') === 0) { |
| 63 | 63 | $url = ltrim($url, '?'); |
| 64 | 64 | } |
@@ -23,5 +23,5 @@ |
||
| 23 | 23 | /** |
| 24 | 24 | * @return string|null |
| 25 | 25 | */ |
| 26 | - public static function getHomePath():?string; |
|
| 26 | + public static function getHomePath(): ?string; |
|
| 27 | 27 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public static function delete(string $filename):bool |
| 29 | 29 | { |
| 30 | - if (($path=Path::format($filename)) !== null) { |
|
| 30 | + if (($path = Path::format($filename)) !== null) { |
|
| 31 | 31 | if (!is_writable($path)) { |
| 32 | 32 | return false; |
| 33 | 33 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public static function move(string $src, string $dest):bool |
| 47 | 47 | { |
| 48 | - if (($path=Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
| 48 | + if (($path = Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
| 49 | 49 | return rename($path, $dest); |
| 50 | 50 | } |
| 51 | 51 | return false; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public static function copy(string $src, string $dest):bool |
| 62 | 62 | { |
| 63 | - if (($path=Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
| 63 | + if (($path = Path::format($src)) !== null && is_writable(dirname($dest))) { |
|
| 64 | 64 | return copy($path, $dest); |
| 65 | 65 | } |
| 66 | 66 | return false; |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | * @param string $filename |
| 89 | 89 | * @return string|null |
| 90 | 90 | */ |
| 91 | - public static function get(string $filename):?string |
|
| 91 | + public static function get(string $filename): ?string |
|
| 92 | 92 | { |
| 93 | - if (is_readable($filename) && ($path=Path::format($filename)) !== null) { |
|
| 93 | + if (is_readable($filename) && ($path = Path::format($filename)) !== null) { |
|
| 94 | 94 | return file_get_contents($path); |
| 95 | 95 | } |
| 96 | 96 | return null; |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | function suda_panic($error_type, $error_message, $error_code = 500) |
| 3 | 3 | { |
| 4 | - date_default_timezone_set(defined('DEFAULT_TIMEZONE')?constant('DEFAULT_TIMEZONE'):'PRC'); |
|
| 4 | + date_default_timezone_set(defined('DEFAULT_TIMEZONE') ?constant('DEFAULT_TIMEZONE') : 'PRC'); |
|
| 5 | 5 | header('HTTP/1.1 500 Internal Server Error'); |
| 6 | 6 | header('Status:500 Internal Server Error'); |
| 7 | 7 | ob_start(); |
| 8 | 8 | $error_sort_type = strpos($error_type, '\\') === false ? $error_type : substr($error_type, strrpos($error_type, '\\') + 1); |
| 9 | - include __DIR__ .'/error.php'; |
|
| 9 | + include __DIR__.'/error.php'; |
|
| 10 | 10 | header('Content-Type:text/html; charset=UTF-8'); |
| 11 | 11 | header('Content-Length:'.ob_get_length()); |
| 12 | 12 | die(ob_get_clean()); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->method = $method; |
| 61 | 61 | $static = $this->isStatic() ? '->' : '::'; |
| 62 | 62 | $name = is_object($object) ? get_class($object) : $object; |
| 63 | - $this->name = $name . $static . $method; |
|
| 63 | + $this->name = $name.$static.$method; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | if (null === $this->requireFile) { |
| 122 | 122 | $this->requireFile = $requireFile; |
| 123 | - $this->name = $this->name . '@' . $requireFile; |
|
| 123 | + $this->name = $this->name.'@'.$requireFile; |
|
| 124 | 124 | } |
| 125 | 125 | return $this; |
| 126 | 126 | } |