Passed
Push — master ( e76565...f081ea )
by 世昌
02:25
created
nebula/loader/web.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use nebula\NebulaApplication;
4 4
 use nebula\application\Loader;
5 5
 
6
-require_once __DIR__ .'/loader.php';
6
+require_once __DIR__.'/loader.php';
7 7
 
8 8
 
9 9
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 $loader = new Loader;
13 13
 $loader->register();
14
-$loader->addIncludePath(NEBULA_SYSTEM .'/src', 'nebula');
14
+$loader->addIncludePath(NEBULA_SYSTEM.'/src', 'nebula');
15 15
 
16 16
 
17 17
 $nebula = NebulaApplication::configuration(constant('NEBULA_APP'));
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.
nebula/src/application/cache/FileCache.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
      * @param int $expire 过期时间
33 33
      * @return bool
34 34
      */
35
-    public function set(string $name, $value, int $expire=null):bool
35
+    public function set(string $name, $value, int $expire = null):bool
36 36
     {
37 37
         if ($this->disable()) {
38 38
             return false;
39 39
         }
40
-        $path=$this->getPath($name);
41
-        $this->value[$name]=$value;
40
+        $path = $this->getPath($name);
41
+        $this->value[$name] = $value;
42 42
         FileSystem::makes(dirname($path));
43
-        $value=serialize($value);
43
+        $value = serialize($value);
44 44
         if (is_null($expire)) {
45
-            $expire=time() + $this->defaultLiveTime;
45
+            $expire = time() + $this->defaultLiveTime;
46 46
         }
47
-        return file_put_contents($path, $expire.'|'.$value)!==false;
47
+        return file_put_contents($path, $expire.'|'.$value) !== false;
48 48
     }
49 49
 
50 50
     /**
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
      * @param string $name 名
53 53
      * @return mixed|null
54 54
      */
55
-    public function get(string $name, $defalut=null)
55
+    public function get(string $name, $defalut = null)
56 56
     {
57 57
         // 有值就获取值
58 58
         if (array_key_exists($name, $this->value)) {
59
-            $value=$this->value[$name];
59
+            $value = $this->value[$name];
60 60
             return $value;
61 61
         }
62 62
         // 没值就在cache文件中查找
63
-        $path=$this->getPath($name);
63
+        $path = $this->getPath($name);
64 64
         if (FileSystem::exist($path)) {
65
-            $value=FileSystem::get($path);
66
-            list($time, $value)=explode('|', $value, 2);
67
-            if (time()<intval($time)) {
65
+            $value = FileSystem::get($path);
66
+            list($time, $value) = explode('|', $value, 2);
67
+            if (time() < intval($time)) {
68 68
                 // 未过期则返回
69 69
                 return unserialize($value);
70 70
             } else {
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function has(string $name):bool
97 97
     {
98
-        return $this->get($name)!==null;
98
+        return $this->get($name) !== null;
99 99
     }
100 100
 
101 101
     /**
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function gc()
105 105
     {
106
-        $files=FileSystem::readFiles($this->path, true);
106
+        $files = FileSystem::readFiles($this->path, true);
107 107
         foreach ($files as $file) {
108
-            $value=FileSystem::get($file);
109
-            list($time, $value)=explode('|', $value, 2);
110
-            if (time()>intval($time)) {
108
+            $value = FileSystem::get($file);
109
+            list($time, $value) = explode('|', $value, 2);
110
+            if (time() > intval($time)) {
111 111
                 FileSystem::delete($file);
112 112
             }
113 113
         }
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
     private function getPath(string $name)
132 132
     {
133 133
         if (strpos($name, '.')) {
134
-            list($main, $sub)=explode('.', $name, 2);
134
+            list($main, $sub) = explode('.', $name, 2);
135 135
         } else {
136
-            $main=$name;
137
-            $sub=$name;
136
+            $main = $name;
137
+            $sub = $name;
138 138
         }
139
-        $fname= $this->path.'/'.$main.'/'.substr(md5($sub), 0, 4).'.cache';
139
+        $fname = $this->path.'/'.$main.'/'.substr(md5($sub), 0, 4).'.cache';
140 140
         return $fname;
141 141
     }
142 142
 }
Please login to merge, or discard this patch.
nebula/src/component/route/RouteCollection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param RouteMatcher[] $collection
25 25
      */
26
-    public function __construct(array $collection=[])
26
+    public function __construct(array $collection = [])
27 27
     {
28 28
         $this->mergeArray($collection);
29 29
     }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param array $collection
35 35
      * @return void
36 36
      */
37
-    public function mergeArray(array $collection=[])
37
+    public function mergeArray(array $collection = [])
38 38
     {
39 39
         $this->collection = array_merge($this->collection, $collection);
40 40
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param string $name
69 69
      * @return RouteMatcher|null
70 70
      */
71
-    public function get(string $name):?RouteMatcher
71
+    public function get(string $name): ?RouteMatcher
72 72
     {
73 73
         return $this->collection[$name] ?? null;
74 74
     }
Please login to merge, or discard this patch.
nebula/src/application/Application.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -146,8 +146,8 @@
 block discarded – undo
146 146
      */
147 147
     protected function registerModuleManager()
148 148
     {
149
-       $this->manager = new Manager($this->getContext());
150
-       $this->manager->registerModule();
149
+        $this->manager = new Manager($this->getContext());
150
+        $this->manager->registerModule();
151 151
     }
152 152
 
153 153
     
Please login to merge, or discard this patch.
nebula/src/application/module/NameFinder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         $rpos = \strrpos($name, ':');
56 56
         if ($rpos > 0) {
57 57
             $module = substr($name, 0, $rpos);
58
-            $name = \substr($name, $rpos+1);
59
-            $moduleFull  = $this->getFullName($module);
58
+            $name = \substr($name, $rpos + 1);
59
+            $moduleFull = $this->getFullName($module);
60 60
             return [$moduleFull, $name];
61 61
         }
62 62
         if ($rpos === 0) {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         if (\array_key_exists($version, $this->knownsFullName[$name])) {
78 78
             return $this->knownsFullName[$name][$version];
79 79
         }
80
-        return $hasVersion?$name.':'.$version:end($this->knownsFullName[$name]);
80
+        return $hasVersion ? $name.':'.$version : end($this->knownsFullName[$name]);
81 81
     }
82 82
     
83 83
     protected function getLikeName(string $name):string
Please login to merge, or discard this patch.
nebula/src/application/module/Module.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
     public function getRoute(string $groupName): GroupRoutes
77 77
     {
78
-        $group = $groupName === 'default' ? '': '-'. $groupName;
79
-        $routeConfig = $this->getConfig('route'.$group, ['group' => $group,]);
80
-        $routes =  new GroupRoutes($groupName);
78
+        $group = $groupName === 'default' ? '' : '-'.$groupName;
79
+        $routeConfig = $this->getConfig('route'.$group, ['group' => $group, ]);
80
+        $routes = new GroupRoutes($groupName);
81 81
         if (\is_array($routeConfig)) {
82 82
             $prefix = $this->config->get('route.prefix', '');
83 83
             foreach ($routeConfig as $name => $value) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function getFullName()
120 120
     {
121
-        return $this->name .':'. $this->version;
121
+        return $this->name.':'.$this->version;
122 122
     }
123 123
 
124 124
     /**
Please login to merge, or discard this patch.
nebula/src/application/config/Config.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         $this->config = $config;
21 21
     }
22 22
 
23
-    public function load(string $path, array $extra =[])
23
+    public function load(string $path, array $extra = [])
24 24
     {
25 25
         $data = $this->loadConfig($path, $extra);
26 26
         if ($data) {
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 
36 36
     public function assign(array $config)
37 37
     {
38
-        return $this->config=array_merge($this->config, $config);
38
+        return $this->config = array_merge($this->config, $config);
39 39
     }
40 40
 
41
-    public function get(string $name=null, $default=null)
41
+    public function get(string $name = null, $default = null)
42 42
     {
43 43
         if (is_null($name)) {
44 44
             return $this->config;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         return ArrayDotAccess::get($this->config, $name, $default);
47 47
     }
48 48
 
49
-    public function set(string $name, $value, $combine=null)
49
+    public function set(string $name, $value, $combine = null)
50 50
     {
51 51
         return ArrayDotAccess::set($this->config, $name, $value, $combine);
52 52
     }
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
         return ArrayDotAccess::exist($this->config, $name);
57 57
     }
58 58
 
59
-    public function parseValue(string $content, array $extra =[]):string
59
+    public function parseValue(string $content, array $extra = []):string
60 60
     {
61
-        return preg_replace_callback('/\$\{(.+?)\}/', function ($matchs) use ($extra) {
61
+        return preg_replace_callback('/\$\{(.+?)\}/', function($matchs) use ($extra) {
62 62
             $name = $matchs[1];
63
-            if (($value = ArrayDotAccess::get($extra, $name, null))!==null) {
63
+            if (($value = ArrayDotAccess::get($extra, $name, null)) !== null) {
64 64
             } elseif (defined($name)) {
65 65
                 $value = constant($name);
66 66
             } else {
67 67
                 $value = $this->get($name, $matchs[0]);
68 68
             }
69
-            return is_string($value)?trim(json_encode($value), '"'):$value;
69
+            return is_string($value) ?trim(json_encode($value), '"') : $value;
70 70
         }, $content);
71 71
     }
72 72
 }
Please login to merge, or discard this patch.