Parses given command, creates new class object and calls its method via call_user_func_array
@param string $command
@return mixed
769013
public static function parseAndRunCommand($command)
    {
        try {
            list($class, $method, $args) = TaskManager::parseCommand($command);
            if (!class_exists($class)) {
                TaskLoader::loadController($class);
            }

            $obj = new $class();
            if (!method_exists($obj, $method)) {
                throw new TaskManagerException('method ' . $method . ' not found in class ' . $class);
            }

            return call_user_func_array(array($obj, $method), $args);
        } catch (\Exception $e) {
            echo 'Caught an exception: ' . get_class($e) . ': ' . PHP_EOL . $e->getMessage() . PHP_EOL;
            return false;
        }
    }
387792
public function callCommand(string $command, array $arguments = [])
    {
        $newCommand = $this->getApplication()->find($command);

        $arguments['command'] = $command;

        return $newCommand->run(new ArrayInput($arguments), $this->getOutput());
    }
781732
protected function validateCommand($command) {
        if ( ! is_string($command) && ! is_object($command)) {
            throw new InvalidCommandException(s(
                'Command must be either a class name or an instance, "%s" given.',
                get_type($command)
            ));
        }

        if (is_string($command) && ! class_exists($command)) {
            throw new InvalidCommandException(s(
                'Command "%s" does not exist.',
                $command
            ));
        }

        if ( ! method_exists($command, 'setup') || ! method_exists($command, 'run')) {
            throw new InvalidCommandException(s(
                'Command "%s" must implement methods "setup" and "run".',
                get_type($command)
            ));
        }
    }
258226
protected function executeCmd($command)
    {
        $process = new $this->processClass($command);
        $process->run();

        if (false === $process->isSuccessful() && strlen($process->getErrorOutput()) > 0) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return $process->getOutput();
    }
923478
public static function forCommand($command)
    {
        $type =  is_object($command) ? get_class($command) : gettype($command);

        $exception = new static('Could not determine command name of ' . $type);
        $exception->command = $command;

        return $exception;
    }
27836
public function getCommandConfiguration($command)
    {
        $url = "selendroid/configure/command/{$command}";
        $result = $this->driver->curl($this->driver->factoryCommand($url, WebDriver_Command::METHOD_GET));
        return isset($result['value']) ? $result['value'] : [];
    }
618732
public function execute(interfaces\commands\Command $command)
    {
        $handler = $this->resolver->resolve($command);
        
        return call_user_func([$handler, 'handle'], $command);
    }
936920
public function add(Command $command)
    {
        $command->setApplication($this);

        if (!$command->isEnabled()) {
            $command->setApplication(null);

            return;
        }

        if (null === $command->getDefinition()) {
            throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command)));
        }

        $this->commands[$command->getName()] = $command;

        foreach ($command->getAliases() as $alias) {
            $this->commands[$alias] = $command;
        }

        return $command;
    }
81631
protected function doAction(Command $command)
    {
        if ($command->name() === '__default__') {
            return $this->notFound();
        }

        // Let the command collect more data (if missing or needs confirmation)
        $command->interact($this->io());

        if (!$command->action() && !\method_exists($command, 'execute')) {
            return;
        }

        $params = [];
        $values = $command->values();
        // We prioritize action to be in line with commander.js!
        $action = $command->action() ?? [$command, 'execute'];

        foreach ($this->getActionParameters($action) as $param) {
            $params[] = $values[$param->getName()] ?? null;
        }

        return $action(...$params);
    }
774847
public function resolve(Command $command)
    {
        $commandName = get_class($command);

        // Find the CommandHandler if it has been manually defined using pushHandler()
        foreach ($this->handlers as $handlerCommand => $handler) {
            if ($handlerCommand == $commandName) {
                return $handler;
            }
        }

        // If the Command also implements CommandHandler, then it can handle() itself
        if ($command instanceof CommandHandler) {
            return $command;
        }

        // Try and guess the handler's name in the same namespace with suffix "Handler"
        $class = $commandName . 'Handler';
        if (class_exists($class)) {
            return $this->container->make($class);
        }

        // Try and guess the handler's name in nested "Handlers" namespace with suffix "Handler"
        $classParts = explode('\\', $commandName);
        $commandNameWithoutNamespace = array_pop($classParts);
        $class = implode('\\', $classParts) . '\\Handlers\\' . $commandNameWithoutNamespace . 'Handler';
        if (class_exists($class)) {
            return $this->container->make($class);
        }

        throw new UnresolvableCommandHandlerException('Could not resolve a handler for [' . get_class($command) . ']');
    }
150755
public static function fromCommand(OperationCommand $command)
    {
        $response = $command->getResponse();
        $json     = $response->json();

        return self::fromArray($json);
    }
577986
protected function executeCommand($command)
    {
        if (method_exists(Process::class, 'fromShellCommandline')) {
            $process = Process::fromShellCommandline($command, null, $this->env);
        } else {
            $process = new Process($command, null, $this->env);
        }

        if (false !== $this->timeout) {
            $process->setTimeout($this->timeout);
        }

        $process->run();

        return [
            $process->getExitCode(),
            $process->getOutput(),
            $process->getErrorOutput(),
        ];
    }
747062
function execute($command) {
        $output = array();
        $result = null;

        // Redirect standard error to stdout so we can do something with
        // it.
        $command .= " 2>&1";

        exec($command, $output, $result);

        if ($result !== 0) {
            if ($result === self::RESULT_CODE_COMMAND_NOT_FOUND) {
                throw new CommandNotFoundError(implode("\t", $output), $result);
            }
            else {
                throw new ExecutionError(implode("\t", $output), $result);
            }
        }
        return $output;
    }
321267
public function get($command)
    {
        $className = ucfirst($command);
        $className = "PortaText\\Command\\Api\\$className";
        if (!class_exists($className)) {
            throw new \InvalidArgumentException(
                "Command $command does not exist"
            );
        }
        return new $className();
    }
35639
public function prepare($command)
    {
        // change path for php
        if (substr($command, 0, 4) == 'php ') {
            $command = $this->finder->getPath().substr($command, 3);
        }

        // change path to console
        $command = str_replace(' app/console ', ' '.$this->console.' ', $command);

        // change /dev/null for Windows
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
            $command = str_replace('/dev/null', 'nul', $command);
        }

        return $command;
    }
620945
public function getCallbacks($command)
    {
        $result = array();
        $command = strtolower($command);

        if (isset($this->_callbacks[$command])) {
            $result = $this->_callbacks[$command];
        }

        return $result;
    }
1314540
public function execute(Command $command)
    {
        $this->log('Executing command [' . get_class($command) . ']', $command);

        try {
            $response = $this->innerCommandBus->execute($command);
        } catch (\Exception $e) {

            $message = 'Failed executing command [' . get_class($command) . ']. ' . $this->createExceptionString($e);
            $this->log($message, $command);
            throw $e;
        }

        $this->log('Successfully executed command [' . get_class($command) . ']', $command);

        return $response;
    }