Passed
Push — master ( d38419...b59ef7 )
by 世昌
01:56
created
nebula/src/component/request/Request.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param mixed $default
67 67
      * @return mixed
68 68
      */
69
-    public function getHeader(string $name, $default =null)
69
+    public function getHeader(string $name, $default = null)
70 70
     {
71 71
         if (array_key_exists(strtolower($name), $this->headers)) {
72 72
             return $this->headers[$name];
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function ip()
94 94
     {
95
-        static $ipFrom = ['HTTP_CLIENT_IP','HTTP_X_FORWARDED_FOR','HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP','HTTP_FORWARDED_FOR','HTTP_FORWARDED','REMOTE_ADDR'];
95
+        static $ipFrom = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'];
96 96
         foreach ($ipFrom as $key) {
97 97
             if (array_key_exists($key, $_SERVER)) {
98 98
                 foreach (explode(',', $_SERVER[$key]) as $ip) {
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
         }
122 122
         $method = strtoupper($server['REQUEST_METHOD'] ?? 'GET');
123 123
         $uri = $server['REQUEST_URI']??'/';
124
-        $headers  = HeaderItem::buildFromServer($server ?: $_SERVER);
125
-        $request =  new static($method, $uri, $headers);
124
+        $headers = HeaderItem::buildFromServer($server ?: $_SERVER);
125
+        $request = new static($method, $uri, $headers);
126 126
         $request->setDocumentRoot($server['DOCUMENT_ROOT']);
127 127
         if ($simulate && $server !== null) {
128 128
             $request->setServer($server);
Please login to merge, or discard this patch.
nebula/src/application/route/GroupRoutes.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function add(?string $module = null, string $name, RouteMatcher $router)
59 59
     {
60
-        $module =  $module ?: $this->default;
60
+        $module = $module ?: $this->default;
61 61
         if (\array_key_exists($module, $this->routes)) {
62 62
             $this->routes[$module]->add($name, $router);
63 63
         } else {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * @param Request $request
90 90
      * @return MatchResult|null
91 91
      */
92
-    public function match(Request $request):?MatchResult
92
+    public function match(Request $request): ?MatchResult
93 93
     {
94 94
         foreach ($this->routes as $module => $collection) {
95 95
             foreach ($collection as $name => $matcher) {
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
      * @param string $name
109 109
      * @return RouteMatcher|null
110 110
      */
111
-    public function find(?string $module = null, string $name):?RouteMatcher
111
+    public function find(?string $module = null, string $name): ?RouteMatcher
112 112
     {
113
-        $module =  $module ?: $this->default;
113
+        $module = $module ?: $this->default;
114 114
         if (\array_key_exists($module, $this->routes)) {
115 115
             return $this->routes[$module]->get($name);
116 116
         }
Please login to merge, or discard this patch.
nebula/src/application/Route.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function loadFromModule(Manager $manager)
52 52
     {
53
-        $groups =  $this->applicaton->getConfig()->get('app.active', ['default']);
53
+        $groups = $this->applicaton->getConfig()->get('app.active', ['default']);
54 54
         foreach ($groups as $group) {
55 55
             $manager->loadRoute($group, $this);
56 56
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param Request $request
79 79
      * @return MatchResult|null
80 80
      */
81
-    public function match(Request $request):?MatchResult
81
+    public function match(Request $request): ?MatchResult
82 82
     {
83 83
         foreach ($this->routes as $group => $routes) {
84 84
             if (($result = $routes->match($request)) !== null) {
Please login to merge, or discard this patch.
nebula/loader/web.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@
 block discarded – undo
4 4
 use nebula\application\Loader;
5 5
 use nebula\application\Request;
6 6
 
7
-require_once __DIR__ .'/loader.php';
7
+require_once __DIR__.'/loader.php';
8 8
 
9 9
 
10 10
 
11 11
 // 初始化系统加载器
12 12
 $loader = new Loader;
13 13
 $loader->register();
14
-$loader->addIncludePath(NEBULA_SYSTEM .'/src', 'nebula');
15
-$loader->import(NEBULA_SYSTEM .'/src/functions.php');
14
+$loader->addIncludePath(NEBULA_SYSTEM.'/src', 'nebula');
15
+$loader->import(NEBULA_SYSTEM.'/src/functions.php');
16 16
 // 初始化请求
17 17
 $request = Request::buildFromServer();
18 18
 $request->apply(true);
Please login to merge, or discard this patch.
nebula/src/application/Response.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,5 +8,5 @@
 block discarded – undo
8 8
  */
9 9
 abstract class Response extends BaseResponse 
10 10
 {
11
-   public abstract function onRequest(Request $request, Response $response);
11
+    public abstract function onRequest(Request $request, Response $response);
12 12
 }
Please login to merge, or discard this patch.
nebula/src/application/response/provider/type/FileContent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      
22 22
         if ($content->isFile()) {
23 23
             $response->setType($content->getExtension());
24
-            $response->setHeader('Content-Disposition', 'attachment;filename="' . $content->getBasename().'"');
24
+            $response->setHeader('Content-Disposition', 'attachment;filename="'.$content->getBasename().'"');
25 25
             $response->setHeader('Cache-Control', 'max-age=0');
26 26
             $response->send(file_get_contents($content->getRealPath()));
27 27
         } else {
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);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             } elseif (is_null($val)) {
175 175
                 $val = 'null';
176 176
             }
177
-            $replace['{' . $key . '}'] = $val;
177
+            $replace['{'.$key.'}'] = $val;
178 178
         }
179 179
         return strtr($message, $replace);
180 180
     }
Please login to merge, or discard this patch.
nebula/src/application/response/Response.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function setStatus(int $code)
86 86
     {
87
-        $this->header->sendHeaderRaw('HTTP/1.1 '.$code.' '. Status::toText($code));
88
-        $this->header->sendHeader('Status', $code.' '. Status::toText($code));
87
+        $this->header->sendHeaderRaw('HTTP/1.1 '.$code.' '.Status::toText($code));
88
+        $this->header->sendHeader('Status', $code.' '.Status::toText($code));
89 89
     }
90 90
 
91 91
     /**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     public function render($value, string $echo = '', bool $allowEcho = true)
141 141
     {
142 142
         $this->header->send();
143
-        $wantEcho = strlen($echo) > 0 ;
143
+        $wantEcho = strlen($echo) > 0;
144 144
         $noReturn = $wantEcho && is_null($value);
145 145
         if ($noReturn && $wantEcho) {
146 146
             $this->send($echo);
Please login to merge, or discard this patch.
nebula/src/application/response/provider/Content.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 class Content
15 15
 {
16 16
     protected static $types = [
17
-        JsonContent::class => ['boolean', 'integer','double', 'string','array','NULL', JsonSerializable::class],
17
+        JsonContent::class => ['boolean', 'integer', 'double', 'string', 'array', 'NULL', JsonSerializable::class],
18 18
         FileContent::class => [SplFileInfo::class],
19 19
     ];
20 20
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     public static function isTypeOf($data, $type) : bool
42 42
     {
43
-        if (is_object($data) && !\in_array($type, ['boolean', 'integer','double', 'string','array','NULL'])) {
43
+        if (is_object($data) && !\in_array($type, ['boolean', 'integer', 'double', 'string', 'array', 'NULL'])) {
44 44
             $class = new ReflectionClass($data);
45 45
             $typeRef = new ReflectionClass($type);
46 46
             if ($typeRef->isInterface()) {
Please login to merge, or discard this patch.