@@ -8,7 +8,7 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | interface DumpInterface |
| 10 | 10 | { |
| 11 | - public static function parameterToString($object, int $deep=2); |
|
| 11 | + public static function parameterToString($object, int $deep = 2); |
|
| 12 | 12 | public static function dumpThrowable(Throwable $e); |
| 13 | - public static function dumpTrace(array $backtrace, bool $str=true, string $perfix=''); |
|
| 13 | + public static function dumpTrace(array $backtrace, bool $str = true, string $perfix = ''); |
|
| 14 | 14 | } |
@@ -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 | } |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | * @param string $path 目标路径 |
| 17 | 17 | * @return string|null 返回格式化结果,如果路径不存在则返回NULL |
| 18 | 18 | */ |
| 19 | - public static function format(string $path):?string |
|
| 19 | + public static function format(string $path): ?string |
|
| 20 | 20 | { |
| 21 | - return static::existCharset($path, ['GBK','GB2312','BIG5']); |
|
| 21 | + return static::existCharset($path, ['GBK', 'GB2312', 'BIG5']); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param array $charset |
| 27 | 27 | * @return string|null |
| 28 | 28 | */ |
| 29 | - public static function existCharset(string $path, array $charset):?string |
|
| 29 | + public static function existCharset(string $path, array $charset): ?string |
|
| 30 | 30 | { |
| 31 | 31 | $abspath = static::toAbsolutePath($path); |
| 32 | 32 | if (static::existCase($abspath)) { |
@@ -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 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param string $filename |
| 62 | 62 | * @return string|null |
| 63 | 63 | */ |
| 64 | - public static function get(string $filename):?string; |
|
| 64 | + public static function get(string $filename): ?string; |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param int $mode |
| 85 | 85 | * @return Iterator |
| 86 | 86 | */ |
| 87 | - public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : Iterator; |
|
| 87 | + public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : Iterator; |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * 读目录下文件夹 |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param int $mode |
| 97 | 97 | * @return Iterator |
| 98 | 98 | */ |
| 99 | - public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 99 | + public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * 读目录,包括文件,文件夹 |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param int $mode |
| 109 | 109 | * @return Iterator |
| 110 | 110 | */ |
| 111 | - public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 111 | + public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * 截断部分目录 |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param boolean $move |
| 129 | 129 | * @return boolean |
| 130 | 130 | */ |
| 131 | - public static function copyDir(string $path, string $toPath, ?string $regex=null, bool $move = false):bool; |
|
| 131 | + public static function copyDir(string $path, string $toPath, ?string $regex = null, bool $move = false):bool; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * 移动文件夹 |
@@ -138,5 +138,5 @@ discard block |
||
| 138 | 138 | * @param string|null $regex |
| 139 | 139 | * @return boolean |
| 140 | 140 | */ |
| 141 | - public static function moveDir(string $path, string $toPath, ?string $regex=null):bool; |
|
| 141 | + public static function moveDir(string $path, string $toPath, ?string $regex = null):bool; |
|
| 142 | 142 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | // 任意变量名: 中文点下划线英文数字 |
| 16 | 16 | $code = preg_replace_callback( |
| 17 | 17 | '/\B[$](\?)?[:]([.\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )?/ux', |
| 18 | - [$this,'echoValueCallback'], |
|
| 18 | + [$this, 'echoValueCallback'], |
|
| 19 | 19 | $var |
| 20 | 20 | ); |
| 21 | 21 | $error = preg_last_error(); |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | protected function echoValueCallback($matchs) |
| 29 | 29 | { |
| 30 | - $name=$matchs[2]; |
|
| 31 | - if ($matchs[1]==='?') { |
|
| 30 | + $name = $matchs[2]; |
|
| 31 | + if ($matchs[1] === '?') { |
|
| 32 | 32 | return '$this->has("'.$name.'")'; |
| 33 | 33 | } |
| 34 | 34 | if (isset($matchs[4])) { |
| 35 | 35 | if (preg_match('/\((.+)\)/', $matchs[4], $v)) { |
| 36 | 36 | $args = trim($v[1]); |
| 37 | - $args= strlen($args) ?','.$args:''; |
|
| 37 | + $args = strlen($args) ? ','.$args : ''; |
|
| 38 | 38 | return '$this->get("'.$name.'"'.$args.')'; |
| 39 | 39 | } |
| 40 | 40 | } |