Passed
Push — master ( ae009e...1bc377 )
by 世昌
02:06
created
nebula/src/component/route/uri/UriMatcher.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @param boolean $ignoreCase
47 47
      * @return array|null
48 48
      */
49
-    public function match(string $url, bool $ignoreCase = true):?array
49
+    public function match(string $url, bool $ignoreCase = true): ?array
50 50
     {
51
-        $match = '#^'. $this->match.'$#'. ($ignoreCase?'i':'');
51
+        $match = '#^'.$this->match.'$#'.($ignoreCase ? 'i' : '');
52 52
         $parameter = [];
53 53
         if (preg_match($match, $url, $parameter, PREG_UNMATCHED_AS_NULL) > 0) {
54 54
             return array_slice($parameter, 1);
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
             } else {
73 73
                 $value = $parameter->unpackValue($match);
74 74
             }
75
-            $parameters[$parameter->getIndexName()] =  $value;
75
+            $parameters[$parameter->getIndexName()] = $value;
76 76
         }
77 77
         return $parameters;
78 78
     }
79 79
 
80
-    public function getParameter(string $name):?Parameter
80
+    public function getParameter(string $name): ?Parameter
81 81
     {
82 82
         foreach ($this->parameter as $parameter) {
83 83
             if ($parameter->getIndexName() === $name) {
Please login to merge, or discard this patch.
nebula/src/component/route/uri/MatcherHelper.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
         // 参数
27 27
         $parameters = [];
28 28
         // 转义正则
29
-        $url=preg_replace('/([\/\.\\\\\+\(\^\)\$\!\<\>\-\?\*])/', '\\\\$1', $uri);
29
+        $url = preg_replace('/([\/\.\\\\\+\(\^\)\$\!\<\>\-\?\*])/', '\\\\$1', $uri);
30 30
         // 添加忽略
31
-        $url=preg_replace('/(\[)([^\[\]]+)(?(1)\])/', '(?:$2)?', $url);
31
+        $url = preg_replace('/(\[)([^\[\]]+)(?(1)\])/', '(?:$2)?', $url);
32 32
         // 添加 * ? 匹配
33
-        $url=str_replace(['\*','\?'], ['[^/]*?','[^/]'], $url);
33
+        $url = str_replace(['\*', '\?'], ['[^/]*?', '[^/]'], $url);
34 34
         // 编译页面参数
35
-        $url=preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function ($match) use (&$parameters) {
35
+        $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function($match) use (&$parameters) {
36 36
             $name = $match[1];
37 37
             $type = 'string';
38 38
             $extra = '';
39 39
             if (isset($match[2])) {
40
-                if (strpos($match[2], '=')!==false) {
40
+                if (strpos($match[2], '=') !== false) {
41 41
                     list($type, $extra) = \explode('=', $match[2]);
42 42
                 } else {
43 43
                     $type = $match[2];
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 
57 57
     public static function buildUri(UriMatcher $matcher, array $parameter, bool $allowQuery = true):string
58 58
     {
59
-        $uri =  $matcher->getUri();
59
+        $uri = $matcher->getUri();
60 60
         // 拆分参数
61 61
         list($mapper, $query) = static::analyseParameter($matcher, $parameter);
62 62
         // for * ?
63
-        $url=\str_replace(['*','?'], ['','-'], $uri);
63
+        $url = \str_replace(['*', '?'], ['', '-'], $uri);
64 64
         // for ignore value
65
-        $url=preg_replace_callback('/\[(.+?)\]/', function ($match) use ($matcher, $parameter, $mapper) {
65
+        $url = preg_replace_callback('/\[(.+?)\]/', function($match) use ($matcher, $parameter, $mapper) {
66 66
             if (preg_match('/\{(\w+).+?\}/', $match[1])) {
67 67
                 $count = 0;
68
-                $subUrl= static::replaceParameter($match[1], $matcher, $parameter, $mapper, $count);
68
+                $subUrl = static::replaceParameter($match[1], $matcher, $parameter, $mapper, $count);
69 69
                 if ($count > 0) {
70 70
                     return $subUrl;
71 71
                 }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             return '';
74 74
         }, $url);
75 75
  
76
-        $url= static::replaceParameter($url, $matcher, $parameter, $mapper);
76
+        $url = static::replaceParameter($url, $matcher, $parameter, $mapper);
77 77
 
78 78
         if (count($query) && $allowQuery) {
79 79
             return $url.'?'.http_build_query($query, 'v', '&', PHP_QUERY_RFC3986);
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         return [$mapper, $query];
98 98
     }
99 99
 
100
-    protected static function replaceParameter(string $input, UriMatcher $matcher, array $parameter, array $mapper, ?int &$count=null)
100
+    protected static function replaceParameter(string $input, UriMatcher $matcher, array $parameter, array $mapper, ?int &$count = null)
101 101
     {
102
-        return preg_replace_callback('/\{(\w+).+?\}/', function ($match) use ($matcher, $parameter, $mapper) {
102
+        return preg_replace_callback('/\{(\w+).+?\}/', function($match) use ($matcher, $parameter, $mapper) {
103 103
             if (\array_key_exists($match[1], $mapper)) {
104 104
                 return $mapper[$match[1]]->packValue($parameter[$match[1]]);
105 105
             }
Please login to merge, or discard this patch.
nebula/src/component/route/uri/parameter/Parameter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * 匹配参数
6 6
  */
7
-abstract class Parameter   {
7
+abstract class Parameter {
8 8
 
9 9
     protected static $name;
10 10
     /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     }
26 26
 
27 27
     public static function build(string $indexName, string $extra):Parameter {
28
-        $parameter =  new static($extra);
28
+        $parameter = new static($extra);
29 29
         $parameter->setIndexName($indexName);
30 30
         return $parameter;
31 31
     }
Please login to merge, or discard this patch.
nebula/src/component/route/RouteMatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
     protected $matcher;
41 41
     
42 42
 
43
-    public function __construct(array $methods, string $uri, array $attribute=[])
43
+    public function __construct(array $methods, string $uri, array $attribute = [])
44 44
     {
45
-        array_walk($methods, function ($value) {
45
+        array_walk($methods, function($value) {
46 46
             return strtoupper($value);
47 47
         });
48 48
         $this->methods = $methods;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @param RequestInterface $request
140 140
      * @return array|null
141 141
      */
142
-    public function match(RequestInterface $request):?array {
142
+    public function match(RequestInterface $request): ?array {
143 143
         if (\in_array($request->getMethod(), $this->methods)) {
144 144
             if ($parameter = $this->matcher->match($request->getUrl())) {
145 145
                 return $this->matcher->buildParamter($parameter);
Please login to merge, or discard this patch.
nebula/src/component/loader/PathInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
 
12 12
     public static function toAbsolutePath(string $path, string $separator = DIRECTORY_SEPARATOR):string;
13 13
 
14
-    public static function getHomePath():?string;
14
+    public static function getHomePath(): ?string;
15 15
 }
Please login to merge, or discard this patch.
nebula/src/component/loader/PathTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 {    
10 10
     public static function formatSeparator(string $path):string
11 11
     {
12
-        return str_replace(['\\','/'], DIRECTORY_SEPARATOR, $path);
12
+        return str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
13 13
     }
14 14
 
15 15
     public static function toAbsolutePath(string $path, string $separator = DIRECTORY_SEPARATOR):string{
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             $subpath = substr($subpath, 1);
31 31
         } else {
32 32
             if (strpos($subpath, ':/') === false) {
33
-                $subpath=str_replace(['/', '\\'], '/', getcwd()).'/'.$subpath;
33
+                $subpath = str_replace(['/', '\\'], '/', getcwd()).'/'.$subpath;
34 34
             }
35 35
             list($root, $subpath) = explode(':/', $subpath, 2);
36 36
             $root .= ':'.DIRECTORY_SEPARATOR;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             } elseif ($name === '.') {
49 49
                 continue;
50 50
             } elseif (strlen($name)) {
51
-                $absulotePaths[]=$name;
51
+                $absulotePaths[] = $name;
52 52
             }
53 53
         }
54 54
         return implode($separator, $absulotePaths);
@@ -57,20 +57,20 @@  discard block
 block discarded – undo
57 57
     protected static function parsePathSchemeSubpath(string $path):array
58 58
     {
59 59
         if (static::getHomePath() !== null && strpos($path, '~') === 0) {
60
-            $scheme ='';
61
-            $subpath = static::getHomePath() .DIRECTORY_SEPARATOR.substr($path, 1);
60
+            $scheme = '';
61
+            $subpath = static::getHomePath().DIRECTORY_SEPARATOR.substr($path, 1);
62 62
         } elseif (strpos($path, '://') !== false) {
63 63
             list($scheme, $subpath) = explode('://', $path, 2);
64
-            $scheme.='://';
64
+            $scheme .= '://';
65 65
         } else {
66
-            $scheme ='';
66
+            $scheme = '';
67 67
             $subpath = $path;
68 68
         }
69 69
         return [$scheme, $subpath];
70 70
     }
71 71
 
72 72
 
73
-    public static function getHomePath():?string {
73
+    public static function getHomePath(): ?string {
74 74
         if (defined('USER_HOME_PATH')) {
75 75
             return constant('USER_HOME_PATH');
76 76
         }
Please login to merge, or discard this patch.
nebula/src/component/loader/LoaderAwareTrait.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@
 block discarded – undo
5 5
 
6 6
 trait LoaderAwareTrait
7 7
 {
8
-     /**
9
-     * 加载器
10
-     *
11
-     * @var Loader
12
-     */
8
+        /**
9
+         * 加载器
10
+         *
11
+         * @var Loader
12
+         */
13 13
     protected $loader;
14 14
 
15 15
     
Please login to merge, or discard this patch.
nebula/src/component/loader/Loader.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @param string $className
57 57
      * @return string|null
58 58
      */
59
-    public  function getClassPath(string $className):?string
59
+    public  function getClassPath(string $className): ?string
60 60
     {
61 61
         // 搜索路径
62 62
         foreach ($this->includePath as $includeNamespace => $includePaths) {
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
      * @param string $className
79 79
      * @return string|null
80 80
      */
81
-    protected  function getClassPathByAlias(string $includePath, string $className):?string
81
+    protected  function getClassPathByAlias(string $includePath, string $className): ?string
82 82
     {
83
-        $namepath=static::formatSeparator($className);
84
-        $className=static::realName($className);
83
+        $namepath = static::formatSeparator($className);
84
+        $className = static::realName($className);
85 85
         foreach ($this->namespace as $namespace) {
86 86
             $path = $includePath.DIRECTORY_SEPARATOR.$namespace.DIRECTORY_SEPARATOR.$namepath.'.php';
87 87
             if ($path = static::realPath($path)) {
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
      * @param string $className
104 104
      * @return string|null
105 105
      */
106
-    protected  function getClassPathByName(string $includeNamespace, string $includePath, string $className):?string
106
+    protected  function getClassPathByName(string $includeNamespace, string $includePath, string $className): ?string
107 107
     {
108 108
         if (is_numeric($includeNamespace)) {
109 109
             $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php';
110 110
         } else {
111 111
             $nl = strlen($includeNamespace);
112 112
             if (substr(static::realName($className), 0, $nl) === $includeNamespace) {
113
-                $path=$includePath.DIRECTORY_SEPARATOR.static::formatSeparator(substr($className, $nl)).'.php';
113
+                $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator(substr($className, $nl)).'.php';
114 114
             } else {
115
-                $path=$includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php';
115
+                $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php';
116 116
             }
117 117
         }
118 118
         if ($path = static::realPath($path)) {
Please login to merge, or discard this patch.
nebula/src/component/runnable/Runnable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * 可执行命令表达式
13 13
  *
14 14
  */
15
-class Runnable   {
15
+class Runnable {
16 16
 
17 17
     /**
18 18
      * 运行对象
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     protected $target;
23 23
 
24
-    public function __construct($runnable, array $parameter=[]) {
24
+    public function __construct($runnable, array $parameter = []) {
25 25
         $this->target = TargetBuilder::build($runnable, $parameter);
26 26
     }
27 27
 
Please login to merge, or discard this patch.