本文整理汇总了PHP中Symfony\Component\Console\Input\InputInterface::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP InputInterface::__toString方法的具体用法?PHP InputInterface::__toString怎么用?PHP InputInterface::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\InputInterface
的用法示例。
在下文中一共展示了InputInterface::__toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run(InputInterface $input, OutputInterface $output)
{
// extract real command name
$tokens = preg_split('{\\s+}', $input->__toString());
$args = array();
foreach ($tokens as $token) {
if ($token && $token[0] !== '-') {
$args[] = $token;
if (count($args) >= 2) {
break;
}
}
}
// show help for this command if no command was found
if (count($args) < 2) {
return parent::run($input, $output);
}
// change to global dir
$config = Factory::createConfig();
chdir($config->get('home'));
$this->getIO()->writeError('<info>Changed current directory to ' . $config->get('home') . '</info>');
// create new input without "global" command prefix
$input = new StringInput(preg_replace('{\\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\\b}', '', $input->__toString(), 1));
$this->getApplication()->resetComposer();
return $this->getApplication()->run($input, $output);
}
示例2: run
public function run(InputInterface $input, OutputInterface $output)
{
$options = $input->__toString();
$arr = explode(' ', $options);
array_shift($arr);
foreach ($arr as $i => &$option) {
$option = trim($option, "'");
if (strpos($option, '-') === 0) {
$option = '{' . $option . '?}';
} else {
$option = '{k' . $i . '}';
}
}
$this->signature = implode(' ', $arr);
$this->configureUsingFluentDefinition();
$this->setDescription($this->description);
return parent::run($input, $output);
}
示例3: run
public function run(InputInterface $input, OutputInterface $output)
{
$tokens = preg_split('{\\s+}', $input->__toString());
$args = array();
foreach ($tokens as $token) {
if ($token && $token[0] !== '-') {
$args[] = $token;
if (count($args) >= 2) {
break;
}
}
}
if (count($args) < 2) {
return parent::run($input, $output);
}
$config = Factory::createConfig();
chdir($config->get('home'));
$this->getIO()->writeError('<info>Changed current directory to ' . $config->get('home') . '</info>');
$input = new StringInput(preg_replace('{\\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\\b}', '', $input->__toString(), 1));
return $this->getApplication()->run($input, $output);
}