Adding __get() to access protected properties of ConsoleOptionParser components for upcoming changes.

This commit is contained in:
mark_story 2010-11-12 23:34:52 -05:00
parent e63f81c12a
commit 8e1dd9e892
4 changed files with 41 additions and 4 deletions

View file

@ -50,6 +50,19 @@ class ConsoleInputArgument {
} }
} }
/**
* Protected attribute accessor.
*
* @param string $name Name of attribute to read.
* @return mixed.
*/
public function __get($name) {
if (isset($this->{'_' . $name})) {
return $this->{'_' . $name};
}
return null;
}
/** /**
* Get the name of the argument * Get the name of the argument
* *

View file

@ -55,6 +55,19 @@ class ConsoleInputOption {
} }
} }
/**
* Protected attribute accessor.
*
* @param string $name Name of attribute to read.
* @return mixed.
*/
public function __get($name) {
if (isset($this->{'_' . $name})) {
return $this->{'_' . $name};
}
return null;
}
/** /**
* Get the name of the argument * Get the name of the argument
* *

View file

@ -27,9 +27,7 @@
*/ */
class ConsoleInputSubcommand { class ConsoleInputSubcommand {
protected $_name; protected $_name, $_help, $_parser;
protected $_help;
protected $_parser;
/** /**
* Make a new Subcommand * Make a new Subcommand
@ -55,6 +53,19 @@ class ConsoleInputSubcommand {
} }
} }
/**
* Protected attribute accessor.
*
* @param string $name Name of attribute to read.
* @return mixed.
*/
public function __get($name) {
if (isset($this->{'_' . $name})) {
return $this->{'_' . $name};
}
return null;
}
/** /**
* Get the name of the subcommand * Get the name of the subcommand
* *

View file

@ -141,7 +141,7 @@ class HelpFormatter {
protected function _getMaxLength($collection) { protected function _getMaxLength($collection) {
$max = 0; $max = 0;
foreach ($collection as $item) { foreach ($collection as $item) {
$max = (strlen($item->name()) > $max) ? strlen($item->name()) : $max; $max = (strlen($item->name) > $max) ? strlen($item->name) : $max;
} }
return $max; return $max;
} }