Passed
Push — master ( 3a4432...bec3a0 )
by 世昌
01:45
created
nebula/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/route/RouteCollection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
      *
23 23
      * @param RouteMatcher[] $collection
24 24
      */
25
-    public function __construct(array $collection=[])
25
+    public function __construct(array $collection = [])
26 26
     {
27 27
         $this->collection = $collection;
28 28
     }
29 29
 
30
-    public function merge(array $collection=[]) {
30
+    public function merge(array $collection = []) {
31 31
         $this->collection = $collection;
32 32
     }
33 33
 
Please login to merge, or discard this patch.
nebula/route/collection/CollectionFile.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     public function save(string $path):bool
34 34
     {
35 35
         foreach ($this as $name => $value) {
36
-            if (\file_put_contents($path, $name .'|'. \serialize($value), FILE_APPEND) === false) {
36
+            if (\file_put_contents($path, $name.'|'.\serialize($value), FILE_APPEND) === false) {
37 37
                 return false;
38 38
             }
39 39
         }
Please login to merge, or discard this patch.
nebula/route/collection/ReadLineIterator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
             while (!feof($fp)) {
41 41
                 fseek($fp, $offset);
42 42
                 $content = fread($fp, $this->bufferSize);
43
-                $content.=(feof($fp))? "\n":'';
43
+                $content .= (feof($fp)) ? "\n" : '';
44 44
                 $size = strpos($content, "\n");
45 45
                 $offset += $size;
46 46
                 if ($content[$size - 1] === "\r") {
47
-                    $content = substr($content, 0, $size -1);
47
+                    $content = substr($content, 0, $size - 1);
48 48
                 } else {
49 49
                     $content = substr($content, 0, $size);
50 50
                 }
Please login to merge, or discard this patch.
nebula/route/RouteMatcher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@
 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;
Please login to merge, or discard this patch.