Passed
Push — master ( d38419...b59ef7 )
by 世昌
01:56
created
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.
nebula/src/application/config/ConfigLoader.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  */
10 10
 abstract class ConfigLoader
11 11
 {
12
-    public function loadConfig(string $path, array $extra =[]):?array
12
+    public function loadConfig(string $path, array $extra = []): ?array
13 13
     {
14
-        $data=null;
14
+        $data = null;
15 15
         if (!file_exists($path)) {
16 16
             $path = static::resolve($path);
17 17
         }
@@ -27,25 +27,25 @@  discard block
 block discarded – undo
27 27
         return $data;
28 28
     }
29 29
 
30
-    protected function loadJson(string $path, array $extra =[]):array
30
+    protected function loadJson(string $path, array $extra = []):array
31 31
     {
32 32
         $content = file_get_contents($path);
33
-        $content =$this->parseValue($content, $extra);
33
+        $content = $this->parseValue($content, $extra);
34 34
         $data = json_decode($content, true);
35
-        if (json_last_error()!==JSON_ERROR_NONE) {
35
+        if (json_last_error() !== JSON_ERROR_NONE) {
36 36
             throw new JSONException(json_last_error());
37 37
         }
38 38
         return $data;
39 39
     }
40 40
 
41
-    protected function loadIni(string $path, array $extra =[]):array
41
+    protected function loadIni(string $path, array $extra = []):array
42 42
     {
43 43
         $content = file_get_contents($path);
44
-        $content =$this->parseValue($content, $extra);
44
+        $content = $this->parseValue($content, $extra);
45 45
         return \parse_ini_string($content, true) ?: [];
46 46
     }
47 47
 
48
-    protected function loadYaml(string $path, array $extra =[]):array
48
+    protected function loadYaml(string $path, array $extra = []):array
49 49
     {
50 50
         if (function_exists('yaml_parse')) {
51 51
             $name = 'yaml_parse';
@@ -55,25 +55,25 @@  discard block
 block discarded – undo
55 55
             throw new YamlException("parse yaml config error : missing yaml extension or spyc", 1);
56 56
         }
57 57
         $content = file_get_contents($path);
58
-        $content =$this->parseValue($content, $extra);
58
+        $content = $this->parseValue($content, $extra);
59 59
         return \call_user_func_array($name, [$content]);
60 60
     }
61 61
 
62
-    abstract public function parseValue(string $content, array $extra =[]):string;
62
+    abstract public function parseValue(string $content, array $extra = []):string;
63 63
 
64
-    public  static function resolve(string $path):?string
64
+    public  static function resolve(string $path): ?string
65 65
     {
66 66
         if (file_exists($path)) {
67 67
             return $path;
68 68
         }
69 69
         $basepath = dirname($path).'/'.pathinfo($path, PATHINFO_FILENAME);
70
-        if (file_exists($conf = $basepath.'.yml')  || file_exists($conf = $basepath.'.yaml')) {
70
+        if (file_exists($conf = $basepath.'.yml') || file_exists($conf = $basepath.'.yaml')) {
71 71
             if (function_exists('yaml_parse') || class_exists('Spyc')) {
72 72
                 return $conf;
73 73
             }
74 74
         }
75
-        foreach (['.json','.php','.ini'] as $ext) {
76
-            if (file_exists($conf=$basepath.$ext)) {
75
+        foreach (['.json', '.php', '.ini'] as $ext) {
76
+            if (file_exists($conf = $basepath.$ext)) {
77 77
                 return $conf;
78 78
             }
79 79
         }
Please login to merge, or discard this patch.
nebula/src/application/module/Builder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@
 block discarded – undo
42 42
             $extension !== 'module') {
43 43
             return null;
44 44
         }
45
-        $zip=new ZipArchive;
45
+        $zip = new ZipArchive;
46 46
         if ($zip->open($path, ZipArchive::CHECKCONS)) {
47
-            $unzipPath = $unpackPath.'/'. pathinfo($path, PATHINFO_FILENAME) .'-'.substr(md5_file($path), 0, 8);
47
+            $unzipPath = $unpackPath.'/'.pathinfo($path, PATHINFO_FILENAME).'-'.substr(md5_file($path), 0, 8);
48 48
             $zip->extractTo($unzipPath);
49 49
             $zip->close();
50 50
             return Config::resolve($unzipPath.'/module');
Please login to merge, or discard this patch.
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/Application.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -162,8 +162,8 @@
 block discarded – undo
162 162
      */
163 163
     protected function registerModuleManager()
164 164
     {
165
-       $this->manager = new Manager($this->getContext());
166
-       $this->manager->registerModule();
165
+        $this->manager = new Manager($this->getContext());
166
+        $this->manager->registerModule();
167 167
     }
168 168
 
169 169
     /**
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/Status.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     public static $statusTexts = [
10 10
         100 => 'Continue',
11 11
         101 => 'Switching Protocols',
12
-        102 => 'Processing',            // RFC2518
12
+        102 => 'Processing', // RFC2518
13 13
         103 => 'Early Hints',
14 14
         200 => 'OK',
15 15
         201 => 'Created',
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
         204 => 'No Content',
19 19
         205 => 'Reset Content',
20 20
         206 => 'Partial Content',
21
-        207 => 'Multi-Status',          // RFC4918
22
-        208 => 'Already Reported',      // RFC5842
23
-        226 => 'IM Used',               // RFC3229
21
+        207 => 'Multi-Status', // RFC4918
22
+        208 => 'Already Reported', // RFC5842
23
+        226 => 'IM Used', // RFC3229
24 24
         300 => 'Multiple Choices',
25 25
         301 => 'Moved Permanently',
26 26
         302 => 'Found',
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         304 => 'Not Modified',
29 29
         305 => 'Use Proxy',
30 30
         307 => 'Temporary Redirect',
31
-        308 => 'Permanent Redirect',    // RFC7238
31
+        308 => 'Permanent Redirect', // RFC7238
32 32
         400 => 'Bad Request',
33 33
         401 => 'Unauthorized',
34 34
         402 => 'Payment Required',
@@ -47,34 +47,34 @@  discard block
 block discarded – undo
47 47
         415 => 'Unsupported Media Type',
48 48
         416 => 'Range Not Satisfiable',
49 49
         417 => 'Expectation Failed',
50
-        418 => 'I\'m a teapot',                                               // RFC2324
51
-        421 => 'Misdirected Request',                                         // RFC7540
52
-        422 => 'Unprocessable Entity',                                        // RFC4918
53
-        423 => 'Locked',                                                      // RFC4918
54
-        424 => 'Failed Dependency',                                           // RFC4918
55
-        425 => 'Too Early',                                                   // RFC-ietf-httpbis-replay-04
56
-        426 => 'Upgrade Required',                                            // RFC2817
57
-        428 => 'Precondition Required',                                       // RFC6585
58
-        429 => 'Too Many Requests',                                           // RFC6585
59
-        431 => 'Request Header Fields Too Large',                             // RFC6585
60
-        451 => 'Unavailable For Legal Reasons',                               // RFC7725
50
+        418 => 'I\'m a teapot', // RFC2324
51
+        421 => 'Misdirected Request', // RFC7540
52
+        422 => 'Unprocessable Entity', // RFC4918
53
+        423 => 'Locked', // RFC4918
54
+        424 => 'Failed Dependency', // RFC4918
55
+        425 => 'Too Early', // RFC-ietf-httpbis-replay-04
56
+        426 => 'Upgrade Required', // RFC2817
57
+        428 => 'Precondition Required', // RFC6585
58
+        429 => 'Too Many Requests', // RFC6585
59
+        431 => 'Request Header Fields Too Large', // RFC6585
60
+        451 => 'Unavailable For Legal Reasons', // RFC7725
61 61
         500 => 'Internal Server Error',
62 62
         501 => 'Not Implemented',
63 63
         502 => 'Bad Gateway',
64 64
         503 => 'Service Unavailable',
65 65
         504 => 'Gateway Timeout',
66 66
         505 => 'HTTP Version Not Supported',
67
-        506 => 'Variant Also Negotiates',                                     // RFC2295
68
-        507 => 'Insufficient Storage',                                        // RFC4918
69
-        508 => 'Loop Detected',                                               // RFC5842
70
-        510 => 'Not Extended',                                                // RFC2774
71
-        511 => 'Network Authentication Required',                             // RFC6585
67
+        506 => 'Variant Also Negotiates', // RFC2295
68
+        507 => 'Insufficient Storage', // RFC4918
69
+        508 => 'Loop Detected', // RFC5842
70
+        510 => 'Not Extended', // RFC2774
71
+        511 => 'Network Authentication Required', // RFC6585
72 72
     ];
73 73
 
74 74
     const HTTP_CONTINUE = 100;
75 75
     const HTTP_SWITCHING_PROTOCOLS = 101;
76
-    const HTTP_PROCESSING = 102;            // RFC2518
77
-    const HTTP_EARLY_HINTS = 103;           // RFC8297
76
+    const HTTP_PROCESSING = 102; // RFC2518
77
+    const HTTP_EARLY_HINTS = 103; // RFC8297
78 78
     const HTTP_OK = 200;
79 79
     const HTTP_CREATED = 201;
80 80
     const HTTP_ACCEPTED = 202;
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     const HTTP_NO_CONTENT = 204;
83 83
     const HTTP_RESET_CONTENT = 205;
84 84
     const HTTP_PARTIAL_CONTENT = 206;
85
-    const HTTP_MULTI_STATUS = 207;          // RFC4918
86
-    const HTTP_ALREADY_REPORTED = 208;      // RFC5842
87
-    const HTTP_IM_USED = 226;               // RFC3229
85
+    const HTTP_MULTI_STATUS = 207; // RFC4918
86
+    const HTTP_ALREADY_REPORTED = 208; // RFC5842
87
+    const HTTP_IM_USED = 226; // RFC3229
88 88
     const HTTP_MULTIPLE_CHOICES = 300;
89 89
     const HTTP_MOVED_PERMANENTLY = 301;
90 90
     const HTTP_FOUND = 302;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     const HTTP_USE_PROXY = 305;
94 94
     const HTTP_RESERVED = 306;
95 95
     const HTTP_TEMPORARY_REDIRECT = 307;
96
-    const HTTP_PERMANENTLY_REDIRECT = 308;  // RFC7238
96
+    const HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238
97 97
     const HTTP_BAD_REQUEST = 400;
98 98
     const HTTP_UNAUTHORIZED = 401;
99 99
     const HTTP_PAYMENT_REQUIRED = 402;
@@ -112,21 +112,21 @@  discard block
 block discarded – undo
112 112
     const HTTP_UNSUPPORTED_MEDIA_TYPE = 415;
113 113
     const HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
114 114
     const HTTP_EXPECTATION_FAILED = 417;
115
-    const HTTP_I_AM_A_TEAPOT = 418;                                               // RFC2324
116
-    const HTTP_MISDIRECTED_REQUEST = 421;                                         // RFC7540
117
-    const HTTP_UNPROCESSABLE_ENTITY = 422;                                        // RFC4918
118
-    const HTTP_LOCKED = 423;                                                      // RFC4918
119
-    const HTTP_FAILED_DEPENDENCY = 424;                                           // RFC4918
115
+    const HTTP_I_AM_A_TEAPOT = 418; // RFC2324
116
+    const HTTP_MISDIRECTED_REQUEST = 421; // RFC7540
117
+    const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
118
+    const HTTP_LOCKED = 423; // RFC4918
119
+    const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
120 120
 
121 121
     /**
122 122
      * @deprecated
123 123
      */
124
-    const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425;   // RFC2817
125
-    const HTTP_TOO_EARLY = 425;                                                   // RFC-ietf-httpbis-replay-04
126
-    const HTTP_UPGRADE_REQUIRED = 426;                                            // RFC2817
127
-    const HTTP_PRECONDITION_REQUIRED = 428;                                       // RFC6585
128
-    const HTTP_TOO_MANY_REQUESTS = 429;                                           // RFC6585
129
-    const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431;                             // RFC6585
124
+    const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
125
+    const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04
126
+    const HTTP_UPGRADE_REQUIRED = 426; // RFC2817
127
+    const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585
128
+    const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585
129
+    const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585
130 130
     const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451;
131 131
     const HTTP_INTERNAL_SERVER_ERROR = 500;
132 132
     const HTTP_NOT_IMPLEMENTED = 501;
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
     const HTTP_SERVICE_UNAVAILABLE = 503;
135 135
     const HTTP_GATEWAY_TIMEOUT = 504;
136 136
     const HTTP_VERSION_NOT_SUPPORTED = 505;
137
-    const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506;                        // RFC2295
138
-    const HTTP_INSUFFICIENT_STORAGE = 507;                                        // RFC4918
139
-    const HTTP_LOOP_DETECTED = 508;                                               // RFC5842
140
-    const HTTP_NOT_EXTENDED = 510;                                                // RFC2774
137
+    const HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295
138
+    const HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918
139
+    const HTTP_LOOP_DETECTED = 508; // RFC5842
140
+    const HTTP_NOT_EXTENDED = 510; // RFC2774
141 141
     const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; 
142 142
 
143 143
     /**
Please login to merge, or discard this patch.