From da216d186bf120bafba627839bbe5a878e35e122 Mon Sep 17 00:00:00 2001 From: Lander Vanderstraeten Date: Wed, 17 Jan 2018 11:39:32 +0100 Subject: [PATCH] Remove proxy manager --- composer.json | 2 - resources/config/services.yml | 1 - src/Configuration/ContainerFactory.php | 2 - src/Console/Application.php | 86 ++++++++++++++------------ src/IO/ConsoleIO.php | 16 +++++ 5 files changed, 61 insertions(+), 46 deletions(-) diff --git a/composer.json b/composer.json index ecb70f366..7e6f60079 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,6 @@ "doctrine/collections": "~1.2", "gitonomy/gitlib": "^1.0.3", "monolog/monolog": "~1.16", - "ocramius/proxy-manager": "~0.4|~1.0|~2.0", "seld/jsonlint": "~1.1", "symfony/config": "~2.7|~3.0|~4.0", "symfony/console": "~2.7|~3.0|~4.0", @@ -20,7 +19,6 @@ "symfony/finder": "~2.7|~3.0|~4.0", "symfony/options-resolver": "~2.7|~3.0|~4.0", "symfony/process": "~2.7|~3.0|~4.0", - "symfony/proxy-manager-bridge": "~2.7|~3.0|~4.0", "symfony/yaml": "~2.7|~3.0|~4.0" }, "require-dev": { diff --git a/resources/config/services.yml b/resources/config/services.yml index 0b088affe..d90acd050 100644 --- a/resources/config/services.yml +++ b/resources/config/services.yml @@ -79,7 +79,6 @@ services: grumphp.io.console: class: GrumPHP\IO\ConsoleIO - lazy: true arguments: - '@console.input' - '@console.output' diff --git a/src/Configuration/ContainerFactory.php b/src/Configuration/ContainerFactory.php index 9bc1307db..66d032045 100644 --- a/src/Configuration/ContainerFactory.php +++ b/src/Configuration/ContainerFactory.php @@ -3,7 +3,6 @@ namespace GrumPHP\Configuration; use GrumPHP\Util\Filesystem; -use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -19,7 +18,6 @@ final class ContainerFactory public static function buildFromConfiguration($path) { $container = new ContainerBuilder(); - $container->setProxyInstantiator(new RuntimeInstantiator()); // Add compiler passes: $container->addCompilerPass(new Compiler\ExtensionCompilerPass()); diff --git a/src/Console/Application.php b/src/Console/Application.php index 50117a095..73166adba 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -4,7 +4,7 @@ use GrumPHP\Configuration\ContainerFactory; use GrumPHP\Exception\RuntimeException; -use GrumPHP\IO\IOInterface; +use GrumPHP\IO\ConsoleIO; use GrumPHP\Locator\ConfigurationFile; use GrumPHP\Util\Composer; use GrumPHP\Util\Filesystem; @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -42,9 +43,6 @@ class Application extends SymfonyConsole */ protected $composerHelper; - /** - * Set up application: - */ public function __construct() { $this->filesystem = new Filesystem(); @@ -78,64 +76,64 @@ protected function getDefaultInputDefinition() */ protected function getDefaultCommands() { - $container = $this->getContainer(); $commands = parent::getDefaultCommands(); $commands[] = new Command\ConfigureCommand( - $container->get('config'), - $container->get('grumphp.util.filesystem'), - $container->get('git.repository') + $this->container->get('config'), + $this->container->get('grumphp.util.filesystem'), + $this->container->get('git.repository') ); $commands[] = new Command\RunCommand( - $container->get('config'), - $container->get('locator.registered_files') + $this->container->get('config'), + $this->container->get('locator.registered_files') ); $commands[] = new Command\Git\CommitMsgCommand( - $container->get('config'), - $container->get('locator.changed_files'), - $container->get('grumphp.util.filesystem') + $this->container->get('config'), + $this->container->get('locator.changed_files'), + $this->container->get('grumphp.util.filesystem') ); $commands[] = new Command\Git\DeInitCommand( - $container->get('config'), - $container->get('grumphp.util.filesystem') + $this->container->get('config'), + $this->container->get('grumphp.util.filesystem') ); $commands[] = new Command\Git\InitCommand( - $container->get('config'), - $container->get('grumphp.util.filesystem'), - $container->get('process_builder') + $this->container->get('config'), + $this->container->get('grumphp.util.filesystem'), + $this->container->get('process_builder') ); $commands[] = new Command\Git\PreCommitCommand( - $container->get('config'), - $container->get('locator.changed_files') + $this->container->get('config'), + $this->container->get('locator.changed_files') ); return $commands; } + /** + * {@inheritdoc} + */ protected function getDefaultHelperSet() { - $container = $this->getContainer(); - $helperSet = parent::getDefaultHelperSet(); $helperSet->set($this->initializeComposerHelper()); $helperSet->set(new Helper\PathsHelper( - $container->get('config'), - $container->get('grumphp.util.filesystem'), - $container->get('locator.external_command'), + $this->container->get('config'), + $this->container->get('grumphp.util.filesystem'), + $this->container->get('locator.external_command'), $this->getDefaultConfigPath() )); $helperSet->set(new Helper\TaskRunnerHelper( - $container->get('config'), - $container->get('task_runner'), - $container->get('event_dispatcher') + $this->container->get('config'), + $this->container->get('task_runner'), + $this->container->get('event_dispatcher') )); return $helperSet; } /** - * @return \Symfony\Component\DependencyInjection\ContainerBuilder + * @return ContainerBuilder */ protected function getContainer() { @@ -146,35 +144,30 @@ protected function getContainer() // Load cli options: $input = new ArgvInput(); $configPath = $input->getParameterOption(['--config', '-c'], $this->getDefaultConfigPath()); + $output = new ConsoleOutput(); // Build the service container: $this->container = ContainerFactory::buildFromConfiguration($configPath); + $this->container->set('console.input', $input); + $this->container->set('console.output', $output); return $this->container; } /** - * Configure IO of GrumPHP objects - * - * @param InputInterface $input - * @param OutputInterface $output + * {@inheritdoc} */ protected function configureIO(InputInterface $input, OutputInterface $output) { parent::configureIO($input, $output); - $container = $this->getContainer(); - - // Register the console input and output to the container - $container->set('console.input', $input); - $container->set('console.output', $output); + /** @var ConsoleIO $io */ + $io = $this->container->get('grumphp.io.console'); // Redirect the GrumPHP logger to the stdout in verbose mode - /** @var IOInterface $io */ - $io = $container->get('grumphp.io.console'); if ($io->isVerbose()) { /** @var Logger $logger */ - $logger = $container->get('grumphp.logger'); + $logger = $this->container->get('grumphp.logger'); $logger->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG)); } } @@ -218,4 +211,15 @@ protected function initializeComposerHelper() return $this->composerHelper = new Helper\ComposerHelper($configuration, $rootPackage); } + + /** + * {@inheritdoc} + */ + public function run(InputInterface $input = null, OutputInterface $output = null) + { + /** @var ConsoleIO $io */ + $io = $this->container->get('grumphp.io.console'); + + return parent::run($io->getInput(), $io->getOutput()); + } } diff --git a/src/IO/ConsoleIO.php b/src/IO/ConsoleIO.php index 7db6cef9b..e541e903d 100644 --- a/src/IO/ConsoleIO.php +++ b/src/IO/ConsoleIO.php @@ -92,6 +92,22 @@ public function writeError($messages, $newline = true) $this->doWrite($messages, $newline, true); } + /** + * @return InputInterface + */ + public function getInput() + { + return $this->input; + } + + /** + * @return OutputInterface + */ + public function getOutput() + { + return $this->output; + } + /** * @param resource $handle *