src/Console/CommandTrait.php
public function executeWrapper(array $args)
    {
        if (!method_exists($this, 'execute')) {
            $cmd = $this->createCommand(Help::class);

            $cmd->executeWrapper([$this->name()]);

            return;
        }

        // Validating arguments
        foreach ($this->getArguments() as $k => $argument) {
            if (!isset($args[$k])) {
                if ($argument->isRequired()) {
                    throw new RequireValueException("Argument pos {$k} '{$argument->name()}' requires a value.");
                }

                continue;
            }

            if (!$argument->validate($args[$k])) {
                $this->logger->error("Invalid argument {$args[$k]}");

                return;
            }

            $args[$k] = $argument->getValue();
        }

        $refMethod = new \ReflectionMethod($this, 'execute');
        $requiredNumber = $refMethod->getNumberOfRequiredParameters();

        $count = count($args);
        if ($count < $requiredNumber) {
            throw new CommandArgumentNotEnoughException($this, $count, $requiredNumber);
        }

        foreach ($this->extensions as $extension) {
            $extension->execute();
        }

        $this->execute(...$args);
    }
public function executeWrapper(array $args)
    {
        if (!method_exists($this, 'execute')) {
            $cmd = $this->createCommand(Help::class);

            $cmd->executeWrapper([$this->name()]);

            return;
        }

        // Validating arguments
        foreach ($this->getArguments() as $k => $argument) {
            if (!isset($args[$k])) {
                if ($argument->isRequired()) {
                    throw new RequireValueException("Argument pos {$k} '{$argument->name()}' requires a value.");
                }

                continue;
            }

            if (!$argument->validate($args[$k])) {
                $this->logger->error("Invalid argument {$args[$k]}");

                return;
            }

            $args[$k] = $argument->getValue();
        }

        $refMethod = new \ReflectionMethod($this, 'execute');
        $requiredNumber = $refMethod->getNumberOfRequiredParameters();

        $count = count($args);
        if ($count < $requiredNumber) {
            throw new CommandArgumentNotEnoughException($this, $count, $requiredNumber);
        }

        foreach ($this->extensions as $extension) {
            $extension->execute();
        }

        $this->execute(...$args);
    }
public function executeWrapper ( array $ args ) { if ( ! method_exists ( $ this , 'execute' ) ) { $ cmd = $ this -> createCommand ( Help :: class ) ; $ cmd -> executeWrapper ( [ $ this -> name ( ) ] ) ; return ; } // Validating arguments foreach ( $ this -> getArguments ( ) as $ k => $ argument ) { if ( ! isset ( $ args [ $ k ] ) ) { if ( $ argument -> isRequired ( ) ) { throw new RequireValueException ( "Argument pos {$k} '{$argument->name()}' requires a value." ) ; } continue ; } if ( ! $ argument -> validate ( $ args [ $ k ] ) ) { $ this -> logger -> error ( "Invalid argument {$args[$k]}" ) ; return ; } $ args [ $ k ] = $ argument -> getValue ( ) ; } $ refMethod = new \ ReflectionMethod ( $ this , 'execute' ) ; $ requiredNumber = $ refMethod -> getNumberOfRequiredParameters ( ) ; $ count = count ( $ args ) ; if ( $ count < $ requiredNumber ) { throw new CommandArgumentNotEnoughException ( $ this , $ count , $ requiredNumber ) ; } foreach ( $ this -> extensions as $ extension ) { $ extension -> execute ( ) ; } $ this -> execute ( ... $ args ) ; }
Execute command object, this is a wrapper method for execution.

In this method, we check the command arguments by the Reflection feature
provided by PHP.

@param  array $args command argument list (not associative array).

@throws CommandArgumentNotEnoughException
@throws RequireValueException
@throws \ReflectionException
Execute command object this is a wrapper method for execution .