ZF\Console\Application::run PHP Method

run() public method

If no arguments are provided, pulls them from $argv, stripping the script argument first. If the argument list is empty, displays a usage message. If arguments are provided, but no routes match, displays a usage message and returns a status of 1. Otherwise, attempts to dispatch the matched command, returning the execution status.
public run ( array $args = null ) : integer
$args array
return integer
    public function run(array $args = null)
    {
        $this->initializeExceptionHandler();
        $this->setProcessTitle();
        if ($args === null) {
            global $argv;
            $args = array_slice($argv, 1);
        }
        $result = $this->processRun($args);
        $this->showMessage($this->footer);
        return $result;
    }

Usage Example

 /**
  * @group 7
  */
 public function testHandlersConfiguredViaRoutesDoNotOverwriteThoseAlreadyInDispatcher()
 {
     $phpunit = $this;
     $dispatcher = new Dispatcher();
     $dispatcher->map('test', function ($route, $console) use($phpunit) {
         $phpunit->assertEquals('test', $route->getName());
         return 2;
     });
     $routes = [['name' => 'test', 'route' => 'test', 'description' => 'Test handler capabilities', 'short_description' => 'Test handler capabilities', 'handler' => function ($route, $console) use($phpunit) {
         $phpunit->fail('Handler from route configuration was invoked when it should not be');
         return 3;
     }]];
     $application = new Application('ZFConsoleApplication', $this->version, $routes, $this->console, $dispatcher);
     $this->assertEquals(2, $application->run(['test']));
 }
All Usage Examples Of ZF\Console\Application::run