src/Command/Humbug.php
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (PHP_SAPI !== 'phpdbg' && !defined('HHVM_VERSION') && !extension_loaded('xdebug')) {
            $output->writeln(
                '<error>You need to install and enable xdebug, or use phpdbg, '
                . 'in order to allow for code coverage generation.</error>'
            );
            return 1;
        }

        Performance::upMemProfiler();

        $this->validate($input);
        $container = $this->container = new Container($input->getOptions());

        $this->doConfiguration($input);

        if ($this->isLoggingEnabled()) {
            $this->removeOldLogFiles();
        } else {
            $output->writeln('<error>No log file is specified. Detailed results '
                . 'will not be available.</error>');
            $output->write(PHP_EOL);
        }

        if ($input->getOption('incremental')) {
            $output->writeln('<error>Incremental Analysis is an experimental feature and will very likely</error>');
            $output->writeln('<error>yield inaccurate results at this time.</error>');
            $output->write(PHP_EOL);
        }

        if ($this->textLogFile) {
            $renderer = new Text($output, true);
        } else {
            $renderer = new Text($output);
        }

        /**
         * Make initial test run to ensure tests are in a starting passing state
         * and also log the results so test runs during the mutation phase can
         * be optimised.
         */
        $testSuiteRunner = new UnitTestRunner(
            $container->getAdapter(),
            $container->getAdapter()->getProcess($container, true),
            $container->getTempDirectory() . '/coverage.humbug.txt'
        );

        $testSuiteRunner->addObserver(
            new LoggingObserver(
                $renderer,
                $output,
                new ProgressBarObserver($input, $output)
            )
        );

        $result = $testSuiteRunner->run($container);

        /**
         * Check if the initial test run ended with a fatal error
         */
        if (! $result->isSuccess()) {
            return 1;
        }

        $output->write(PHP_EOL);

        /**
         * Message re Static Analysis
         */
        $renderer->renderStaticAnalysisStart();
        $output->write(PHP_EOL);

        $incrementalCache = null;
        if ($input->getOption('incremental')) {
            $incrementalCache = new IncrementalCache($container);
        }

        $mutationTestingRunner = $this->builder->build($container, $renderer, $input, $output);
        $mutationTestingRunner->run($result->getCoverage(), $this->mutableIterator, $incrementalCache);

        if ($this->isLoggingEnabled()) {
            $output->write(PHP_EOL);
        }

        if ($input->getOption('incremental')) {
            $incrementalCache->write();
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (PHP_SAPI !== 'phpdbg' && !defined('HHVM_VERSION') && !extension_loaded('xdebug')) {
            $output->writeln(
                '<error>You need to install and enable xdebug, or use phpdbg, '
                . 'in order to allow for code coverage generation.</error>'
            );
            return 1;
        }

        Performance::upMemProfiler();

        $this->validate($input);
        $container = $this->container = new Container($input->getOptions());

        $this->doConfiguration($input);

        if ($this->isLoggingEnabled()) {
            $this->removeOldLogFiles();
        } else {
            $output->writeln('<error>No log file is specified. Detailed results '
                . 'will not be available.</error>');
            $output->write(PHP_EOL);
        }

        if ($input->getOption('incremental')) {
            $output->writeln('<error>Incremental Analysis is an experimental feature and will very likely</error>');
            $output->writeln('<error>yield inaccurate results at this time.</error>');
            $output->write(PHP_EOL);
        }

        if ($this->textLogFile) {
            $renderer = new Text($output, true);
        } else {
            $renderer = new Text($output);
        }

        /**
         * Make initial test run to ensure tests are in a starting passing state
         * and also log the results so test runs during the mutation phase can
         * be optimised.
         */
        $testSuiteRunner = new UnitTestRunner(
            $container->getAdapter(),
            $container->getAdapter()->getProcess($container, true),
            $container->getTempDirectory() . '/coverage.humbug.txt'
        );

        $testSuiteRunner->addObserver(
            new LoggingObserver(
                $renderer,
                $output,
                new ProgressBarObserver($input, $output)
            )
        );

        $result = $testSuiteRunner->run($container);

        /**
         * Check if the initial test run ended with a fatal error
         */
        if (! $result->isSuccess()) {
            return 1;
        }

        $output->write(PHP_EOL);

        /**
         * Message re Static Analysis
         */
        $renderer->renderStaticAnalysisStart();
        $output->write(PHP_EOL);

        $incrementalCache = null;
        if ($input->getOption('incremental')) {
            $incrementalCache = new IncrementalCache($container);
        }

        $mutationTestingRunner = $this->builder->build($container, $renderer, $input, $output);
        $mutationTestingRunner->run($result->getCoverage(), $this->mutableIterator, $incrementalCache);

        if ($this->isLoggingEnabled()) {
            $output->write(PHP_EOL);
        }

        if ($input->getOption('incremental')) {
            $incrementalCache->write();
        }
    }
Execute the command.

@param InputInterface $input
@param OutputInterface $output
@return void|int