namespace Illuminate\Console;

use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Container\Container;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Illuminate\Contracts\Console\Application as ApplicationContract;
// my name space
class Application extends SymfonyApplication implements ApplicationContract
{// class Application extends SymfonyApplication implements ApplicationContract
/**
* The Laravel application instance.
*
* @var \Illuminate\Contracts\Container\Container
*/
protected $laravel;// The laravel application instance.
// all use this instance in the

/**
* The output from the previous command.
*
* @var \Symfony\Component\Console\Output\BufferedOutput
*/
protected $lastOutput;//The output from the previous command.
// The previous command output String.

/**
* Create a new Artisan console application.
*
* @param \Illuminate\Contracts\Container\Container $laravel
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @param string $version
* @return void
*/
public function __construct(Container $laravel, Dispatcher $events, $version)
{
parent::__construct('Laravel Framework', $version);// use parents construct , may like set

$this->laravel = $laravel;// set the instance the laravel
$this->setAutoExit(false);// set the auto Exit
$this->setCatchExceptions(false);//set Catch Exceptions

$events->fire(new Events\ArtisanStarting($this));//fire the Events \Artisan Starting
}// Create a new Artisan console application

/**
* Run an Artisan console command by name.
*
* @param string $command
* @param array $parameters
* @return int
*/ // Run an Artisan console command by name.
public function call($command, array $parameters = [])//Run an Artisan console command by name.
{// call $command array $parameters
$parameters = collect($parameters)->prepend($command);// collect($parameters)->prepend($command)
// set the parameters ,format the parameters.
// set parameter
$this->lastOutput = new BufferedOutput;// $this->lastOutput get the new Buffered Output
// the Output string is a Output class
// set the lastOutput
$this->setCatchExceptions(false);// set Catch Exceptions
// Set Catch Exceptions
// set the Exceptions
$result = $this->run(new ArrayInput($parameters->toArray()), $this->lastOutput);// run ()
// run the function use parameters and Output.
$this->setCatchExceptions(true);// set the Set Catch Exception

return $result;// back the result to the call
}

/**
* Get the output for the last run command.
*
* @return string
*/
public function output()
{
return $this->lastOutput ? $this->lastOutput->fetch() : '';
}// Get the output for the last run command.
// return $this->lastOutput ? $this->lastOutput->fetch():