public function executeCommand($command, array $arguments = [], array $envVars = [], $input = null): string
    {
        $envVars = array_replace($this->environmentVars, $envVars);
        $commandLine = $this->commandLinePrefix;

        $commandLine[] = $command;
        foreach ($arguments as $argumentName => $argumentValue) {
            if (is_int($argumentName)) {
                $commandLine[] = $argumentValue;
            } else {
                $commandLine[] = $this->getDashedArgumentName($argumentName);
                $commandLine[] = is_array($argumentValue) ? implode(',', $argumentValue) : $argumentValue;
            }
        }

        $process = $this->getProcess($commandLine, $envVars, $input);
        $process->run();

        $output = str_replace("\r\n", "\n", trim($process->getOutput()));

        if (!$process->isSuccessful()) {
            throw FailedSubProcessCommandException::forProcess($command, $process);
        }

        return $output;
    }
public function executeCommand($command, array $arguments = [], array $envVars = [], $input = null): string
    {
        $envVars = array_replace($this->environmentVars, $envVars);
        $commandLine = $this->commandLinePrefix;

        $commandLine[] = $command;
        foreach ($arguments as $argumentName => $argumentValue) {
            if (is_int($argumentName)) {
                $commandLine[] = $argumentValue;
            } else {
                $commandLine[] = $this->getDashedArgumentName($argumentName);
                $commandLine[] = is_array($argumentValue) ? implode(',', $argumentValue) : $argumentValue;
            }
        }

        $process = $this->getProcess($commandLine, $envVars, $input);
        $process->run();

        $output = str_replace("\r\n", "\n", trim($process->getOutput()));

        if (!$process->isSuccessful()) {
            throw FailedSubProcessCommandException::forProcess($command, $process);
        }

        return $output;
    }
public function executeCommand ( $ command , array $ arguments = [ ] , array $ envVars = [ ] , $ input = null ) : string { $ envVars = array_replace ( $ this -> environmentVars , $ envVars ) ; $ commandLine = $ this -> commandLinePrefix ; $ commandLine [ ] = $ command ; foreach ( $ arguments as $ argumentName => $ argumentValue ) { if ( is_int ( $ argumentName ) ) { $ commandLine [ ] = $ argumentValue ; } else { $ commandLine [ ] = $ this -> getDashedArgumentName ( $ argumentName ) ; $ commandLine [ ] = is_array ( $ argumentValue ) ? implode ( ',' , $ argumentValue ) : $ argumentValue ; } } $ process = $ this -> getProcess ( $ commandLine , $ envVars , $ input ) ; $ process -> run ( ) ; $ output = str_replace ( "\r\n" , "\n" , trim ( $ process -> getOutput ( ) ) ) ; if ( ! $ process -> isSuccessful ( ) ) { throw FailedSubProcessCommandException :: forProcess ( $ command , $ process ) ; } return $ output ; }
Execute a command in a sub process

@param string $command Command identifier
@param array $arguments Argument names will automatically be converted to dashed version, if not provided like so
@param array $envVars Environment vars to be added to the command
@param resource|string|\Traversable|null $input Inpupt (stdin) for the command
@throws FailedSubProcessCommandException
@return string
Execute a command in a sub process