| @@ -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 | } | 
| @@ -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 | } | 
| @@ -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 | |
| @@ -50,7 +50,7 @@ discard block | ||
| 50 | 50 | } | 
| 51 | 51 | $requireFile = ''; | 
| 52 | 52 |          if ($fileStart > 0) { | 
| 53 | - $requireFile = substr($command, $fileStart+1); | |
| 53 | + $requireFile = substr($command, $fileStart + 1); | |
| 54 | 54 | $command = substr($command, 0, $fileStart); | 
| 55 | 55 | } | 
| 56 | 56 | // for parameter list | 
| @@ -62,12 +62,12 @@ discard block | ||
| 62 | 62 | $dynmicsMethod; | 
| 63 | 63 | $parameter = self::buildParameter($parameter); | 
| 64 | 64 |          if ($methodStart > 0) { | 
| 65 | - $splitLength = $splitLength > 0 ? 1:2; | |
| 65 | + $splitLength = $splitLength > 0 ? 1 : 2; | |
| 66 | 66 | $methodName = substr($command, $methodStart + $splitLength); | 
| 67 | 67 | $command = substr($command, 0, $methodStart); | 
| 68 | 68 | list($className, $constructParameter) = self::splitParameter($command); | 
| 69 | 69 | $constructParameter = self::buildParameter($constructParameter); | 
| 70 | - $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter); | |
| 70 | + $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter); | |
| 71 | 71 |          } else { | 
| 72 | 72 | $target = new FunctionTarget(self::buildName($command), $parameter); | 
| 73 | 73 | } | 
| @@ -84,8 +84,8 @@ discard block | ||
| 84 | 84 |          if (is_null($parameter)) { | 
| 85 | 85 | return new $classRelName; | 
| 86 | 86 | } | 
| 87 | - $parameters=self::buildParameter($parameter); | |
| 88 | - $classRef= new ReflectionClass($classRelName); | |
| 87 | + $parameters = self::buildParameter($parameter); | |
| 88 | + $classRef = new ReflectionClass($classRelName); | |
| 89 | 89 | return $classRef->newInstanceArgs($parameters); | 
| 90 | 90 | } | 
| 91 | 91 | |
| @@ -94,18 +94,18 @@ discard block | ||
| 94 | 94 |          if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) { | 
| 95 | 95 |              throw new \Exception(\sprintf('invaild command name: %s ', $name)); | 
| 96 | 96 | } | 
| 97 | - return str_replace(['.','/'], '\\', $name); | |
| 97 | + return str_replace(['.', '/'], '\\', $name); | |
| 98 | 98 | } | 
| 99 | 99 | |
| 100 | 100 | private static function splitParameter(string $command):array | 
| 101 | 101 |      { | 
| 102 | 102 | $parameter = null; | 
| 103 | -        if (strrpos($command, ')') === strlen($command) -1) { | |
| 103 | +        if (strrpos($command, ')') === strlen($command) - 1) { | |
| 104 | 104 |              $paramStart = strpos($command, '('); | 
| 105 | 105 | $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2); | 
| 106 | 106 | $command = substr($command, 0, $paramStart); | 
| 107 | 107 | } | 
| 108 | - return [$command,$parameter]; | |
| 108 | + return [$command, $parameter]; | |
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | 111 | private static function buildParameter(?string $parameter) | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 |              if (strpos($value, ':') === 0) { | 
| 125 | 125 | $value = base64_decode(substr($value, 1)); | 
| 126 | 126 | } | 
| 127 | -            if ($prefix ==='=j' || $prefix ==='=json') { | |
| 127 | +            if ($prefix === '=j' || $prefix === '=json') { | |
| 128 | 128 | $params = json_decode($value); | 
| 129 | 129 |                  if (json_last_error() === JSON_ERROR_NONE) { | 
| 130 | 130 | return $params; | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 |          } else { | 
| 141 | 141 |              $params = explode(',', trim($param, ',')); | 
| 142 | 142 |              foreach ($params as $index=>$value) { | 
| 143 | - $params[$index]=trim($value); | |
| 143 | + $params[$index] = trim($value); | |
| 144 | 144 | } | 
| 145 | 145 | return $params; | 
| 146 | 146 | } | 
| @@ -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 | |
| @@ -62,7 +62,7 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | } |