| @@ -25,7 +25,7 @@ discard block | ||
| 25 | 25 | */ | 
| 26 | 26 | public static function delete(string $filename):bool | 
| 27 | 27 |      { | 
| 28 | -        if (($path=Path::format($filename)) !== null) { | |
| 28 | +        if (($path = Path::format($filename)) !== null) { | |
| 29 | 29 |              if (!is_writable($path)) { | 
| 30 | 30 | return false; | 
| 31 | 31 | } | 
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | */ | 
| 44 | 44 | public static function move(string $src, string $dest):bool | 
| 45 | 45 |      { | 
| 46 | -        if (($path=Path::format($src)) !== null && is_writable(dirname($dest))) { | |
| 46 | +        if (($path = Path::format($src)) !== null && is_writable(dirname($dest))) { | |
| 47 | 47 | return rename($path, $dest); | 
| 48 | 48 | } | 
| 49 | 49 | return false; | 
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | */ | 
| 59 | 59 | public static function copy(string $src, string $dest):bool | 
| 60 | 60 |      { | 
| 61 | -        if (($path=Path::format($src)) !== null && is_writable(dirname($dest))) { | |
| 61 | +        if (($path = Path::format($src)) !== null && is_writable(dirname($dest))) { | |
| 62 | 62 | return copy($path, $dest); | 
| 63 | 63 | } | 
| 64 | 64 | return false; | 
| @@ -86,9 +86,9 @@ discard block | ||
| 86 | 86 | * @param string $name | 
| 87 | 87 | * @return string|null | 
| 88 | 88 | */ | 
| 89 | - public static function get(string $filename):?string | |
| 89 | + public static function get(string $filename): ?string | |
| 90 | 90 |      { | 
| 91 | -        if (is_readable($filename) && ($path=Path::format($filename)) !== null) { | |
| 91 | +        if (is_readable($filename) && ($path = Path::format($filename)) !== null) { | |
| 92 | 92 | return file_get_contents($path); | 
| 93 | 93 | } | 
| 94 | 94 | return null; | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | * @param string $name | 
| 57 | 57 | * @return string|null | 
| 58 | 58 | */ | 
| 59 | - public static function get(string $filename):?string; | |
| 59 | + public static function get(string $filename): ?string; | |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | /** | 
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | * @param boolean $full | 
| 78 | 78 | * @return \Iterator | 
| 79 | 79 | */ | 
| 80 | - public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator; | |
| 80 | + public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator; | |
| 81 | 81 | |
| 82 | 82 | /** | 
| 83 | 83 | * 读目录下文件夹 | 
| @@ -88,7 +88,7 @@ discard block | ||
| 88 | 88 | * @param boolean $full | 
| 89 | 89 | * @return \Iterator | 
| 90 | 90 | */ | 
| 91 | - public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; | |
| 91 | + public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; | |
| 92 | 92 | |
| 93 | 93 | /** | 
| 94 | 94 | * 读目录,包括文件,文件夹 | 
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 | * @param boolean $full | 
| 100 | 100 | * @return \Iterator | 
| 101 | 101 | */ | 
| 102 | - public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; | |
| 102 | + public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; | |
| 103 | 103 | |
| 104 | 104 | /** | 
| 105 | 105 | * 截断部分目录 | 
| @@ -119,7 +119,7 @@ discard block | ||
| 119 | 119 | * @param boolean $move | 
| 120 | 120 | * @return boolean | 
| 121 | 121 | */ | 
| 122 | - public static function copyDir(string $path, string $toPath, ?string $regex=null, bool $move = false):bool; | |
| 122 | + public static function copyDir(string $path, string $toPath, ?string $regex = null, bool $move = false):bool; | |
| 123 | 123 | |
| 124 | 124 | /** | 
| 125 | 125 | * 移动文件夹 | 
| @@ -129,5 +129,5 @@ discard block | ||
| 129 | 129 | * @param string|null $regex | 
| 130 | 130 | * @return boolean | 
| 131 | 131 | */ | 
| 132 | - public static function moveDir(string $path, string $toPath, ?string $regex=null):bool; | |
| 132 | + public static function moveDir(string $path, string $toPath, ?string $regex = null):bool; | |
| 133 | 133 | } | 
| @@ -7,17 +7,17 @@ discard block | ||
| 7 | 7 | */ | 
| 8 | 8 | class PathResolver | 
| 9 | 9 |  { | 
| 10 | - public static function resolve(string $path):?string | |
| 10 | + public static function resolve(string $path): ?string | |
| 11 | 11 |      { | 
| 12 | 12 |          if (file_exists($path)) { | 
| 13 | 13 | return $path; | 
| 14 | 14 | } | 
| 15 | 15 | $basepath = dirname($path).'/'.pathinfo($path, PATHINFO_FILENAME); | 
| 16 | 16 | |
| 17 | - return static::resolveYaml($basepath) ?? static::resolveExtensions($basepath, ['json','php','ini']); | |
| 17 | + return static::resolveYaml($basepath) ?? static::resolveExtensions($basepath, ['json', 'php', 'ini']); | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | - protected static function resolveYaml(string $basepath):?string | |
| 20 | + protected static function resolveYaml(string $basepath): ?string | |
| 21 | 21 |      { | 
| 22 | 22 |          if (file_exists($conf = $basepath.'.yml') || file_exists($conf = $basepath.'.yaml')) { | 
| 23 | 23 |              if (function_exists('yaml_parse') || class_exists('Spyc')) { | 
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | return null; | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | - protected static function resolveExtensions(string $basepath, array $extensions):?string | |
| 30 | + protected static function resolveExtensions(string $basepath, array $extensions): ?string | |
| 31 | 31 |      { | 
| 32 | 32 |          foreach ($extensions as $ext) { | 
| 33 | 33 |              if (file_exists($conf = $basepath.'.'.$ext)) { | 
| @@ -45,13 +45,13 @@ | ||
| 45 | 45 | |
| 46 | 46 | protected static function parseValue(string $content, array $extra = []):string | 
| 47 | 47 |      { | 
| 48 | -        return preg_replace_callback('/\$\{(.+?)\}/', function ($matchs) use ($extra) { | |
| 48 | +        return preg_replace_callback('/\$\{(.+?)\}/', function($matchs) use ($extra) { | |
| 49 | 49 | $name = $matchs[1]; | 
| 50 | 50 |              if (($value = ArrayDotAccess::get($extra, $name, null)) !== null) { | 
| 51 | 51 |              } elseif (defined($name)) { | 
| 52 | 52 | $value = constant($name); | 
| 53 | 53 | } | 
| 54 | - return is_string($value)?trim(json_encode($value), '"'):$value; | |
| 54 | + return is_string($value) ?trim(json_encode($value), '"') : $value; | |
| 55 | 55 | }, $content); | 
| 56 | 56 | } | 
| 57 | 57 | } | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 | |
| 43 | 43 | public function __construct(array $methods, string $uri, array $attribute = []) | 
| 44 | 44 |      { | 
| 45 | -        array_walk($methods, function ($value) { | |
| 45 | +        array_walk($methods, function($value) { | |
| 46 | 46 | return strtoupper($value); | 
| 47 | 47 | }); | 
| 48 | 48 | $this->methods = $methods; | 
| @@ -158,7 +158,7 @@ discard block | ||
| 158 | 158 | * @param Request $request | 
| 159 | 159 | * @return array|null | 
| 160 | 160 | */ | 
| 161 | - public function match(Request $request):?array | |
| 161 | + public function match(Request $request): ?array | |
| 162 | 162 |      { | 
| 163 | 163 |          if (count($this->methods) > 0 && !\in_array($request->getMethod(), $this->methods)) { | 
| 164 | 164 | return null; | 
| @@ -69,7 +69,7 @@ | ||
| 69 | 69 | * @param string $name | 
| 70 | 70 | * @return RouteMatcher|null | 
| 71 | 71 | */ | 
| 72 | - public function get(string $name):?RouteMatcher | |
| 72 | + public function get(string $name): ?RouteMatcher | |
| 73 | 73 |      { | 
| 74 | 74 | return $this->collection[$name] ?? null; | 
| 75 | 75 | } | 
| @@ -10,13 +10,13 @@ | ||
| 10 | 10 |  { | 
| 11 | 11 | public function log($level, string $message, array $context = []) | 
| 12 | 12 |      { | 
| 13 | -        print date('Y-m-d H:i:s') .' ' . $this->interpolate($message, $context) . PHP_EOL; | |
| 13 | +        print date('Y-m-d H:i:s').' '.$this->interpolate($message, $context).PHP_EOL; | |
| 14 | 14 | } | 
| 15 | 15 | public function interpolate(string $message, array $context) | 
| 16 | 16 |      { | 
| 17 | 17 | $replace = []; | 
| 18 | 18 |          foreach ($context as $key => $val) { | 
| 19 | -            $replace['{' . $key . '}'] = $val; | |
| 19 | +            $replace['{'.$key.'}'] = $val; | |
| 20 | 20 | } | 
| 21 | 21 | return strtr($message, $replace); | 
| 22 | 22 | } | 
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | namespace suda\framework\debug; | 
| 3 | 3 | |
| 4 | -interface ConfigInterface  { | |
| 4 | +interface ConfigInterface { | |
| 5 | 5 | public function applyConfig(array $config); | 
| 6 | 6 | } | 
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | } | 
| 21 | 21 |      public function getConfig(string $name) { | 
| 22 | 22 | $defaultConfig = $this->getDefaultConfig(); | 
| 23 | - return $this->config[$name] ?? $defaultConfig[$name];; | |
| 23 | + return $this->config[$name] ?? $defaultConfig[$name]; ; | |
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | 26 | abstract public function getDefaultConfig():array; |