@@ -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 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static function formatSeparator(string $path):string |
| 15 | 15 | { |
| 16 | - return str_replace(['\\','/'], DIRECTORY_SEPARATOR, $path); |
|
| 16 | + return str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | if (static::getHomePath() !== null && strpos($path, '~') === 0) { |
| 85 | 85 | $scheme = ''; |
| 86 | - $subpath = static::getHomePath() .DIRECTORY_SEPARATOR.substr($path, 1); |
|
| 86 | + $subpath = static::getHomePath().DIRECTORY_SEPARATOR.substr($path, 1); |
|
| 87 | 87 | } elseif (strpos($path, '://') !== false) { |
| 88 | 88 | list($scheme, $subpath) = explode('://', $path, 2); |
| 89 | 89 | $scheme .= '://'; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * @return string|null |
| 100 | 100 | */ |
| 101 | - public static function getHomePath():?string |
|
| 101 | + public static function getHomePath(): ?string |
|
| 102 | 102 | { |
| 103 | 103 | if (defined('USER_HOME_PATH')) { |
| 104 | 104 | return constant('USER_HOME_PATH'); |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | class ContentWrapper |
| 22 | 22 | { |
| 23 | 23 | protected $types = [ |
| 24 | - [ JsonContentWrapper::class , ['array', JsonSerializable::class],], |
|
| 25 | - [ HtmlContentWrapper::class , ['boolean', 'integer','double', 'string'],], |
|
| 26 | - [ NullContentWrapper::class , ['NULL'],], |
|
| 27 | - [ FileContentWrapper::class , [SplFileObject::class],], |
|
| 24 | + [JsonContentWrapper::class, ['array', JsonSerializable::class], ], |
|
| 25 | + [HtmlContentWrapper::class, ['boolean', 'integer', 'double', 'string'], ], |
|
| 26 | + [NullContentWrapper::class, ['NULL'], ], |
|
| 27 | + [FileContentWrapper::class, [SplFileObject::class], ], |
|
| 28 | 28 | ]; |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public static function isTypeOf($data, string $type) : bool |
| 51 | 51 | { |
| 52 | - if (is_object($data) && !in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string','array','NULL'])) { |
|
| 52 | + if (is_object($data) && !in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string', 'array', 'NULL'])) { |
|
| 53 | 53 | $class = new ReflectionClass($data); |
| 54 | 54 | $typeRef = new ReflectionClass($type); |
| 55 | 55 | if ($typeRef->isInterface()) { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param string $name |
| 60 | 60 | * @return string|null |
| 61 | 61 | */ |
| 62 | - public static function get(string $filename):?string; |
|
| 62 | + public static function get(string $filename): ?string; |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param boolean $full |
| 82 | 82 | * @return Iterator |
| 83 | 83 | */ |
| 84 | - public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : Iterator; |
|
| 84 | + public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : Iterator; |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * 读目录下文件夹 |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param boolean $full |
| 93 | 93 | * @return Iterator |
| 94 | 94 | */ |
| 95 | - public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 95 | + public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * 读目录,包括文件,文件夹 |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param boolean $full |
| 104 | 104 | * @return Iterator |
| 105 | 105 | */ |
| 106 | - public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 106 | + public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): Iterator; |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * 截断部分目录 |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param boolean $move |
| 124 | 124 | * @return boolean |
| 125 | 125 | */ |
| 126 | - public static function copyDir(string $path, string $toPath, ?string $regex=null, bool $move = false):bool; |
|
| 126 | + public static function copyDir(string $path, string $toPath, ?string $regex = null, bool $move = false):bool; |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * 移动文件夹 |
@@ -133,5 +133,5 @@ discard block |
||
| 133 | 133 | * @param string|null $regex |
| 134 | 134 | * @return boolean |
| 135 | 135 | */ |
| 136 | - public static function moveDir(string $path, string $toPath, ?string $regex=null):bool; |
|
| 136 | + public static function moveDir(string $path, string $toPath, ?string $regex = null):bool; |
|
| 137 | 137 | } |
@@ -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()); |