Skip to content

Commit

Permalink
Adding __get() to access protected properties of ConsoleOptionParser …
Browse files Browse the repository at this point in the history
…components for upcoming changes.
  • Loading branch information
markstory committed Nov 13, 2010
1 parent e63f81c commit 8e1dd9e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
13 changes: 13 additions & 0 deletions cake/console/libs/console_input_argument.php
Expand Up @@ -50,6 +50,19 @@ public function __construct($name, $help = '', $required = false, $choices = arr
}
}

/**
* 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
*
Expand Down
13 changes: 13 additions & 0 deletions cake/console/libs/console_input_option.php
Expand Up @@ -55,6 +55,19 @@ public function __construct($name, $short = null, $help = '', $boolean = false,
}
}

/**
* 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
*
Expand Down
17 changes: 14 additions & 3 deletions cake/console/libs/console_input_subcommand.php
Expand Up @@ -27,9 +27,7 @@
*/
class ConsoleInputSubcommand {

protected $_name;
protected $_help;
protected $_parser;
protected $_name, $_help, $_parser;

/**
* Make a new Subcommand
Expand All @@ -55,6 +53,19 @@ public function __construct($name, $help = '', $parser = null) {
}
}

/**
* 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
*
Expand Down
2 changes: 1 addition & 1 deletion cake/console/libs/help_formatter.php
Expand Up @@ -141,7 +141,7 @@ protected function _generateUsage() {
protected function _getMaxLength($collection) {
$max = 0;
foreach ($collection as $item) {
$max = (strlen($item->name()) > $max) ? strlen($item->name()) : $max;
$max = (strlen($item->name) > $max) ? strlen($item->name) : $max;
}
return $max;
}
Expand Down

0 comments on commit 8e1dd9e

Please sign in to comment.