@@ -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 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * 可执行命令表目标 |
6 | 6 | * |
7 | 7 | */ |
8 | -abstract class RunnableTarget { |
|
8 | +abstract class RunnableTarget { |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * 参数 |
@@ -52,7 +52,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -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 | } |
@@ -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 |
@@ -85,7 +85,7 @@ |
||
85 | 85 | if (is_null($this->pdo)) { |
86 | 86 | try { |
87 | 87 | $this->pdo = new PDO($this->getDsn(), $this->config['database-user'], $this->config['database-password']); |
88 | - static::$connetionCount ++; |
|
88 | + static::$connetionCount++; |
|
89 | 89 | } catch (PDOException $e) { |
90 | 90 | throw new ConnectionException($e->getMessage(), $e->getCode()); |
91 | 91 | } |
@@ -40,11 +40,11 @@ |
||
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 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $this->content = $content; |
40 | 40 | $this->name = $name; |
41 | 41 | $this->open = $open; |
42 | - $this->close= $close; |
|
42 | + $this->close = $close; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function compile(string $content):string |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | public function parseEchoValue($var):string |
7 | 7 | { |
8 | 8 | // 任意变量名: 中文点下划线英文数字 |
9 | - $code = preg_replace_callback('/\B[$](\?)?[:]([.\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )?/ux', [$this,'echoValueCallback'], $var); |
|
9 | + $code = preg_replace_callback('/\B[$](\?)?[:]([.\w\x{4e00}-\x{9aff}]+)(\s*)(\( ( (?>[^()]+) | (?4) )* \) )?/ux', [$this, 'echoValueCallback'], $var); |
|
10 | 10 | $error = preg_last_error(); |
11 | 11 | if ($error !== PREG_NO_ERROR) { |
12 | 12 | throw new \Exception($error); |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | |
17 | 17 | protected function echoValueCallback($matchs) |
18 | 18 | { |
19 | - $name=$matchs[2]; |
|
20 | - if ($matchs[1]==='?') { |
|
19 | + $name = $matchs[2]; |
|
20 | + if ($matchs[1] === '?') { |
|
21 | 21 | return '$this->has("'.$name.'")'; |
22 | 22 | } |
23 | 23 | if (isset($matchs[4])) { |
24 | 24 | if (preg_match('/\((.+)\)/', $matchs[4], $v)) { |
25 | 25 | $args = trim($v[1]); |
26 | - $args= strlen($args) ?','.$args:''; |
|
26 | + $args = strlen($args) ? ','.$args : ''; |
|
27 | 27 | return '$this->get("'.$name.'"'.$args.')'; |
28 | 28 | } |
29 | 29 | } |