@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | protected function analyse(array $context) |
| 24 | 24 | { |
| 25 | 25 | $replace = []; |
| 26 | - $attach = [] ; |
|
| 26 | + $attach = []; |
|
| 27 | 27 | foreach ($context as $key => $val) { |
| 28 | 28 | if ($this->isReplacedObj($val)) { |
| 29 | - $replace['{' . $key . '}'] = $val; |
|
| 29 | + $replace['{'.$key.'}'] = $val; |
|
| 30 | 30 | } else { |
| 31 | 31 | $attach[$key] = $val; |
| 32 | 32 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | protected function isReplacedObj($val) : bool |
| 38 | 38 | { |
| 39 | - return !is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && ! $val instanceof Throwable; |
|
| 39 | + return !is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && !$val instanceof Throwable; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function interpolate(string $message, array $context, array $attribute) |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | list($attach, $replace) = $this->analyse($context); |
| 45 | 45 | $attribute = array_merge($this->attribute, $attribute); |
| 46 | 46 | foreach ($attribute as $key => $val) { |
| 47 | - $replace['%' . $key . '%'] = $val; |
|
| 47 | + $replace['%'.$key.'%'] = $val; |
|
| 48 | 48 | } |
| 49 | 49 | $message = strtr($message, $replace); |
| 50 | 50 | $attachInfo = ''; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file')); |
| 84 | 84 | } |
| 85 | 85 | $this->latest = $this->getConfig('save-path').'/'.$this->getConfig('file-name'); |
| 86 | - register_shutdown_function([$this,'save']); |
|
| 86 | + register_shutdown_function([$this, 'save']); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function getDefaultConfig():array |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | protected function packLogFile() |
| 103 | 103 | { |
| 104 | 104 | $logFile = $this->latest; |
| 105 | - $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip'); |
|
| 105 | + $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip'); |
|
| 106 | 106 | $zip = $this->getZipArchive($path); |
| 107 | 107 | if ($zip !== null) { |
| 108 | - if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) { |
|
| 108 | + if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) { |
|
| 109 | 109 | array_push($this->removeFiles, $logFile); |
| 110 | 110 | } |
| 111 | 111 | if (is_dir($this->getConfig('save-pack-path'))) { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $zip->close(); |
| 120 | 120 | } else { |
| 121 | 121 | if (is_file($logFile) && file_exists($logFile)) { |
| 122 | - rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log'); |
|
| 122 | + rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log'); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | } elseif (null === $val) { |
| 218 | 218 | $val = 'null'; |
| 219 | 219 | } |
| 220 | - $replace['{' . $key . '}'] = $val; |
|
| 220 | + $replace['{'.$key.'}'] = $val; |
|
| 221 | 221 | } |
| 222 | 222 | return strtr($message, $replace); |
| 223 | 223 | } |
@@ -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 | } |
@@ -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'); |
@@ -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()); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $fields = $reads; |
| 31 | 31 | } else { |
| 32 | 32 | $field = []; |
| 33 | - $prefix = strlen($table) ?"`{$table}`." :''; |
|
| 33 | + $prefix = strlen($table) ? "`{$table}`." : ''; |
|
| 34 | 34 | foreach ($reads as $want) { |
| 35 | 35 | $field[] = $prefix."`$want`"; |
| 36 | 36 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | list($inSQL, $binders) = $this->prepareInParameter($values, $name); |
| 104 | 104 | $sql = $name.' IN ('.$inSQL.')'; |
| 105 | - return [$sql,$binders]; |
|
| 105 | + return [$sql, $binders]; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function prepareQueryMark(string $sql, array $parameter) |
| 155 | 155 | { |
| 156 | 156 | $binders = []; |
| 157 | - $query = preg_replace_callback('/\?/', function ($match) use (&$binders, $parameter) { |
|
| 157 | + $query = preg_replace_callback('/\?/', function($match) use (&$binders, $parameter) { |
|
| 158 | 158 | $index = count($binders); |
| 159 | 159 | if (array_key_exists($index, $parameter)) { |
| 160 | 160 | $name = Binder::index($index); |