@@ -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 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | if ($fileStart === 0) { |
| 24 | 24 | return new FileTarget(substr($command, 1)); |
| 25 | 25 | } |
| 26 | - $requireFile = substr($command, $fileStart+1); |
|
| 26 | + $requireFile = substr($command, $fileStart + 1); |
|
| 27 | 27 | $command = substr($command, 0, $fileStart); |
| 28 | 28 | // for parameter list |
| 29 | 29 | list($command, $parameter) = self::splitParameter($command); |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | $dynmicsMethod; |
| 35 | 35 | $parameter = self::buildParameter($parameter); |
| 36 | 36 | if ($methodStart > 0) { |
| 37 | - $splitLength = $splitLength > 0 ? 1:2; |
|
| 37 | + $splitLength = $splitLength > 0 ? 1 : 2; |
|
| 38 | 38 | $methodName = substr($command, $methodStart + $splitLength); |
| 39 | 39 | $command = substr($command, 0, $methodStart); |
| 40 | 40 | list($className, $constructParameter) = self::splitParameter($command); |
| 41 | 41 | $constructParameter = self::buildParameter($constructParameter); |
| 42 | - return new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter); |
|
| 42 | + return new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter); |
|
| 43 | 43 | } else { |
| 44 | 44 | return new FunctionTarget(self::buildName($command), $parameter); |
| 45 | 45 | } |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) { |
| 51 | 51 | throw new \Exception(\sprintf('invaild command name: %s ', $name)); |
| 52 | 52 | } |
| 53 | - return str_replace(['.','/'], '\\', $name); |
|
| 53 | + return str_replace(['.', '/'], '\\', $name); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | private static function splitParameter(string $command):array |
| 57 | 57 | { |
| 58 | 58 | $parameter = null; |
| 59 | - if (strrpos($command, ')') === strlen($command) -1) { |
|
| 59 | + if (strrpos($command, ')') === strlen($command) - 1) { |
|
| 60 | 60 | $paramStart = strpos($command, '('); |
| 61 | 61 | $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2); |
| 62 | 62 | $command = substr($command, 0, $paramStart); |
| 63 | 63 | } |
| 64 | - return [$command,$parameter]; |
|
| 64 | + return [$command, $parameter]; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | private static function buildParameter(?string $parameter) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | if (strpos($value, ':') === 0) { |
| 81 | 81 | $value = base64_decode(substr($value, 1)); |
| 82 | 82 | } |
| 83 | - if ($prefix ==='=j' || $prefix ==='=json') { |
|
| 83 | + if ($prefix === '=j' || $prefix === '=json') { |
|
| 84 | 84 | $params = json_decode($value); |
| 85 | 85 | if (json_last_error() === JSON_ERROR_NONE) { |
| 86 | 86 | return $params; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } else { |
| 97 | 97 | $params = explode(',', trim($param, ',')); |
| 98 | 98 | foreach ($params as $index=>$value) { |
| 99 | - $params[$index]=trim($value); |
|
| 99 | + $params[$index] = trim($value); |
|
| 100 | 100 | } |
| 101 | 101 | return $params; |
| 102 | 102 | } |