Passed
Push — master ( 8b0ed1...c061fa )
by 世昌
02:48
created
nebula/src/component/loader/Path.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
14 14
      * @param string $path 目标路径 
15 15
      * @return string|null 返回格式化结果,如果路径不存在则返回NULL
16 16
      */
17
-    public static function format(string $path):?string
17
+    public static function format(string $path): ?string
18 18
     {
19
-        return static::existCharset($path, ['GBK','GB2312','BIG5']);
19
+        return static::existCharset($path, ['GBK', 'GB2312', 'BIG5']);
20 20
     }
21 21
  
22
-    public static function existCharset(string $path, array $charset):?string
22
+    public static function existCharset(string $path, array $charset): ?string
23 23
     {
24 24
         $abspath = static::toAbsolutePath($path);
25 25
         if (static::existCase($abspath)) {
Please login to merge, or discard this patch.
nebula/src/application/filesystem/FileSystemInterface.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
nebula/src/application/filesystem/FileHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
nebula/src/application/filesystem/DirectoryHelper.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
      * @param boolean $full
95 95
      * @return \Iterator
96 96
      */
97
-    public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator
97
+    public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator
98 98
     {
99 99
         $parent = Path::format($path);
100 100
         foreach (static::read($path, $recursive, $regex, false, $mode) as $subpath) {
101
-            $path = $full?$subpath:$parent.DIRECTORY_SEPARATOR.$subpath;
101
+            $path = $full ? $subpath : $parent.DIRECTORY_SEPARATOR.$subpath;
102 102
             if (is_file($path)) {
103 103
                 yield $subpath;
104 104
             }
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
      * @param boolean $full
115 115
      * @return \Iterator
116 116
      */
117
-    public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator
117
+    public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator
118 118
     {
119 119
         $parent = Path::format($path);
120 120
         foreach (static::read($path, $recursive, $regex, false, $mode) as $subpath) {
121
-            $path = $full?$subpath:$parent.DIRECTORY_SEPARATOR.$subpath;
121
+            $path = $full ? $subpath : $parent.DIRECTORY_SEPARATOR.$subpath;
122 122
             if (is_dir($path)) {
123 123
                 yield $subpath;
124 124
             }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      * @param boolean $full
135 135
      * @return \Iterator
136 136
      */
137
-    public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator
137
+    public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator
138 138
     {
139 139
         $directory = Path::format($path);
140 140
         if ($directory && \is_dir($directory)) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     }
151 151
     
152 152
 
153
-    protected static function buildIterator(string $directory, bool $recursive=false, ?string $regex = null, int $mode): \Iterator
153
+    protected static function buildIterator(string $directory, bool $recursive = false, ?string $regex = null, int $mode): \Iterator
154 154
     {
155 155
         $it = new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS);
156 156
         if ($regex !== null) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public static function cut(string $path, string $basepath):string
173 173
     {
174
-        $path =  PathTrait::toAbsolutePath($path);
174
+        $path = PathTrait::toAbsolutePath($path);
175 175
         $basepath = PathTrait::toAbsolutePath($basepath);
176 176
         if (strpos($path, $basepath.DIRECTORY_SEPARATOR) === 0) {
177 177
             return substr($path, \strlen($basepath) + 1);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      * @param boolean $move
189 189
      * @return boolean
190 190
      */
191
-    public static function copy(string $path, string $toPath, ?string $regex=null, bool $move = false):bool
191
+    public static function copy(string $path, string $toPath, ?string $regex = null, bool $move = false):bool
192 192
     {
193 193
         $directory = Path::format($path);
194 194
         static::makes($toPath);
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      * @param string|null $regex
228 228
      * @return boolean
229 229
      */
230
-    public static function move(string $path, string $toPath, ?string $regex=null):bool
230
+    public static function move(string $path, string $toPath, ?string $regex = null):bool
231 231
     {
232 232
         return static::copy($path, $toPath, $regex, true);
233 233
     }
Please login to merge, or discard this patch.
nebula/src/application/filesystem/FileSystem.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@
 block discarded – undo
19 19
     }
20 20
 
21 21
     use FileHelper  {
22
-       delete as protected deleteFile;
23
-       FileHelper::copy insteadof DirectoryHelper;
24
-       FileHelper::move insteadof DirectoryHelper;
22
+        delete as protected deleteFile;
23
+        FileHelper::copy insteadof DirectoryHelper;
24
+        FileHelper::move insteadof DirectoryHelper;
25 25
     }
26 26
 
27 27
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
      */
35 35
     public static function delete(string $path):bool
36 36
     {
37
-        if (($path=Path::format($path)) !== null) {
37
+        if (($path = Path::format($path)) !== null) {
38 38
             if (is_file($path)) {
39 39
                 return static::deleteFile($path);
40 40
             }
Please login to merge, or discard this patch.
nebula/src/component/loader/IncludeManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
      *
16 16
      * @var array
17 17
      */
18
-    protected $namespace=[ __NAMESPACE__ ];
18
+    protected $namespace = [__NAMESPACE__];
19 19
 
20 20
     /**
21 21
      * 包含路径
22 22
      *
23 23
      * @var array
24 24
      */
25
-    protected $includePath=[];
25
+    protected $includePath = [];
26 26
 
27 27
     /**
28 28
      * 将JAVA,路径分割转换为PHP分割符
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function realName(string $name):string
34 34
     {
35
-        return str_replace(['.','/'], '\\', $name);
35
+        return str_replace(['.', '/'], '\\', $name);
36 36
     }
37 37
 
38 38
     /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param string $name
42 42
      * @return string|null
43 43
      */
44
-    public static function realPath(string $name):?string
44
+    public static function realPath(string $name): ?string
45 45
     {
46 46
         return Path::format($name);
47 47
     }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param string $filename
53 53
      * @return string|null
54 54
      */
55
-    public function import(string $filename):?string
55
+    public function import(string $filename): ?string
56 56
     {
57 57
         if ($filename = static::realPath($filename)) {
58 58
             @require_once $filename;
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
         return null;
69 69
     }
70 70
 
71
-    public function addIncludePath(string $path, string $namespace=null)
71
+    public function addIncludePath(string $path, string $namespace = null)
72 72
     {
73 73
         if ($path = static::realPath($path)) {
74 74
             $namespace = $namespace ?? 0;
75 75
             if (array_key_exists($namespace, $this->includePath)) {
76 76
                 if (!\in_array($path, $this->includePath[$namespace])) {
77
-                    $this->includePath[$namespace][]=$path;
77
+                    $this->includePath[$namespace][] = $path;
78 78
                 }
79 79
             } else {
80
-                $this->includePath[$namespace][]=$path;
80
+                $this->includePath[$namespace][] = $path;
81 81
             }
82 82
         }
83 83
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     public function setNamespace(string $namespace)
96 96
     {
97 97
         if (!in_array($namespace, $this->namespace)) {
98
-            $this->namespace[]=$namespace;
98
+            $this->namespace[] = $namespace;
99 99
         }
100 100
     }
101 101
 }
Please login to merge, or discard this patch.
nebula/src/application/Resource.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $path = $source;
30 30
         if (Path::isRelativePath($source)) {
31
-            $path =  $relative.'/'.$path;
31
+            $path = $relative.'/'.$path;
32 32
         }
33 33
         return Path::toAbsolutePath($path);
34 34
     }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param string $path
54 54
      * @return string|null
55 55
      */
56
-    public function getResourcePath(string $path):?string
56
+    public function getResourcePath(string $path): ?string
57 57
     {
58 58
         foreach ($this->resource as $root) {
59 59
             $target = $root.'/'.$path;
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
      * @param string $path
71 71
      * @return string|null
72 72
      */
73
-    public function getConfigResourcePath(string $path):?string
73
+    public function getConfigResourcePath(string $path): ?string
74 74
     {
75 75
         foreach ($this->resource as $root) {
76
-            if ( $target = Config::resolve($root.'/'.$path)) {
76
+            if ($target = Config::resolve($root.'/'.$path)) {
77 77
                 return $target;
78 78
             }
79 79
         }
Please login to merge, or discard this patch.
nebula/src/component/debug/log/logger/FileLogger.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
      * @throws FileLoggerException
47 47
      * @param array $config
48 48
      */
49
-    public function __construct(array $config=[])
49
+    public function __construct(array $config = [])
50 50
     {
51 51
         $this->applyConfig($config);
52 52
         $temp = tmpfile();
53 53
         if ($temp === false) {
54
-            $this->tempname = $this->getConfig('save-path').'/log-'. microtime(true).'.tmp';
54
+            $this->tempname = $this->getConfig('save-path').'/log-'.microtime(true).'.tmp';
55 55
             $temp = fopen($this->tempname, 'w+');
56 56
         }
57 57
         if ($temp !== false) {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file'));
61 61
         }
62 62
         $this->latest = $this->getConfig('save-path').'/'.$this->getConfig('file-name');
63
-        \register_shutdown_function([$this,'save']);
63
+        \register_shutdown_function([$this, 'save']);
64 64
     }
65 65
 
66 66
     public function getDefaultConfig():array
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     
79 79
     protected function packLogFile()
80 80
     {
81
-        $logFile= $this->latest;
82
-        $path=preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip');
81
+        $logFile = $this->latest;
82
+        $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip');
83 83
         $zip = new ZipArchive;
84 84
         $res = $zip->open($path, ZipArchive::CREATE);
85 85
         if ($res === true) {
86
-            if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) {
86
+            if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) {
87 87
                 array_push($this->removeFiles, $logFile);
88 88
             }
89 89
             if (\is_dir($this->getConfig('save-pack-path'))) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             $zip->close();
98 98
         } else {
99 99
             if (is_file($logFile) && file_exists($logFile)) {
100
-                rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log');
100
+                rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log');
101 101
             }
102 102
         }
103 103
     }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function checkSize():bool
111 111
     {
112
-        $logFile= $this->latest;
112
+        $logFile = $this->latest;
113 113
         if (file_exists($logFile)) {
114 114
             if (filesize($logFile) > $this->getConfig('max-file-size')) {
115 115
                 return true;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     public function log($level, string $message, array $context = [])
123 123
     {
124
-        if (LogLevel::compare($level, $this->getConfig('log-level')) >=0) {
124
+        if (LogLevel::compare($level, $this->getConfig('log-level')) >= 0) {
125 125
             $replace = [];
126 126
             $message = $this->interpolate($message, $context);
127 127
             $replace['%level%'] = $level;
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
     protected function rollLatest()
135 135
     {
136 136
         if (isset($this->latest)) {
137
-            $size=ftell($this->temp);
137
+            $size = ftell($this->temp);
138 138
             fseek($this->temp, 0);
139 139
             if ($size > 0) {
140
-                $body=fread($this->temp, $size);
140
+                $body = fread($this->temp, $size);
141 141
                 file_put_contents($this->latest, $body, FILE_APPEND);
142 142
             }
143 143
             fclose($this->temp);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     {
170 170
         $replace = [];
171 171
         foreach ($context as $key => $val) {
172
-            $replace['{' . $key . '}'] = $val;
172
+            $replace['{'.$key.'}'] = $val;
173 173
         }
174 174
         return strtr($message, $replace);
175 175
     }
Please login to merge, or discard this patch.
nebula/loader/loader.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
     }
21 21
 }
22 22
 
23
-require_once NEBULA_SYSTEM .'/src/component/loader/Path.php';
24
-require_once NEBULA_SYSTEM .'/src/component/loader/PathTrait.php';
25
-require_once NEBULA_SYSTEM .'/src/component/loader/PathInterface.php';
26
-require_once NEBULA_SYSTEM .'/src/component/loader/IncludeManager.php';
27
-require_once NEBULA_SYSTEM .'/src/component/loader/Loader.php';
28
-require_once NEBULA_SYSTEM .'/src/application/Loader.php';
23
+require_once NEBULA_SYSTEM.'/src/component/loader/Path.php';
24
+require_once NEBULA_SYSTEM.'/src/component/loader/PathTrait.php';
25
+require_once NEBULA_SYSTEM.'/src/component/loader/PathInterface.php';
26
+require_once NEBULA_SYSTEM.'/src/component/loader/IncludeManager.php';
27
+require_once NEBULA_SYSTEM.'/src/component/loader/Loader.php';
28
+require_once NEBULA_SYSTEM.'/src/application/Loader.php';
Please login to merge, or discard this patch.