diff --git a/framework/console/CConsoleApplication.php b/framework/console/CConsoleApplication.php index 5335f7ae0e..538277f860 100644 --- a/framework/console/CConsoleApplication.php +++ b/framework/console/CConsoleApplication.php @@ -84,7 +84,7 @@ protected function init() /** * Processes the user request. - * This method creates a console command runner to handle the particular user command. + * This method uses a console command runner to handle the particular user command. * Since version 1.1.11 this method will exit application with an exit code if one is returned by the user command. */ public function processRequest() diff --git a/framework/console/CConsoleCommand.php b/framework/console/CConsoleCommand.php index 22a012cdaa..3cd5343cbe 100644 --- a/framework/console/CConsoleCommand.php +++ b/framework/console/CConsoleCommand.php @@ -112,8 +112,7 @@ public function behaviors() * dispatch the command request to an appropriate action with the corresponding * option values * @param array $args command line parameters for this command. - * @return int|null application exit code returned by the action - * will return null when action has been aborted by {@link onBeforeAction} event + * @return integer application exit code returned by the action, 0 if action does not return anything * (return value is available since version 1.1.11) */ public function run($args) @@ -168,11 +167,13 @@ public function run($args) if(!empty($options)) $this->usageError("Unknown options: ".implode(', ',array_keys($options))); + $exitCode=0; if($this->beforeAction($action,$params)) { $exitCode=$method->invokeArgs($this,$params); - return $this->afterAction($action,$params,$exitCode); + $exitCode=$this->afterAction($action,$params,is_int($exitCode)?$exitCode:0); } + return $exitCode; } /** @@ -201,10 +202,10 @@ protected function beforeAction($action,$params) * You may override this method to do some postprocessing for the action. * @param string $action the action name * @param array $params the parameters to be passed to the action method. - * @param int|null $exitCode the application exit code returned by the action method. - * @return int|null application exit code (return value is available since version 1.1.11) + * @param integer $exitCode the application exit code returned by the action method. + * @return integer application exit code (return value is available since version 1.1.11) */ - protected function afterAction($action,$params,$exitCode=null) + protected function afterAction($action,$params,$exitCode=0) { $event=new CConsoleCommandEvent($this,$params,$action,$exitCode); if($this->hasEventHandler('onAfterAction')) diff --git a/framework/console/CConsoleCommandEvent.php b/framework/console/CConsoleCommandEvent.php index 6c47e886fe..58129f646c 100644 --- a/framework/console/CConsoleCommandEvent.php +++ b/framework/console/CConsoleCommandEvent.php @@ -31,7 +31,7 @@ class CConsoleCommandEvent extends CEvent */ public $stopCommand=false; /** - * @var int exit code of application. + * @var integer exit code of application. * This property is available in {@link CConsoleCommand::onAfterAction} event and will be set to the exit code * returned by the console command action. You can set it to change application exit code. */ @@ -42,7 +42,7 @@ class CConsoleCommandEvent extends CEvent * @param mixed $sender sender of the event * @param string $params the parameters to be passed to the action method. * @param string $action the action name - * @param string $exitCode the application exit code + * @param integer $exitCode the application exit code */ public function __construct($sender=null,$params=null,$action=null,$exitCode=0){ parent::__construct($sender,$params); diff --git a/framework/console/CConsoleCommandRunner.php b/framework/console/CConsoleCommandRunner.php index 9990d84efa..7b7325520d 100644 --- a/framework/console/CConsoleCommandRunner.php +++ b/framework/console/CConsoleCommandRunner.php @@ -46,7 +46,7 @@ class CConsoleCommandRunner extends CComponent /** * Executes the requested command. * @param array $args list of user supplied parameters (including the entry script name and the command name). - * @return int|null application exit code returned by the command + * @return integer|null application exit code returned by the command * (return value is available since version 1.1.11) */ public function run($args)