diff --git a/cake/console/libs/console_input_argument.php b/cake/console/libs/console_input_argument.php index ce28446cf..0a82bc425 100644 --- a/cake/console/libs/console_input_argument.php +++ b/cake/console/libs/console_input_argument.php @@ -51,16 +51,12 @@ class ConsoleInputArgument { } /** - * Protected attribute accessor. + * Get the value of the name attribute. * - * @param string $name Name of attribute to read. - * @return mixed. + * @return string Value of this->_name. */ - public function __get($name) { - if (isset($this->{'_' . $name})) { - return $this->{'_' . $name}; - } - return null; + public function name() { + return $this->_name; } /** diff --git a/cake/console/libs/console_input_option.php b/cake/console/libs/console_input_option.php index d55847fe4..3d8267277 100644 --- a/cake/console/libs/console_input_option.php +++ b/cake/console/libs/console_input_option.php @@ -56,16 +56,21 @@ class ConsoleInputOption { } /** - * Protected attribute accessor. + * Get the value of the name attribute. * - * @param string $name Name of attribute to read. - * @return mixed. + * @return string Value of this->_name. */ - public function __get($name) { - if (isset($this->{'_' . $name})) { - return $this->{'_' . $name}; - } - return null; + public function name() { + return $this->_name; + } + +/** + * Get the value of the short attribute. + * + * @return string Value of this->_short. + */ + public function short() { + return $this->_short; } /** diff --git a/cake/console/libs/console_input_subcommand.php b/cake/console/libs/console_input_subcommand.php index 0b9097107..76bd19d2f 100644 --- a/cake/console/libs/console_input_subcommand.php +++ b/cake/console/libs/console_input_subcommand.php @@ -54,16 +54,12 @@ class ConsoleInputSubcommand { } /** - * Protected attribute accessor. + * Get the value of the name attribute. * - * @param string $name Name of attribute to read. - * @return mixed. + * @return string Value of this->_name. */ - public function __get($name) { - if (isset($this->{'_' . $name})) { - return $this->{'_' . $name}; - } - return null; + public function name() { + return $this->_name; } /** diff --git a/cake/console/libs/console_option_parser.php b/cake/console/libs/console_option_parser.php index 70009f2c1..d6cccba1e 100644 --- a/cake/console/libs/console_option_parser.php +++ b/cake/console/libs/console_option_parser.php @@ -267,7 +267,7 @@ class ConsoleOptionParser { public function addOption($name, $params = array()) { if (is_object($name) && $name instanceof ConsoleInputOption) { $option = $name; - $name = $option->name; + $name = $option->name(); } else { $defaults = array( 'name' => $name, @@ -281,8 +281,8 @@ class ConsoleOptionParser { $option = new ConsoleInputOption($options); } $this->_options[$name] = $option; - if ($option->short !== null) { - $this->_shortOptions[$option->short] = $name; + if ($option->short() !== null) { + $this->_shortOptions[$option->short()] = $name; } return $this; } @@ -374,7 +374,7 @@ class ConsoleOptionParser { public function addSubcommand($name, $params = array()) { if (is_object($name) && $name instanceof ConsoleInputSubcommand) { $command = $name; - $name = $command->name; + $name = $command->name(); } else { $defaults = array( 'name' => $name, @@ -458,12 +458,12 @@ class ConsoleOptionParser { foreach ($this->_args as $i => $arg) { if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) { throw new RuntimeException( - sprintf(__('Missing required arguments. %s is required.'), $arg->name) + sprintf(__('Missing required arguments. %s is required.'), $arg->name()) ); } } foreach ($this->_options as $option) { - $name = $option->name; + $name = $option->name(); $isBoolean = $option->isBoolean(); $default = $option->defaultValue(); diff --git a/cake/console/libs/help_formatter.php b/cake/console/libs/help_formatter.php index 754a1865c..7af4cadf1 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; } diff --git a/cake/tests/cases/console/libs/console_option_parser.test.php b/cake/tests/cases/console/libs/console_option_parser.test.php index 605ed281f..656f3317a 100644 --- a/cake/tests/cases/console/libs/console_option_parser.test.php +++ b/cake/tests/cases/console/libs/console_option_parser.test.php @@ -277,7 +277,7 @@ class ConsoleOptionParserTest extends CakeTestCase { $parser->addArgument(new ConsoleInputArgument('test')); $result = $parser->arguments(); $this->assertEquals(1, count($result)); - $this->assertEquals('test', $result[0]->name); + $this->assertEquals('test', $result[0]->name()); } /** @@ -385,7 +385,7 @@ class ConsoleOptionParserTest extends CakeTestCase { $parser->addSubcommand(new ConsoleInputSubcommand('test')); $result = $parser->subcommands(); $this->assertEquals(1, count($result)); - $this->assertEquals('test', $result['test']->name); + $this->assertEquals('test', $result['test']->name()); } /**