@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $container = $this->consoleContainerBuilder->build($className); |
56 | 56 | /**@var ConsoleContainer $container*/ |
57 | 57 | foreach ($container->getCommands() as $name => $command) { |
58 | - $command->setCode(function (InputInterface $input, OutputInterface $output)use ($container, $command){ |
|
58 | + $command->setCode(function(InputInterface $input, OutputInterface $output)use ($container, $command){ |
|
59 | 59 | return $this->diInvoker->call([$command, 'invoke'], ['container'=>$container, 'input'=>$input, 'output'=>$output]); |
60 | 60 | }); |
61 | 61 | $this->add($command); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $dir = @dir($fromPath) or abort("dir $fromPath not exist"); |
73 | 73 | |
74 | - $getEach = function () use ($dir) { |
|
74 | + $getEach = function() use ($dir) { |
|
75 | 75 | $name = $dir->read(); |
76 | 76 | if (!$name) { |
77 | 77 | return $name; |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | if ($entry == '.' || $entry == '..') { |
84 | 84 | continue; |
85 | 85 | } |
86 | - $path = $fromPath . '/' . str_replace('\\', '/', $entry); |
|
86 | + $path = $fromPath.'/'.str_replace('\\', '/', $entry); |
|
87 | 87 | if (is_file($path) && substr_compare($entry, '.php', strlen($entry) - 4, 4, true) == 0) { |
88 | - $class_name = $namespace . '\\' . substr($entry, 0, strlen($entry) - 4); |
|
88 | + $class_name = $namespace.'\\'.substr($entry, 0, strlen($entry) - 4); |
|
89 | 89 | $this->loadCommandsFromClass($class_name); |
90 | - } else { |
|
90 | + }else { |
|
91 | 91 | //\Log::debug($path.' ignored'); |
92 | 92 | } |
93 | 93 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | public function getCommand($target) |
60 | 60 | { |
61 | - return isset($this->commands[$target])?$this->commands[$target]:null; |
|
61 | + return isset($this->commands[$target]) ? $this->commands[$target] : null; |
|
62 | 62 | } |
63 | 63 | /** |
64 | 64 | * @return string |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | public function postCreate() |
99 | 99 | { |
100 | - foreach ($this->commands as $command){ |
|
100 | + foreach ($this->commands as $command) { |
|
101 | 101 | $command->postCreate($this); |
102 | 102 | } |
103 | 103 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getInstance(FactoryInterface $factory) |
115 | 115 | { |
116 | - if(!$this->instance ){ |
|
117 | - $this->instance = $factory->make($this->getClassName()); |
|
116 | + if (!$this->instance) { |
|
117 | + $this->instance = $factory->make($this->getClassName()); |
|
118 | 118 | } |
119 | 119 | return $this->instance; |
120 | 120 | } |
@@ -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,11 +84,11 @@ 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 | ob_start(); |
93 | 93 | $code = call_user_func_array([$container->getInstance($factory), $this->actionName], $params); |
94 | 94 | $out = ob_get_contents(); |
@@ -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++; |