Browse Source

Merge pull request #7920 from cakephp/master-no-magic-number

Don't use magic number for default error code.
Mark Story 10 years ago
parent
commit
b13d34aec7
2 changed files with 13 additions and 6 deletions
  1. 3 3
      src/Console/ConsoleOptionParser.php
  2. 10 3
      src/Console/Shell.php

+ 3 - 3
src/Console/ConsoleOptionParser.php

@@ -169,7 +169,7 @@ class ConsoleOptionParser
      *
      *
      * @param string|null $command The command name this parser is for. The command name is used for generating help.
      * @param string|null $command The command name this parser is for. The command name is used for generating help.
      * @param bool $defaultOptions Whether you want the verbose and quiet options set.
      * @param bool $defaultOptions Whether you want the verbose and quiet options set.
-     * @return ConsoleOptionParser
+     * @return $this
      */
      */
     public static function create($command, $defaultOptions = true)
     public static function create($command, $defaultOptions = true)
     {
     {
@@ -197,7 +197,7 @@ class ConsoleOptionParser
      *
      *
      * @param array $spec The spec to build the OptionParser with.
      * @param array $spec The spec to build the OptionParser with.
      * @param bool $defaultOptions Whether you want the verbose and quiet options set.
      * @param bool $defaultOptions Whether you want the verbose and quiet options set.
-     * @return ConsoleOptionParser
+     * @return $this
      */
      */
     public static function buildFromArray($spec, $defaultOptions = true)
     public static function buildFromArray($spec, $defaultOptions = true)
     {
     {
@@ -371,7 +371,7 @@ class ConsoleOptionParser
      * Remove an option from the option parser.
      * Remove an option from the option parser.
      *
      *
      * @param string $name The option name to remove.
      * @param string $name The option name to remove.
-     * @return ConsoleOptionParser this
+     * @return $this
      */
      */
     public function removeOption($name)
     public function removeOption($name)
     {
     {

+ 10 - 3
src/Console/Shell.php

@@ -41,6 +41,13 @@ class Shell
     use ModelAwareTrait;
     use ModelAwareTrait;
 
 
     /**
     /**
+     * Default error code
+     *
+     * @var int
+     */
+    const CODE_ERROR = 1;
+
+    /**
      * Output constant making verbose shells.
      * Output constant making verbose shells.
      *
      *
      * @var int
      * @var int
@@ -496,7 +503,7 @@ class Shell
      *
      *
      * By overriding this method you can configure the ConsoleOptionParser before returning it.
      * By overriding this method you can configure the ConsoleOptionParser before returning it.
      *
      *
-     * @return ConsoleOptionParser
+     * @return \Cake\Console\ConsoleOptionParser
      * @link http://book.cakephp.org/3.0/en/console-and-shells.html#configuring-options-and-generating-help
      * @link http://book.cakephp.org/3.0/en/console-and-shells.html#configuring-options-and-generating-help
      */
      */
     public function getOptionParser()
     public function getOptionParser()
@@ -680,9 +687,9 @@ class Shell
         if (!empty($message)) {
         if (!empty($message)) {
             $this->_io->err($message);
             $this->_io->err($message);
         }
         }
-        $this->_stop(1);
+        $this->_stop(self::CODE_ERROR);
 
 
-        return 1;
+        return self::CODE_ERROR;
     }
     }
 
 
     /**
     /**