Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
- One argument per line on multi-line function calls
- @return self (instead of \Zend\Console\Getopt); performed throughout
  class for consistency
- Removed all @return void and @return null annotations
- Relative namespace qualification for all @throws annotations
  • Loading branch information
weierophinney committed Mar 4, 2014
1 parent 139b8e7 commit a7fe006
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions src/Getopt.php
Expand Up @@ -262,7 +262,6 @@ public function __isset($key)
*
* @param string $key
* @param string $value
* @return void
*/
public function __set($key, $value)
{
Expand All @@ -287,7 +286,6 @@ public function __toString()
* Unset an option.
*
* @param string $key
* @return void
*/
public function __unset($key)
{
Expand All @@ -303,8 +301,8 @@ public function __unset($key)
* These are appended to those defined when the constructor was called.
*
* @param array $argv
* @throws \Zend\Console\Exception\InvalidArgumentException When not given an array as parameter
* @return \Zend\Console\Getopt Provides a fluent interface
* @throws Exception\InvalidArgumentException When not given an array as parameter
* @return self
*/
public function addArguments($argv)
{
Expand All @@ -321,8 +319,8 @@ public function addArguments($argv)
* These replace any currently defined.
*
* @param array $argv
* @throws \Zend\Console\Exception\InvalidArgumentException When not given an array as parameter
* @return \Zend\Console\Getopt Provides a fluent interface
* @throws Exception\InvalidArgumentException When not given an array as parameter
* @return self
*/
public function setArguments($argv)
{
Expand All @@ -340,7 +338,7 @@ public function setArguments($argv)
* the behavior of Zend\Console\Getopt.
*
* @param array $getoptConfig
* @return \Zend\Console\Getopt Provides a fluent interface
* @return self
*/
public function setOptions($getoptConfig)
{
Expand All @@ -359,7 +357,7 @@ public function setOptions($getoptConfig)
*
* @param string $configKey
* @param string $configValue
* @return \Zend\Console\Getopt Provides a fluent interface
* @return self
*/
public function setOption($configKey, $configValue)
{
Expand All @@ -374,7 +372,7 @@ public function setOption($configKey, $configValue)
* These are appended to the rules defined when the constructor was called.
*
* @param array $rules
* @return \Zend\Console\Getopt Provides a fluent interface
* @return self
*/
public function addRules($rules)
{
Expand Down Expand Up @@ -586,9 +584,11 @@ public function getUsageMessage()
$lines[] = $linepart;
}
foreach ($lines as $linepart) {
$usage .= sprintf("%s %s\n",
$usage .= sprintf(
"%s %s\n",
str_pad($linepart['name'], $maxLen),
$linepart['help']);
$linepart['help']
);
}
return $usage;
}
Expand All @@ -600,8 +600,8 @@ public function getUsageMessage()
* mapping option name (short or long) to an alias.
*
* @param array $aliasMap
* @throws \Zend\Console\Exception\ExceptionInterface
* @return \Zend\Console\Getopt Provides a fluent interface
* @throws Exception\ExceptionInterface
* @return self
*/
public function setAliases($aliasMap)
{
Expand Down Expand Up @@ -631,7 +631,7 @@ public function setAliases($aliasMap)
* mapping option name (short or long) to the help string.
*
* @param array $helpMap
* @return \Zend\Console\Getopt Provides a fluent interface
* @return self
*/
public function setHelp($helpMap)
{
Expand All @@ -652,13 +652,14 @@ public function setHelp($helpMap)
* Also find option parameters, and remaining arguments after
* all options have been parsed.
*
* @return \Zend\Console\Getopt|null Provides a fluent interface
* @return self
*/
public function parse()
{
if ($this->parsed === true) {
return;
return $this;
}

$argv = $this->argv;
$this->options = array();
$this->remainingArgs = array();
Expand Down Expand Up @@ -702,7 +703,7 @@ public function parse()
* false then an Exception\RuntimeException will be thrown indicating that
* there is a parse issue with this option.
*
* @return \Zend\Console\Getopt Fluent interface.
* @return self
*/
public function setOptionCallback($option, \Closure $callback)
{
Expand Down Expand Up @@ -738,7 +739,6 @@ protected function triggerCallbacks()
* Long options may not be clustered.
*
* @param mixed &$argv
* @return void
*/
protected function _parseLongOption(&$argv)
{
Expand All @@ -758,7 +758,6 @@ protected function _parseLongOption(&$argv)
* Short options may be clustered.
*
* @param mixed &$argv
* @return void
*/
protected function _parseShortOptionCluster(&$argv)
{
Expand All @@ -773,8 +772,7 @@ protected function _parseShortOptionCluster(&$argv)
*
* @param string $flag
* @param mixed $argv
* @throws \Zend\Console\Exception\ExceptionInterface
* @return void
* @throws Exception\ExceptionInterface
*/
protected function _parseSingleOption($flag, &$argv)
{
Expand Down Expand Up @@ -867,7 +865,6 @@ protected function _setNumericOptionValue($value)
*
* @param string $flag
* @param string $value
* @return null
*/
protected function _setSingleOptionValue($flag, $value)
{
Expand Down Expand Up @@ -898,7 +895,6 @@ protected function _setSingleOptionValue($flag, $value)
* In other case increase value to show count of flags' usage
*
* @param string $flag
* @return null
*/
protected function _setBooleanFlagValue($flag)
{
Expand All @@ -914,7 +910,7 @@ protected function _setBooleanFlagValue($flag)
*
* @param string $flag
* @param string $param
* @throws \Zend\Console\Exception\ExceptionInterface
* @throws Exception\ExceptionInterface
* @return bool
*/
protected function _checkParameterType($flag, $param)
Expand Down Expand Up @@ -949,7 +945,6 @@ protected function _checkParameterType($flag, $param)
* Define legal options using the gnu-style format.
*
* @param string $rules
* @return void
*/
protected function _addRulesModeGnu($rules)
{
Expand Down Expand Up @@ -983,8 +978,7 @@ protected function _addRulesModeGnu($rules)
* Define legal options using the Zend-style format.
*
* @param array $rules
* @throws \Zend\Console\Exception\ExceptionInterface
* @return void
* @throws Exception\ExceptionInterface
*/
protected function _addRulesModeZend($rules)
{
Expand Down Expand Up @@ -1057,4 +1051,4 @@ protected function _addRulesModeZend($rules)
$this->rules[$mainFlag] = $rule;
}
}
}
}

0 comments on commit a7fe006

Please sign in to comment.