public function run(Input $input, OutputInterface $output)
    {
        $this->eventDispatcher->dispatch(new ExerciseRunnerEvent('cli.run.start', $this->exercise, $input));
        $success = true;
        foreach ($this->preserveOldArgFormat($this->exercise->getArgs()) as $i => $args) {
            /** @var CliExecuteEvent $event */
            $event = $this->eventDispatcher->dispatch(
                new CliExecuteEvent('cli.run.student-execute.pre', new ArrayObject($args))
            );

            $args = $event->getArgs();

            if (count($args)) {
                $glue = max(array_map('strlen', $args->getArrayCopy())) > 30 ? "\n" : ', ';

                $output->writeTitle('Arguments');
                $output->write(implode($glue, $args->getArrayCopy()));
                $output->emptyLine();
            }

            $output->writeTitle("Output");
            $process = $this->getPhpProcess($input->getArgument('program'), $args);
            $process->start();
            $this->eventDispatcher->dispatch(
                new CliExecuteEvent('cli.run.student.executing', $args, ['output' => $output])
            );
            $process->wait(function ($outputType, $outputBuffer) use ($output) {
                $output->write($outputBuffer);
            });
            $output->emptyLine();

            if (!$process->isSuccessful()) {
                $success = false;
            }

            $output->lineBreak();
        }

        $this->eventDispatcher->dispatch(new ExerciseRunnerEvent('cli.run.finish', $this->exercise, $input));
        return $success;
    }
public function run(Input $input, OutputInterface $output)
    {
        $this->eventDispatcher->dispatch(new ExerciseRunnerEvent('cli.run.start', $this->exercise, $input));
        $success = true;
        foreach ($this->preserveOldArgFormat($this->exercise->getArgs()) as $i => $args) {
            /** @var CliExecuteEvent $event */
            $event = $this->eventDispatcher->dispatch(
                new CliExecuteEvent('cli.run.student-execute.pre', new ArrayObject($args))
            );

            $args = $event->getArgs();

            if (count($args)) {
                $glue = max(array_map('strlen', $args->getArrayCopy())) > 30 ? "\n" : ', ';

                $output->writeTitle('Arguments');
                $output->write(implode($glue, $args->getArrayCopy()));
                $output->emptyLine();
            }

            $output->writeTitle("Output");
            $process = $this->getPhpProcess($input->getArgument('program'), $args);
            $process->start();
            $this->eventDispatcher->dispatch(
                new CliExecuteEvent('cli.run.student.executing', $args, ['output' => $output])
            );
            $process->wait(function ($outputType, $outputBuffer) use ($output) {
                $output->write($outputBuffer);
            });
            $output->emptyLine();

            if (!$process->isSuccessful()) {
                $success = false;
            }

            $output->lineBreak();
        }

        $this->eventDispatcher->dispatch(new ExerciseRunnerEvent('cli.run.finish', $this->exercise, $input));
        return $success;
    }
public function run ( Input $ input , OutputInterface $ output ) { $ this -> eventDispatcher -> dispatch ( new ExerciseRunnerEvent ( 'cli.run.start' , $ this -> exercise , $ input ) ) ; $ success = true ; foreach ( $ this -> preserveOldArgFormat ( $ this -> exercise -> getArgs ( ) ) as $ i => $ args ) { /** @var CliExecuteEvent $event */ $ event = $ this -> eventDispatcher -> dispatch ( new CliExecuteEvent ( 'cli.run.student-execute.pre' , new ArrayObject ( $ args ) ) ) ; $ args = $ event -> getArgs ( ) ; if ( count ( $ args ) ) { $ glue = max ( array_map ( 'strlen' , $ args -> getArrayCopy ( ) ) ) > 30 ? "\n" : ', ' ; $ output -> writeTitle ( 'Arguments' ) ; $ output -> write ( implode ( $ glue , $ args -> getArrayCopy ( ) ) ) ; $ output -> emptyLine ( ) ; } $ output -> writeTitle ( "Output" ) ; $ process = $ this -> getPhpProcess ( $ input -> getArgument ( 'program' ) , $ args ) ; $ process -> start ( ) ; $ this -> eventDispatcher -> dispatch ( new CliExecuteEvent ( 'cli.run.student.executing' , $ args , [ 'output' => $ output ] ) ) ; $ process -> wait ( function ( $ outputType , $ outputBuffer ) use ( $ output ) { $ output -> write ( $ outputBuffer ) ; } ) ; $ output -> emptyLine ( ) ; if ( ! $ process -> isSuccessful ( ) ) { $ success = false ; } $ output -> lineBreak ( ) ; } $ this -> eventDispatcher -> dispatch ( new ExerciseRunnerEvent ( 'cli.run.finish' , $ this -> exercise , $ input ) ) ; return $ success ; }
Runs a student's solution by invoking PHP from the CLI passing the arguments gathered from the exercise
as command line arguments to PHP.

Running only runs the student's solution, the reference solution is not run and no verification is performed,
the output of the student's solution is written directly to the output.

Events dispatched:

* cli.run.student-execute.pre
* cli.run.student.executing

@param Input $input The command line arguments passed to the command.
@param OutputInterface $output A wrapper around STDOUT.
@return bool If the solution was successfully executed, eg. exit code was 0.
Runs a student s solution by invoking PHP from the CLI passing the arguments gathered from the exercise as command line arguments to PHP .