public function compile()
 {
     foreach (PluginRepository::findAll() as $plugin) {
         $containerBuilder = new UnfreezableContainerBuilder();
         $containerBuilder->registerExtension(new GeneralExtension());
         $extensionClass = new \ReflectionClass('Stagehand\\TestRunner\\DependencyInjection\\Extension\\' . $plugin->getPluginID() . 'Extension');
         if (!$extensionClass->isInterface() && !$extensionClass->isAbstract() && $extensionClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')) {
             $containerBuilder->registerExtension($extensionClass->newInstance());
         }
         foreach ($containerBuilder->getExtensions() as $extension) {
             /* @var $extension \Symfony\Component\DependencyInjection\Extension\ExtensionInterface */
             $containerBuilder->loadFromExtension($extension->getAlias(), array());
         }
         $containerBuilder->addCompilerPass(new ReplaceDefinitionByPluginDefinitionPass($plugin));
         $containerBuilder->getCompilerPassConfig()->setOptimizationPasses(array_filter($containerBuilder->getCompilerPassConfig()->getOptimizationPasses(), function (CompilerPassInterface $compilerPass) {
             return !$compilerPass instanceof ResolveParameterPlaceHoldersPass;
         }));
         ErrorReporting::invokeWith(error_reporting() & ~E_USER_DEPRECATED, function () use($containerBuilder) {
             $containerBuilder->compile();
         });
         $phpDumper = new PhpDumper($containerBuilder);
         $containerClass = $plugin->getPluginID() . 'Container';
         $containerClassSource = $phpDumper->dump(array('class' => $containerClass));
         $containerClassSource = preg_replace('/^<\\?php/', '<?php' . PHP_EOL . 'namespace ' . self::COMPILED_CONTAINER_NAMESPACE . ';' . PHP_EOL, $containerClassSource);
         file_put_contents(__DIR__ . '/../' . $containerClass . '.php', $containerClassSource);
     }
 }
 public function clearOutputHandlers()
 {
     $self = $this;
     ErrorReporting::invokeWith(E_NOTICE, function () use($self) {
         while ($self->getNestingLevel()) {
             $self->clearOutputHandler();
         }
     });
 }
 public function prepare()
 {
     parent::prepare();
     if (is_null($this->getCIUnitPath())) {
         $ciunitPath = ApplicationContext::getInstance()->getEnvironment()->getWorkingDirectoryAtStartup();
     } else {
         $ciunitPath = $this->getCIUnitPath();
     }
     /* Removes some superglobals and environment variables to avoid getting invalid
      * URI string by the CIUnit URI object since some cases PDT sets some
      * environment variables for debugging.
      */
     $this->backupVariables();
     ErrorReporting::invokeWith(error_reporting() & ~E_USER_NOTICE, function () use($ciunitPath) {
         require_once $ciunitPath . '/CIUnit.php';
     });
     $this->restoreVariables();
 }
 public function prepare()
 {
     if (defined('STAGEHAND_TESTRUNNER_PREPARER_CAKEPREPARER_PREPARECALLEDMARKER')) {
         return;
     }
     define('STAGEHAND_TESTRUNNER_PREPARER_CAKEPREPARER_PREPARECALLEDMARKER', true);
     if (!defined('DISABLE_AUTO_DISPATCH')) {
         define('DISABLE_AUTO_DISPATCH', true);
     }
     if (is_null($this->getCakePHPAppPath())) {
         $cakephpAppPath = $this->environment->getWorkingDirectoryAtStartup();
     } else {
         $cakephpAppPath = $this->getCakePHPAppPath();
     }
     $rootPath = realpath($cakephpAppPath . '/..');
     $appPath = basename(realpath($cakephpAppPath));
     if (is_null($this->getCakePHPCorePath())) {
         $corePath = $rootPath . DIRECTORY_SEPARATOR . 'cake';
     } else {
         $corePath = realpath($this->getCakePHPCorePath());
     }
     if (!defined('TEST_CAKE_CORE_INCLUDE_PATH')) {
         define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
     }
     ob_start();
     require_once $corePath . '/console/cake.php';
     ErrorReporting::invokeWith(error_reporting(), function () use($rootPath, $appPath) {
         new TestRunnerShellDispatcher(array('-root', $rootPath, '-app', $appPath));
     });
     ob_end_clean();
     require_once $corePath . '/tests/lib/test_manager.php';
     new \TestManager();
 }