0
我们有一个symfony 2控制台命令应用程序。在命令内部(扩展为\Symfony\Component\Console\Command\Command
),我们调用另一个命令。再次调用应用程序 - >运行()
$this->getApplication()->run(new StringInput('cache:flush'), new NullOutput());
这是工作的罚款,直到更新到最新的Symfony版本
但现在我打的异常在下面的Symfony函数(\Symfony\Component\Console\Input\ArgvInput::parseArgument()
)
private function parseArgument($token)
{
$c = count($this->arguments); ## $c is 0 !
// if input is expecting another argument, add it
if ($this->definition->hasArgument($c)) {
$arg = $this->definition->getArgument($c);
$this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token;
// if last argument isArray(), append token to last argument
} elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
$arg = $this->definition->getArgument($c - 1);
$this->arguments[$arg->getName()][] = $token;
// unexpected argument
} else {
throw new \RuntimeException('Too many arguments.'); ### this exception is thrown
}
}
两个的命令(原始的一个dev:setup:run
和我们所说的cache:flush
)不需要pa rameters。
参考文献:https://github.com/netz98/n98-magerun/issues/90