From f3b6e1a30c9fa4c3a320206fdc0d480baee49e0e Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Sun, 6 Feb 2011 16:34:24 -0800 Subject: [PATCH] PHPDoc for Console --- src/Symfony/Component/Console/Application.php | 27 +++++++++++++++++-- .../Component/Console/Command/HelpCommand.php | 9 +++++-- .../Component/Console/Command/ListCommand.php | 4 +-- .../Console/Helper/FormatterHelper.php | 9 +++++++ src/Symfony/Component/Console/Input/Input.php | 12 +++++++++ .../Console/Input/InputDefinition.php | 7 +++++ .../Console/Input/InputInterface.php | 7 +++++ .../Component/Console/Input/StringInput.php | 3 +++ .../Component/Console/Output/Output.php | 13 +++++++++ 9 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 89c31bade7..d7509de85b 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -201,7 +201,7 @@ class Application } /** - * Get the helper set associated with the command + * Get the helper set associated with the command. * * @return HelperSet The HelperSet instance associated with this command */ @@ -396,7 +396,7 @@ class Application } /** - * Returns true if the command exists, false otherwise + * Returns true if the command exists, false otherwise. * * @param string $name The command name or alias * @@ -429,6 +429,8 @@ class Application /** * Finds a registered namespace by a name or an abbreviation. * + * @param string $namespace A namespace or abbreviation to search for + * * @return string A registered namespace * * @throws \InvalidArgumentException When namespace is incorrect or ambiguous @@ -715,11 +717,25 @@ class Application } } + /** + * Gets the name of the command based on input. + * + * @param InputInterface $input The input interface + * + * @return string The command name + */ protected function getCommandName(InputInterface $input) { return $input->getFirstArgument('command'); } + /** + * Sorts commands in alphabetical order. + * + * @param array $commands An associative array of commands to sort + * + * @return array A sorted array of commands + */ protected function sortCommands($commands) { $namespacedCommands = array(); @@ -741,6 +757,13 @@ class Application return $namespacedCommands; } + /** + * Returns abbreviated suggestions in string format. + * + * @param array $abbrevs Abbreviated suggestions to convert + * + * @return string A formatted string of abbreviated suggestions + */ protected function getAbbreviationSuggestions($abbrevs) { return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : ''); diff --git a/src/Symfony/Component/Console/Command/HelpCommand.php b/src/Symfony/Component/Console/Command/HelpCommand.php index 49e91782dc..61ff032c0a 100644 --- a/src/Symfony/Component/Console/Command/HelpCommand.php +++ b/src/Symfony/Component/Console/Command/HelpCommand.php @@ -28,7 +28,7 @@ class HelpCommand extends Command protected $command; /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -54,13 +54,18 @@ EOF ); } + /** + * Sets the command + * + * @param Command $command The command to set + */ public function setCommand(Command $command) { $this->command = $command; } /** - * @see Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php index 3d2ee7bb15..76fb7cbcef 100644 --- a/src/Symfony/Component/Console/Command/ListCommand.php +++ b/src/Symfony/Component/Console/Command/ListCommand.php @@ -26,7 +26,7 @@ use Symfony\Component\Console\Command\Command; class ListCommand extends Command { /** - * @see Command + * {@inheritdoc} */ protected function configure() { @@ -54,7 +54,7 @@ EOF } /** - * @see Command + * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Component/Console/Helper/FormatterHelper.php b/src/Symfony/Component/Console/Helper/FormatterHelper.php index 7da190631f..5a05aa049a 100644 --- a/src/Symfony/Component/Console/Helper/FormatterHelper.php +++ b/src/Symfony/Component/Console/Helper/FormatterHelper.php @@ -67,6 +67,13 @@ class FormatterHelper extends Helper return implode("\n", $messages); } + /** + * Returns the length of a string, uses mb_strlen if it is available. + * + * @param string $string The string to check its length + * + * @return integer The length of the string + */ protected function strlen($string) { return function_exists('mb_strlen') ? mb_strlen($string) : strlen($string); @@ -74,6 +81,8 @@ class FormatterHelper extends Helper /** * Returns the helper's canonical name + * + * @return string The canonical name of the helper */ public function getName() { diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index 8fcf989925..aba45273a7 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/src/Symfony/Component/Console/Input/Input.php @@ -64,6 +64,8 @@ abstract class Input implements InputInterface abstract protected function parse(); /** + * Validates the input. + * * @throws \RuntimeException When not enough arguments are given */ public function validate() @@ -73,11 +75,21 @@ abstract class Input implements InputInterface } } + /** + * Checks if the input is interactive. + * + * @return Boolean Returns true if the input is interactive + */ public function isInteractive() { return $this->interactive; } + /** + * Sets the input interactivity. + * + * @param Boolean $interactive If the input should be interactive + */ public function setInteractive($interactive) { $this->interactive = (Boolean) $interactive; diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index a4ed4ae3a2..9a7baff2a6 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -42,6 +42,11 @@ class InputDefinition $this->setDefinition($definition); } + /** + * Sets the definition of the input. + * + * @param array $definition The definition array + */ public function setDefinition(array $definition) { $arguments = array(); @@ -297,6 +302,8 @@ class InputDefinition /** * Gets an InputOption by shortcut. * + * @param string $shortcut the Shortcut name + * * @return InputOption An InputOption object */ public function getOptionForShortcut($shortcut) diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index bf943716a4..1027507ff7 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -63,6 +63,7 @@ interface InputInterface /** * Get argument by name. * + * @param string $name The name of the argument * @return mixed */ function getArgument($name); @@ -72,6 +73,12 @@ interface InputInterface */ function getOptions(); + /** + * Get an option by name. + * + * @param string $name The name of the option + * @return mixed + */ function getOption($name); /** diff --git a/src/Symfony/Component/Console/Input/StringInput.php b/src/Symfony/Component/Console/Input/StringInput.php index 64d9772af2..7a7575996b 100644 --- a/src/Symfony/Component/Console/Input/StringInput.php +++ b/src/Symfony/Component/Console/Input/StringInput.php @@ -39,6 +39,9 @@ class StringInput extends ArgvInput } /** + * Tokenizes a string. + * + * @param string $input The input to tokenise * @throws \InvalidArgumentException When unable to parse input (should never happen) */ protected function tokenize($input) diff --git a/src/Symfony/Component/Console/Output/Output.php b/src/Symfony/Component/Console/Output/Output.php index 388848614a..acc1a2f03c 100644 --- a/src/Symfony/Component/Console/Output/Output.php +++ b/src/Symfony/Component/Console/Output/Output.php @@ -179,6 +179,12 @@ abstract class Output implements OutputInterface } /** + * Replaces the starting style of the output. + * + * @param array $match + * + * @return string The replaced style + * * @throws \InvalidArgumentException When style is unknown */ protected function replaceStartStyle($match) @@ -220,6 +226,13 @@ abstract class Output implements OutputInterface return "\033[".implode(';', $codes).'m'; } + /** + * Replaces the end style. + * + * @param string $match The text to match + * + * @return string The end style + */ protected function replaceEndStyle($match) { if (!$this->decorated) {