Passed
Push — master ( 280ab3...c1e721 )
by 世昌
01:51
created
nebula/src/component/debug/attach/AttachTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @var array
13 13
      */
14
-    protected $attribute=[];
14
+    protected $attribute = [];
15 15
     
16
-    public function addAttribute(string $name , $value)
16
+    public function addAttribute(string $name, $value)
17 17
     {
18 18
         $this->attribute[$name] = $value;
19 19
     }
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
     protected function analyse(array $context)
22 22
     {
23 23
         $replace = [];
24
-        $attach  =[] ;
24
+        $attach  = [];
25 25
         foreach ($context as $key => $val) {
26
-            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && ! $val instanceof \Exception) {
27
-                $replace['{' . $key . '}'] = $val;
26
+            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString')) && !$val instanceof \Exception) {
27
+                $replace['{'.$key.'}'] = $val;
28 28
             } else {
29 29
                 $attach[$key] = $val;
30 30
             }
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function interpolate(string $message, array $context, array $attribute)
36 36
     {
37
-        list($attach, $replace) =  $this->analyse($context);
37
+        list($attach, $replace) = $this->analyse($context);
38 38
         $attribute = array_merge($this->attribute, $attribute);
39 39
         foreach ($attribute as $key => $val) {
40
-            $replace['%' . $key . '%'] = $val;
40
+            $replace['%'.$key.'%'] = $val;
41 41
         }
42 42
         $message = strtr($message, $replace);
43 43
         $attachInfo = '';
44 44
         foreach ($attach as $name => $value) {
45 45
             $attachInfo = $name.' = ';
46 46
             if ($value instanceof AttachValueInterface) {
47
-                $attachInfo.= $value->getLogAttach().PHP_EOL;
47
+                $attachInfo .= $value->getLogAttach().PHP_EOL;
48 48
             } else {
49
-                $attachInfo.= DumpTrait::parameterToString($value).PHP_EOL;
49
+                $attachInfo .= DumpTrait::parameterToString($value).PHP_EOL;
50 50
             }
51 51
         }
52 52
         if (strlen($attachInfo) > 0) {
Please login to merge, or discard this patch.
nebula/src/application/module/Manager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     public function registerModule()
141 141
     {
142 142
         $scan = $this->getContext()->getConfig()->get('app.module.scan-path', []);
143
-        $cache = $this->getContext()->getApplication()->getDataPath() .'/module-cache';
143
+        $cache = $this->getContext()->getApplication()->getDataPath().'/module-cache';
144 144
         FileSystem::makes($cache);
145 145
         // 扫描加载
146 146
         foreach (Builder::scan($scan, $cache) as $module) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      * @param string $name
191 191
      * @return Module|null
192 192
      */
193
-    public function find(string $name):?Module
193
+    public function find(string $name): ?Module
194 194
     {
195 195
         $fullName = $this->finder->getFullName($name);
196 196
         return $this->module[$fullName] ?? null;
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
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
     public function getRoute(string $groupName): GroupRoutes
86 86
     {
87
-        $group = $groupName === 'default' ? '': '-'. $groupName;
88
-        $routeConfig = $this->getConfigFrom('route'.$group, ['group' => $group,]);
89
-        $routes =  new GroupRoutes($groupName);
87
+        $group = $groupName === 'default' ? '' : '-'.$groupName;
88
+        $routeConfig = $this->getConfigFrom('route'.$group, ['group' => $group, ]);
89
+        $routes = new GroupRoutes($groupName);
90 90
         if (\is_array($routeConfig)) {
91 91
             // debug()->debug('load route {group} from {module}',['group'=>$groupName, 'module' => $this->getFullName()]);
92 92
             $prefix = $this->config->get('route.prefix', '');
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function getFullName()
143 143
     {
144
-        return $this->name .':'. $this->version;
144
+        return $this->name.':'.$this->version;
145 145
     }
146 146
 
147 147
     /**
Please login to merge, or discard this patch.
nebula/src/NebulaApplication.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     private function initBaseConfig()
90 90
     {
91
-        $this->initConfigIfNotSet('app.route.active', defined('NEBULA_ROUTE_GROUPS')? \explode(',', \constant('NEBULA_ROUTE_GROUPS')) :['default']);
91
+        $this->initConfigIfNotSet('app.route.active', defined('NEBULA_ROUTE_GROUPS') ? \explode(',', \constant('NEBULA_ROUTE_GROUPS')) : ['default']);
92 92
         $this->initConfigIfNotSet('app.import', [\constant('NEBULA_APP').'/'.'share']);
93 93
         $this->initConfigIfNotSet('app.resource', [\constant('NEBULA_APP').'/'.'resource']);
94 94
         $this->initConfigIfNotSet('app.module.scan-path', [\constant('NEBULA_APP').'/'.'modules']);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     private function initTimezone()
117 117
     {
118
-        $timezone = defined('DEFAULT_TIMEZONE')?constant('DEFAULT_TIMEZONE'):'PRC';
118
+        $timezone = defined('DEFAULT_TIMEZONE') ?constant('DEFAULT_TIMEZONE') : 'PRC';
119 119
         date_default_timezone_set($this->config->get('app.timezone', $timezone));
120 120
     }
121 121
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public function run()
201 201
     {
202
-        $className  = $this->config->get('app.application', Application::class);
202
+        $className = $this->config->get('app.application', Application::class);
203 203
         $this->application = Runnable::newClassInstance($className);
204 204
         $this->application->setContext($this);
205 205
         $this->application->setPath($this->path);
Please login to merge, or discard this patch.
nebula/src/application/response/provider/MimeType.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
      */
14 14
     protected static $mimes = [
15 15
         # Image Type
16
-        'jpe' => 'image/jpeg' ,
17
-        'jpeg' => 'image/jpeg' ,
18
-        'jpg' => 'image/jpeg' ,
19
-        'svg' => 'image/svg+xml' ,
20
-        'png' => 'image/png' ,
21
-        'gif' => 'image/gif' ,
16
+        'jpe' => 'image/jpeg',
17
+        'jpeg' => 'image/jpeg',
18
+        'jpg' => 'image/jpeg',
19
+        'svg' => 'image/svg+xml',
20
+        'png' => 'image/png',
21
+        'gif' => 'image/gif',
22 22
         'ico' => 'image/x-icon',
23 23
         'webp' => 'image/webp',
24 24
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
         'js' => 'text/javascript',
27 27
         'css' => 'text/css',
28 28
         'txt' => 'text/plain',
29
-        'html' => 'text/html' ,
30
-        'csv' => 'text/csv' ,
29
+        'html' => 'text/html',
30
+        'csv' => 'text/csv',
31 31
         'xml' => 'text/xml',
32 32
 
33 33
         # App type
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
         # Archive
41 41
         'zip' => 'application/zip',
42
-        'gtar' => 'application/x-gtar' ,
43
-        'gz' => 'application/x-gzip' ,
42
+        'gtar' => 'application/x-gtar',
43
+        'gz' => 'application/x-gzip',
44 44
         '7z' => 'application/x-7z-compressed',
45 45
         'rar' => 'application/x-rar-compressed',
46 46
 
Please login to merge, or discard this patch.
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.