Passed
Push — master ( 1c163d...8b0ed1 )
by 世昌
02:04
created
nebula/src/component/runnable/target/ClosureTarget.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      */
18 18
     protected $closure;
19 19
     
20
-    public function __construct(Closure $closure, array $parameter =[]) {
20
+    public function __construct(Closure $closure, array $parameter = []) {
21 21
         $this->closure = $closure;
22 22
         $this->parameter = $parameter;
23 23
         $this->name = 'Closure object()';
Please login to merge, or discard this patch.
nebula/src/component/runnable/target/MethodTarget.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
      * @param string $method
47 47
      * @param array $parameter
48 48
      */
49
-    public function __construct($object, ?array $constructParameter=null, string $method, array $parameter = [])
49
+    public function __construct($object, ?array $constructParameter = null, string $method, array $parameter = [])
50 50
     {
51 51
         $this->object = $object;
52 52
         $this->constructParameter = $constructParameter;
53 53
         $this->method = $method;
54 54
         $this->parameter = $parameter;
55 55
         $static = $this->isStatic() ? '->' : '::';
56
-        $name = \is_object($object)? \get_class($object) : $object;
56
+        $name = \is_object($object) ? \get_class($object) : $object;
57 57
         $this->name = $name.$static.$method;
58 58
     }
59 59
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      *
63 63
      * @return object|null 动态类可获取
64 64
      */
65
-    public function getObjectInstance():?object
65
+    public function getObjectInstance(): ?object
66 66
     {
67 67
         if (\is_object($this->object)) {
68 68
             return $this->object;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         if (!is_null($this->requireFile) && !\class_exists($this->object)) {
74 74
             require_once $this->requireFile;
75 75
         }
76
-        $classRef= new ReflectionClass($this->object);
76
+        $classRef = new ReflectionClass($this->object);
77 77
         return $classRef->newInstanceArgs($this->constructParameter);
78 78
     }
79 79
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             if ($this->isStatic() || \is_object($this->object)) {
84 84
                 $this->runnableTarget = [$this->object, $this->method];
85 85
             }
86
-            $this->runnableTarget =  [$this->getObjectInstance() ?? $this->object, $this->method];
86
+            $this->runnableTarget = [$this->getObjectInstance() ?? $this->object, $this->method];
87 87
         }
88 88
         return $this->runnableTarget;
89 89
     }
Please login to merge, or discard this patch.
nebula/src/component/runnable/target/TargetBuilder.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         }
53 53
         $requireFile = '';
54 54
         if ($fileStart > 0) {
55
-            $requireFile = substr($command, $fileStart+1);
55
+            $requireFile = substr($command, $fileStart + 1);
56 56
             $command = substr($command, 0, $fileStart);
57 57
         }
58 58
         // for parameter list
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
         $dynmicsMethod;
65 65
         $parameter = self::buildParameter($parameter);
66 66
         if ($methodStart > 0) {
67
-            $splitLength = $splitLength > 0 ? 1:2;
67
+            $splitLength = $splitLength > 0 ? 1 : 2;
68 68
             $methodName = substr($command, $methodStart + $splitLength);
69 69
             $command = substr($command, 0, $methodStart);
70 70
             list($className, $constructParameter) = self::splitParameter($command);
71 71
             $constructParameter = self::buildParameter($constructParameter);
72
-            $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter);
72
+            $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter);
73 73
         } else {
74 74
             $target = new FunctionTarget(self::buildName($command), $parameter);
75 75
         }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
         if (is_null($parameter)) {
87 87
             return new  $classRelName;
88 88
         }
89
-        $parameters=self::buildParameter($parameter);
90
-        $classRef= new ReflectionClass($classRelName);
89
+        $parameters = self::buildParameter($parameter);
90
+        $classRef = new ReflectionClass($classRelName);
91 91
         return $classRef->newInstanceArgs($parameters);
92 92
     }
93 93
 
@@ -96,18 +96,18 @@  discard block
 block discarded – undo
96 96
         if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) {
97 97
             throw new InvalidNameException(\sprintf('invaild name: %s ', $name));
98 98
         }
99
-        return  str_replace(['.','/'], '\\', $name);
99
+        return  str_replace(['.', '/'], '\\', $name);
100 100
     }
101 101
 
102 102
     private static function splitParameter(string $command):array
103 103
     {
104 104
         $parameter = null;
105
-        if (strrpos($command, ')') === strlen($command) -1) {
105
+        if (strrpos($command, ')') === strlen($command) - 1) {
106 106
             $paramStart = strpos($command, '(');
107 107
             $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2);
108 108
             $command = substr($command, 0, $paramStart);
109 109
         }
110
-        return [$command,$parameter];
110
+        return [$command, $parameter];
111 111
     }
112 112
 
113 113
     private static function buildParameter(?string $parameter)
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             if (strpos($value, ':') === 0) {
127 127
                 $value = base64_decode(substr($value, 1));
128 128
             }
129
-            if ($prefix ==='=j' || $prefix ==='=json') {
129
+            if ($prefix === '=j' || $prefix === '=json') {
130 130
                 $params = json_decode($value);
131 131
                 if (json_last_error() === JSON_ERROR_NONE) {
132 132
                     return $params;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         } else {
143 143
             $params = explode(',', trim($param, ','));
144 144
             foreach ($params as $index=>$value) {
145
-                $params[$index]=trim($value);
145
+                $params[$index] = trim($value);
146 146
             }
147 147
             return $params;
148 148
         }
Please login to merge, or discard this patch.
nebula/src/component/runnable/target/FileTarget.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
      *
16 16
      * @var string|null
17 17
      */
18
-    protected $requireFile=null;
18
+    protected $requireFile = null;
19 19
     
20
-    public function __construct(string $path, array $parameter =[]) {
20
+    public function __construct(string $path, array $parameter = []) {
21 21
         $this->setRequireFile($path);
22 22
         $this->setParameter($parameter);
23 23
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function setRequireFile($requireFile)
48 48
     {
49 49
         $this->requireFile = $requireFile;
50
-        $this->name ='@'.$requireFile;
50
+        $this->name = '@'.$requireFile;
51 51
         return $this;
52 52
     }
53 53
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
             $args = $this->getParameter();
74 74
         }
75 75
         array_unshift($args, $this->requireFile);
76
-        $_SERVER['argv']=$args;
77
-        $_SERVER['args']=count($args);
76
+        $_SERVER['argv'] = $args;
77
+        $_SERVER['args'] = count($args);
78 78
         return include $this->requireFile;
79 79
     }
80 80
 }
Please login to merge, or discard this patch.
nebula/src/component/debug/attach/DumpInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  */
7 7
 interface DumpInterface 
8 8
 {
9
-    public static function parameterToString($object, int $deep=2);
9
+    public static function parameterToString($object, int $deep = 2);
10 10
     public static function dumpException(\Exception $e);
11
-    public static function dumpTrace(array $backtrace, bool $str=true, string $perfix='');
11
+    public static function dumpTrace(array $backtrace, bool $str = true, string $perfix = '');
12 12
 }
Please login to merge, or discard this patch.
nebula/src/component/debug/attach/DumpTrait.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
         if ($deep > 0) {
16 16
             $vars = get_class_vars($objectName);
17 17
             foreach ($vars as $key => $value) {
18
-                $parameterString.=static::valueToString($key, $value, $deep);
18
+                $parameterString .= static::valueToString($key, $value, $deep);
19 19
             }
20
-            $parameterString.= static::objectGetter($objectName, $object, $deep);
20
+            $parameterString .= static::objectGetter($objectName, $object, $deep);
21 21
         } else {
22 22
             $parameterString = '...';
23 23
         }
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
     protected static function objectGetter(string $objectName, object $object, int $deep)
28 28
     {
29 29
         $methods = get_class_methods($objectName);
30
-        $parameterString ='';
30
+        $parameterString = '';
31 31
         foreach ($methods as $method) {
32 32
             if (strpos($method, 'get') === 0) {
33 33
                 $methodRef = new \ReflectionMethod($object, $method);
34 34
                 $ignore = \preg_match('/@ignore(-d|D)ump/i', $methodRef->getDocComment()??'') > 0;
35 35
                 if (count($methodRef->getParameters()) === 0 && !$ignore) {
36
-                    $parameterString.=static::valueToString($method.'()', $object->$method(), $deep);
36
+                    $parameterString .= static::valueToString($method.'()', $object->$method(), $deep);
37 37
                 }
38 38
             }
39 39
         }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $parameterString = '';
46 46
         if ($deep > 0) {
47 47
             foreach ($array as $key => $value) {
48
-                $parameterString.=static::valueToString($key, $value, $deep);
48
+                $parameterString .= static::valueToString($key, $value, $deep);
49 49
             }
50 50
         } else {
51 51
             $parameterString = '...';
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
     protected static function valueToString(string $key, $value, int $deep):string
65 65
     {
66 66
         if (is_string($value) && strlen($value) > static::$dumpStringLength) {
67
-            return  $key.'='.json_encode(substr($value, 0, static::$dumpStringLength), JSON_UNESCAPED_UNICODE) .'... ,';
67
+            return  $key.'='.json_encode(substr($value, 0, static::$dumpStringLength), JSON_UNESCAPED_UNICODE).'... ,';
68 68
         } elseif (is_bool($value)) {
69 69
             return $key.'='.($value ? 'true' : 'false').' ,';
70 70
         } else {
71
-            return $key.'='.self::parameterToString($value, $deep-1) .' ,';
71
+            return $key.'='.self::parameterToString($value, $deep - 1).' ,';
72 72
         }
73 73
     }
74 74
 
75
-    public static function parameterToString($object, int $deep=2)
75
+    public static function parameterToString($object, int $deep = 2)
76 76
     {
77 77
         if (is_null($object)) {
78 78
             return 'NULL';
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
         return $object;
87 87
     }
88 88
 
89
-    public static function dumpTrace(array $backtrace, bool $str=true, string $perfix='')
89
+    public static function dumpTrace(array $backtrace, bool $str = true, string $perfix = '')
90 90
     {
91
-        $tracesConsole=[];
91
+        $tracesConsole = [];
92 92
         foreach ($backtrace as $trace) {
93
-            $tracesConsole[]=static::buildTraceLine($trace);
93
+            $tracesConsole[] = static::buildTraceLine($trace);
94 94
         }
95 95
         if ($str) {
96
-            $str='';
96
+            $str = '';
97 97
             foreach ($tracesConsole as $trace_info) {
98
-                $str.=$perfix.preg_replace('/\n/', "\n".$perfix."\t", $trace_info).PHP_EOL;
98
+                $str .= $perfix.preg_replace('/\n/', "\n".$perfix."\t", $trace_info).PHP_EOL;
99 99
             }
100 100
             return $str;
101 101
         }
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
         } else {
114 114
             $function = $trace['function'];
115 115
         }
116
-        $argsDump='';
116
+        $argsDump = '';
117 117
         if (!empty($trace['args'])) {
118 118
             foreach ($trace['args'] as $arg) {
119
-                $argsDump.= self::parameterToString($arg) .',';
119
+                $argsDump .= self::parameterToString($arg).',';
120 120
             }
121 121
             $argsDump = rtrim($argsDump, ',');
122 122
         }
123
-        $line.=' '.$function.'('.$argsDump.')';
123
+        $line .= ' '.$function.'('.$argsDump.')';
124 124
         return $line;
125 125
     }
126 126
 
127 127
     public static function dumpException(\Exception $e)
128 128
     {
129
-        $dump = get_class($e).':'. $e->getMessage() .PHP_EOL;
130
-        $dump.= 'At: ' . $e->getFile().':'.$e->getLine().PHP_EOL;
131
-        $dump.= static::dumpTrace($e->getTrace());
129
+        $dump = get_class($e).':'.$e->getMessage().PHP_EOL;
130
+        $dump .= 'At: '.$e->getFile().':'.$e->getLine().PHP_EOL;
131
+        $dump .= static::dumpTrace($e->getTrace());
132 132
         return $dump;
133 133
     }
134 134
 }
Please login to merge, or discard this patch.
nebula/src/component/debug/Debug.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 class Debug implements LoggerInterface, LoggerAwareInterface, DumpInterface, AttachInterface, ConfigInterface
18 18
 {
19
-    use LoggerTrait,LoggerAwareTrait,DumpTrait,AttachTrait,ConfigTrait;
19
+    use LoggerTrait, LoggerAwareTrait, DumpTrait, AttachTrait, ConfigTrait;
20 20
 
21 21
     /**
22 22
      * 时间记录
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $replace = [];
53 53
         foreach ($context as $key => $val) {
54
-            $replace['{' . $key . '}'] = $val;
54
+            $replace['{'.$key.'}'] = $val;
55 55
         }
56 56
         return strtr($message, $replace);
57 57
     }
@@ -67,26 +67,26 @@  discard block
 block discarded – undo
67 67
         return $attribute;
68 68
     }
69 69
 
70
-    protected static function formatBytes(int $bytes, int $precision=0)
70
+    protected static function formatBytes(int $bytes, int $precision = 0)
71 71
     {
72
-        $human= ['B', 'KB', 'MB', 'GB', 'TB'];
72
+        $human = ['B', 'KB', 'MB', 'GB', 'TB'];
73 73
         $bytes = max($bytes, 0);
74
-        $pow = floor(($bytes?log($bytes):0)/log(1024));
75
-        $pos = min($pow, count($human)-1);
76
-        $bytes /= (1 << (10* $pos));
74
+        $pow = floor(($bytes ?log($bytes) : 0) / log(1024));
75
+        $pos = min($pow, count($human) - 1);
76
+        $bytes /= (1 << (10 * $pos));
77 77
         return round($bytes, $precision).' '.$human[$pos];
78 78
     }
79 79
 
80
-    public function time(string $name, string $type= LogLevel::INFO)
80
+    public function time(string $name, string $type = LogLevel::INFO)
81 81
     {
82
-        $this->timeRecord[$name]=['time'=>microtime(true),'level'=>$type];
82
+        $this->timeRecord[$name] = ['time'=>microtime(true), 'level'=>$type];
83 83
     }
84 84
 
85 85
     public function timeEnd(string $name)
86 86
     {
87 87
         if (\array_key_exists($name, $this->timeRecord)) {
88
-            $pass=microtime(true)-$this->timeRecord[$name]['time'];
89
-            $this->log($this->timeRecord[$name]['level'], 'process cost '. $name.' '. number_format($pass, 5).'s');
88
+            $pass = microtime(true) - $this->timeRecord[$name]['time'];
89
+            $this->log($this->timeRecord[$name]['level'], 'process cost '.$name.' '.number_format($pass, 5).'s');
90 90
             return $pass;
91 91
         }
92 92
         return 0;
Please login to merge, or discard this patch.
nebula/src/component/debug/Caller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
     protected $ignorePath = [__FILE__];
10 10
     protected $backtrace;
11 11
 
12
-    public function __construct(array $backtrace, array $ignorePath =[])
12
+    public function __construct(array $backtrace, array $ignorePath = [])
13 13
     {
14 14
         $this->ignorePath = \array_merge($this->ignorePath, $ignorePath);
15 15
         $this->backtrace = $backtrace;
16 16
     }
17 17
 
18
-    public function getCallerTrace():?array
18
+    public function getCallerTrace(): ?array
19 19
     {
20 20
         foreach ($this->backtrace as $trace) {
21 21
             if (array_key_exists('file', $trace)) {
Please login to merge, or discard this patch.
nebula/src/component/debug/log/logger/ConsoleLogger.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 {
11 11
     public function log($level, string $message, array $context = [])
12 12
     {
13
-        print date('Y-m-d H:i:s') .' ' . $this->interpolate($message, $context) . PHP_EOL;
13
+        print date('Y-m-d H:i:s').' '.$this->interpolate($message, $context).PHP_EOL;
14 14
     }
15 15
     public function interpolate(string $message, array $context)
16 16
     {
17 17
         $replace = [];
18 18
         foreach ($context as $key => $val) {
19
-            $replace['{' . $key . '}'] = $val;
19
+            $replace['{'.$key.'}'] = $val;
20 20
         }
21 21
         return strtr($message, $replace);
22 22
     }
Please login to merge, or discard this patch.