File: ServerDumpPlaceholderCommand.php

package info (click to toggle)
symfony 7.4.0~rc2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 133,256 kB
  • sloc: php: 1,543,830; xml: 7,134; javascript: 979; sh: 584; makefile: 250; pascal: 70
file content (54 lines) | stat: -rw-r--r-- 1,868 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\DebugBundle\Command;

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\VarDumper\Command\ServerDumpCommand;
use Symfony\Component\VarDumper\Server\DumpServer;

/**
 * A placeholder command easing VarDumper server discovery.
 *
 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
 *
 * @internal
 */
#[AsCommand(name: 'server:dump', description: 'Start a dump server that collects and displays dumps in a single place')]
class ServerDumpPlaceholderCommand extends Command
{
    private ServerDumpCommand $replacedCommand;

    public function __construct(?DumpServer $server = null, array $descriptors = [])
    {
        $this->replacedCommand = new ServerDumpCommand((new \ReflectionClass(DumpServer::class))->newInstanceWithoutConstructor(), $descriptors);

        parent::__construct();
    }

    protected function configure(): void
    {
        $this->setDefinition($this->replacedCommand->getDefinition());
        $this->setHelp($this->replacedCommand->getHelp());
        $this->setDescription($this->replacedCommand->getDescription());
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        (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)%"');

        return 8;
    }
}