namespace Symfony\Component\Console\Input;
-use Symfony\Component\Console\Descriptor\TextDescriptor;
-use Symfony\Component\Console\Descriptor\XmlDescriptor;
-use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\LogicException;
* Usage:
*
* $definition = new InputDefinition(array(
- * new InputArgument('name', InputArgument::REQUIRED),
- * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),
+ * new InputArgument('name', InputArgument::REQUIRED),
+ * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),
* ));
*
* @author Fabien Potencier <fabien@symfony.com>
private $shortcuts;
/**
- * Constructor.
- *
* @param array $definition An array of InputArgument and InputOption instance
*/
public function __construct(array $definition = array())
/**
* Sets the definition of the input.
- *
- * @param array $definition The definition array
*/
public function setDefinition(array $definition)
{
}
/**
- * Adds an InputArgument object.
- *
- * @param InputArgument $argument An InputArgument object
- *
* @throws LogicException When incorrect argument is given
*/
public function addArgument(InputArgument $argument)
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
- $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;
+ $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
return $arguments[$name];
}
*/
public function hasArgument($name)
{
- $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments;
+ $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
return isset($arguments[$name]);
}
*/
public function getArgumentCount()
{
- return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments);
+ return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
}
/**
}
/**
- * Adds an InputOption object.
- *
- * @param InputOption $option An InputOption object
- *
* @throws LogicException When option given already exist
*/
public function addOption(InputOption $option)
/**
* Gets an InputOption by shortcut.
*
- * @param string $shortcut the Shortcut name
+ * @param string $shortcut The Shortcut name
*
* @return InputOption An InputOption object
*/
}
}
- if (count($elements) && $this->getArguments()) {
+ if (\count($elements) && $this->getArguments()) {
$elements[] = '[--]';
}
if (!$argument->isRequired()) {
$element = '['.$element.']';
} elseif ($argument->isArray()) {
- $element = $element.' ('.$element.')';
+ $element .= ' ('.$element.')';
}
if ($argument->isArray()) {
return implode(' ', $elements);
}
-
- /**
- * Returns a textual representation of the InputDefinition.
- *
- * @return string A string representing the InputDefinition
- *
- * @deprecated since version 2.3, to be removed in 3.0.
- */
- public function asText()
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
-
- $descriptor = new TextDescriptor();
- $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
- $descriptor->describe($output, $this, array('raw_output' => true));
-
- return $output->fetch();
- }
-
- /**
- * Returns an XML representation of the InputDefinition.
- *
- * @param bool $asDom Whether to return a DOM or an XML string
- *
- * @return string|\DOMDocument An XML string representing the InputDefinition
- *
- * @deprecated since version 2.3, to be removed in 3.0.
- */
- public function asXml($asDom = false)
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
-
- $descriptor = new XmlDescriptor();
-
- if ($asDom) {
- return $descriptor->getInputDefinitionDocument($this);
- }
-
- $output = new BufferedOutput();
- $descriptor->describe($output, $this);
-
- return $output->fetch();
- }
}