@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param mixed $def |
88 | 88 | * @return array 设置后的数组 |
89 | 89 | */ |
90 | - public static function set(array &$array, string $name, $value, $def=null):array |
|
90 | + public static function set(array &$array, string $name, $value, $def = null):array |
|
91 | 91 | { |
92 | 92 | $path = explode('.', $name); |
93 | 93 | $root = &$array; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $array[$key] = []; |
99 | 99 | } |
100 | 100 | } else { |
101 | - $array=[]; |
|
101 | + $array = []; |
|
102 | 102 | } |
103 | 103 | $array = &$array[$key]; |
104 | 104 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $array[$key] = []; |
122 | 122 | } |
123 | 123 | } else { |
124 | - $array=[]; |
|
124 | + $array = []; |
|
125 | 125 | } |
126 | 126 | $array = &$array[$key]; |
127 | 127 | } |
@@ -40,11 +40,11 @@ |
||
40 | 40 | $exstr = ''; |
41 | 41 | foreach ($array as $key => $value) { |
42 | 42 | $line = ''; |
43 | - $current=$arrname."['".addslashes($key)."']"; |
|
43 | + $current = $arrname."['".addslashes($key)."']"; |
|
44 | 44 | if (is_array($value)) { |
45 | 45 | $line .= self::parserArraySub($current, $value); |
46 | 46 | } else { |
47 | - $line = $current; |
|
47 | + $line = $current; |
|
48 | 48 | if (is_string($value)) { |
49 | 49 | $line .= "='".addslashes($value).'\';'.PHP_EOL; |
50 | 50 | } elseif (is_bool($value)) { |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | protected $function; |
19 | 19 | |
20 | - public function __construct(string $name, array $parameter =[]) { |
|
20 | + public function __construct(string $name, array $parameter = []) { |
|
21 | 21 | $this->setParameter($parameter); |
22 | 22 | $this->function = $name; |
23 | 23 | } |
@@ -46,14 +46,14 @@ discard block |
||
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 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | if (!is_null($this->requireFile) && !\class_exists($this->object)) { |
66 | 66 | require_once $this->requireFile; |
67 | 67 | } |
68 | - $classRef= new ReflectionClass($this->object); |
|
68 | + $classRef = new ReflectionClass($this->object); |
|
69 | 69 | return $classRef->newInstanceArgs($this->constructParameter); |
70 | 70 | } |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | if ($this->isStatic() || \is_object($this->object)) { |
76 | 76 | $this->runnableTarget = [$this->object, $this->method]; |
77 | 77 | } |
78 | - $this->runnableTarget = [$this->getObjectInstance(), $this->method]; |
|
78 | + $this->runnableTarget = [$this->getObjectInstance(), $this->method]; |
|
79 | 79 | } |
80 | 80 | return $this->runnableTarget; |
81 | 81 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * 可执行命令表目标 |
6 | 6 | * |
7 | 7 | */ |
8 | -abstract class RunnableTarget { |
|
8 | +abstract class RunnableTarget { |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * 参数 |
@@ -15,9 +15,9 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if ($fileStart === 0) { |
48 | 48 | return new FileTarget(substr($command, 1)); |
49 | 49 | } |
50 | - $requireFile = substr($command, $fileStart+1); |
|
50 | + $requireFile = substr($command, $fileStart + 1); |
|
51 | 51 | $command = substr($command, 0, $fileStart); |
52 | 52 | // for parameter list |
53 | 53 | list($command, $parameter) = self::splitParameter($command); |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | $dynmicsMethod; |
59 | 59 | $parameter = self::buildParameter($parameter); |
60 | 60 | if ($methodStart > 0) { |
61 | - $splitLength = $splitLength > 0 ? 1:2; |
|
61 | + $splitLength = $splitLength > 0 ? 1 : 2; |
|
62 | 62 | $methodName = substr($command, $methodStart + $splitLength); |
63 | 63 | $command = substr($command, 0, $methodStart); |
64 | 64 | list($className, $constructParameter) = self::splitParameter($command); |
65 | 65 | $constructParameter = self::buildParameter($constructParameter); |
66 | - $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter); |
|
66 | + $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter); |
|
67 | 67 | } else { |
68 | 68 | $target = new FunctionTarget(self::buildName($command), $parameter); |
69 | 69 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | if (is_null($parameter)) { |
81 | 81 | return new $classRelName; |
82 | 82 | } |
83 | - $parameters=self::buildParameter($parameter); |
|
84 | - $classRef= new ReflectionClass($classRelName); |
|
83 | + $parameters = self::buildParameter($parameter); |
|
84 | + $classRef = new ReflectionClass($classRelName); |
|
85 | 85 | return $classRef->newInstanceArgs($parameters); |
86 | 86 | } |
87 | 87 | |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) { |
91 | 91 | throw new \Exception(\sprintf('invaild command name: %s ', $name)); |
92 | 92 | } |
93 | - return str_replace(['.','/'], '\\', $name); |
|
93 | + return str_replace(['.', '/'], '\\', $name); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | private static function splitParameter(string $command):array |
97 | 97 | { |
98 | 98 | $parameter = null; |
99 | - if (strrpos($command, ')') === strlen($command) -1) { |
|
99 | + if (strrpos($command, ')') === strlen($command) - 1) { |
|
100 | 100 | $paramStart = strpos($command, '('); |
101 | 101 | $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2); |
102 | 102 | $command = substr($command, 0, $paramStart); |
103 | 103 | } |
104 | - return [$command,$parameter]; |
|
104 | + return [$command, $parameter]; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | private static function buildParameter(?string $parameter) |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | if (strpos($value, ':') === 0) { |
121 | 121 | $value = base64_decode(substr($value, 1)); |
122 | 122 | } |
123 | - if ($prefix ==='=j' || $prefix ==='=json') { |
|
123 | + if ($prefix === '=j' || $prefix === '=json') { |
|
124 | 124 | $params = json_decode($value); |
125 | 125 | if (json_last_error() === JSON_ERROR_NONE) { |
126 | 126 | return $params; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } else { |
137 | 137 | $params = explode(',', trim($param, ',')); |
138 | 138 | foreach ($params as $index=>$value) { |
139 | - $params[$index]=trim($value); |
|
139 | + $params[$index] = trim($value); |
|
140 | 140 | } |
141 | 141 | return $params; |
142 | 142 | } |
@@ -17,7 +17,7 @@ |
||
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()'; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * 可执行命令表达式 |
13 | 13 | * |
14 | 14 | */ |
15 | -class Runnable { |
|
15 | +class Runnable { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * 运行对象 |
@@ -21,7 +21,7 @@ discard block |
||
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 |