@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public function __construct($actionName, $name) |
| 37 | 37 | { |
| 38 | - parent::__construct($name?:$actionName); |
|
| 38 | + parent::__construct($name ?: $actionName); |
|
| 39 | 39 | $this->actionName = $actionName; |
| 40 | 40 | } |
| 41 | 41 | /** |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function postCreate(ConsoleContainer $container) |
| 50 | 50 | { |
| 51 | - if($container->getModuleName()){ |
|
| 51 | + if ($container->getModuleName()) { |
|
| 52 | 52 | $this->setName($container->getModuleName().'.'.$this->getName()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - foreach ($this->paramMetas as $paramMeta){ |
|
| 56 | - $mode = $paramMeta->isOptional?InputArgument::OPTIONAL:InputArgument::REQUIRED; |
|
| 57 | - if($paramMeta->container instanceof ArrayContainer || $paramMeta->container instanceof EntityContainer){ |
|
| 58 | - $mode = $mode|InputArgument::IS_ARRAY; |
|
| 55 | + foreach ($this->paramMetas as $paramMeta) { |
|
| 56 | + $mode = $paramMeta->isOptional ?InputArgument::OPTIONAL : InputArgument::REQUIRED; |
|
| 57 | + if ($paramMeta->container instanceof ArrayContainer || $paramMeta->container instanceof EntityContainer) { |
|
| 58 | + $mode = $mode | InputArgument::IS_ARRAY; |
|
| 59 | 59 | } |
| 60 | 60 | $this->addArgument($paramMeta->name, |
| 61 | 61 | $mode, |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | public function getParamMeta($name) |
| 69 | 69 | { |
| 70 | - foreach ($this->paramMetas as $meta){ |
|
| 71 | - if($meta->name == $name){ |
|
| 70 | + foreach ($this->paramMetas as $meta) { |
|
| 71 | + if ($meta->name == $name) { |
|
| 72 | 72 | return $meta; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -84,40 +84,40 @@ discard block |
||
| 84 | 84 | * @throws \DI\DependencyException |
| 85 | 85 | * @throws \DI\NotFoundException |
| 86 | 86 | */ |
| 87 | - public function invoke(FactoryInterface $factory,ConsoleContainer $container, InputInterface $input, OutputInterface $output) |
|
| 87 | + public function invoke(FactoryInterface $factory, ConsoleContainer $container, InputInterface $input, OutputInterface $output) |
|
| 88 | 88 | { |
| 89 | 89 | $params = []; |
| 90 | 90 | $reference = []; |
| 91 | - $this->bindInput($input, $params,$reference); |
|
| 91 | + $this->bindInput($input, $params, $reference); |
|
| 92 | 92 | $code = call_user_func_array([$container->getInstance($factory), $this->actionName], $params); |
| 93 | 93 | return $code; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function bindInput(InputInterface $input, array &$params, array &$reference){ |
|
| 96 | + public function bindInput(InputInterface $input, array &$params, array &$reference) { |
|
| 97 | 97 | $vld = new Validator(); |
| 98 | 98 | $req = ['argv'=>$input->getArguments()]; |
| 99 | 99 | $requestArray = new ArrayAdaptor($req); |
| 100 | 100 | $inputs = []; |
| 101 | - foreach ($this->paramMetas as $k=>$meta){ |
|
| 102 | - if($meta->isPassedByReference){ |
|
| 101 | + foreach ($this->paramMetas as $k=>$meta) { |
|
| 102 | + if ($meta->isPassedByReference) { |
|
| 103 | 103 | // param PassedByReference is used to output |
| 104 | 104 | continue; |
| 105 | 105 | } |
| 106 | 106 | $source = \JmesPath\search($meta->source, $requestArray); |
| 107 | - if ($source !== null){ |
|
| 107 | + if ($source !== null) { |
|
| 108 | 108 | $source = ArrayAdaptor::strip($source); |
| 109 | - if($source instanceof ParameterBag){ |
|
| 109 | + if ($source instanceof ParameterBag) { |
|
| 110 | 110 | $source = $source->all(); |
| 111 | 111 | } |
| 112 | - if($meta->container){ |
|
| 112 | + if ($meta->container) { |
|
| 113 | 113 | $inputs[$meta->name] = $meta->container->make($source); |
| 114 | - }else{ |
|
| 114 | + }else { |
|
| 115 | 115 | $inputs[$meta->name] = $source; |
| 116 | 116 | } |
| 117 | - if($meta->validation){ |
|
| 117 | + if ($meta->validation) { |
|
| 118 | 118 | $vld->rule($meta->validation, $meta->name); |
| 119 | 119 | } |
| 120 | - }else{ |
|
| 120 | + }else { |
|
| 121 | 121 | $meta->isOptional or \PhpBoot\abort(new \InvalidArgumentException("the parameter \"{$meta->source}\" is missing")); |
| 122 | 122 | $inputs[$meta->name] = $meta->default; |
| 123 | 123 | } |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | 135 | $pos = 0; |
| 136 | - foreach ($this->paramMetas as $meta){ |
|
| 137 | - if($meta->isPassedByReference){ |
|
| 136 | + foreach ($this->paramMetas as $meta) { |
|
| 137 | + if ($meta->isPassedByReference) { |
|
| 138 | 138 | $params[$pos] = null; |
| 139 | - }else{ |
|
| 139 | + }else { |
|
| 140 | 140 | $params[$pos] = $inputs[$meta->name]; |
| 141 | 141 | } |
| 142 | 142 | $pos++; |