@@ -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,12 +84,12 @@ 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); |
|
92 | - ob_start(function ($test)use($output){ |
|
91 | + $this->bindInput($input, $params, $reference); |
|
92 | + ob_start(function($test)use($output){ |
|
93 | 93 | $output->write($test); |
94 | 94 | }); |
95 | 95 | $code = call_user_func_array([$container->getInstance($factory), $this->actionName], $params); |
@@ -97,31 +97,31 @@ discard block |
||
97 | 97 | return $code; |
98 | 98 | } |
99 | 99 | |
100 | - public function bindInput(InputInterface $input, array &$params, array &$reference){ |
|
100 | + public function bindInput(InputInterface $input, array &$params, array &$reference) { |
|
101 | 101 | $vld = new Validator(); |
102 | 102 | $req = ['argv'=>$input->getArguments()]; |
103 | 103 | $requestArray = new ArrayAdaptor($req); |
104 | 104 | $inputs = []; |
105 | - foreach ($this->paramMetas as $k=>$meta){ |
|
106 | - if($meta->isPassedByReference){ |
|
105 | + foreach ($this->paramMetas as $k=>$meta) { |
|
106 | + if ($meta->isPassedByReference) { |
|
107 | 107 | // param PassedByReference is used to output |
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | $source = \JmesPath\search($meta->source, $requestArray); |
111 | - if ($source !== null){ |
|
111 | + if ($source !== null) { |
|
112 | 112 | $source = ArrayAdaptor::strip($source); |
113 | - if($source instanceof ParameterBag){ |
|
113 | + if ($source instanceof ParameterBag) { |
|
114 | 114 | $source = $source->all(); |
115 | 115 | } |
116 | - if($meta->container){ |
|
116 | + if ($meta->container) { |
|
117 | 117 | $inputs[$meta->name] = $meta->container->make($source); |
118 | - }else{ |
|
118 | + }else { |
|
119 | 119 | $inputs[$meta->name] = $source; |
120 | 120 | } |
121 | - if($meta->validation){ |
|
121 | + if ($meta->validation) { |
|
122 | 122 | $vld->rule($meta->validation, $meta->name); |
123 | 123 | } |
124 | - }else{ |
|
124 | + }else { |
|
125 | 125 | $meta->isOptional or \PhpBoot\abort(new \InvalidArgumentException("the parameter \"{$meta->source}\" is missing")); |
126 | 126 | $inputs[$meta->name] = $meta->default; |
127 | 127 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | $pos = 0; |
140 | - foreach ($this->paramMetas as $meta){ |
|
141 | - if($meta->isPassedByReference){ |
|
140 | + foreach ($this->paramMetas as $meta) { |
|
141 | + if ($meta->isPassedByReference) { |
|
142 | 142 | $params[$pos] = null; |
143 | - }else{ |
|
143 | + }else { |
|
144 | 144 | $params[$pos] = $inputs[$meta->name]; |
145 | 145 | } |
146 | 146 | $pos++; |