From 8e1dd9e89230263643b1c97c05e872d74a4b6d3e Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 12 Nov 2010 23:34:52 -0500 Subject: [PATCH] Adding __get() to access protected properties of ConsoleOptionParser components for upcoming changes. --- cake/console/libs/console_input_argument.php | 13 +++++++++++++ cake/console/libs/console_input_option.php | 13 +++++++++++++ cake/console/libs/console_input_subcommand.php | 17 ++++++++++++++--- cake/console/libs/help_formatter.php | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index 3e8d1eb7d..fbd05548f 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -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 * diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index 173e19cdc..d47bcb956 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -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 * diff --git a/cake/console/libs/console_input_subcommand.php b/cake/console/libs/console_input_subcommand.php index 514c5a1b9..f6b80bfdd 100644 --- a/cake/console/libs/console_input_subcommand.php +++ b/cake/console/libs/console_input_subcommand.php @@ -27,9 +27,7 @@ */ class ConsoleInputSubcommand { - protected $_name; - protected $_help; - protected $_parser; + protected $_name, $_help, $_parser; /** * 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 * diff --git a/cake/console/libs/help_formatter.php b/cake/console/libs/help_formatter.php index 7af4cadf1..754a1865c 100644 --- a/cake/console/libs/help_formatter.php +++ b/cake/console/libs/help_formatter.php @@ -141,7 +141,7 @@ class HelpFormatter { 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; }