ServerDumpPlaceholderCommand.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\DebugBundle\Command;
  11. use Symfony\Component\Console\Command\Command;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. use Symfony\Component\Console\Style\SymfonyStyle;
  15. use Symfony\Component\VarDumper\Command\ServerDumpCommand;
  16. use Symfony\Component\VarDumper\Server\DumpServer;
  17. /**
  18. * A placeholder command easing VarDumper server discovery.
  19. *
  20. * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
  21. *
  22. * @internal
  23. */
  24. class ServerDumpPlaceholderCommand extends Command
  25. {
  26. private $replacedCommand;
  27. public function __construct(DumpServer $server = null, array $descriptors = [])
  28. {
  29. $this->replacedCommand = new ServerDumpCommand((new \ReflectionClass(DumpServer::class))->newInstanceWithoutConstructor(), $descriptors);
  30. parent::__construct();
  31. }
  32. protected function configure()
  33. {
  34. $this->setDefinition($this->replacedCommand->getDefinition());
  35. $this->setHelp($this->replacedCommand->getHelp());
  36. $this->setDescription($this->replacedCommand->getDescription());
  37. }
  38. protected function execute(InputInterface $input, OutputInterface $output): int
  39. {
  40. (new SymfonyStyle($input, $output))->getErrorStyle()->warning('In order to use the VarDumper server, set the "debug.dump_destination" config option to "tcp://%env(VAR_DUMPER_SERVER)%"');
  41. return 8;
  42. }
  43. }