diff --git a/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php index 90dd8f1dfe..da0fc652f6 100644 --- a/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Form/Console/Descriptor/TextDescriptor.php @@ -11,12 +11,10 @@ namespace Symfony\Component\Form\Console\Descriptor; +use Symfony\Component\Console\Helper\Dumper; use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Form\ResolvedFormTypeInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\VarDumper\Caster\Caster; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; /** * @author Yonel Ceruto @@ -97,7 +95,7 @@ class TextDescriptor extends Descriptor { $definition = $this->getOptionDefinition($optionsResolver, $options['option']); - $dump = $this->getDumpFunction(); + $dump = new Dumper($this->output); $map = []; if ($definition['deprecated']) { $map = [ @@ -180,23 +178,4 @@ class TextDescriptor extends Descriptor return $options; } - - private function getDumpFunction() - { - $cloner = new VarCloner(); - $cloner->addCasters(['Closure' => function ($c, $a) { - $prefix = Caster::PREFIX_VIRTUAL; - - return [ - $prefix.'file' => $a[$prefix.'file'], - $prefix.'line' => $a[$prefix.'line'], - ]; - }]); - $dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); - $dumper->setColors($this->output->isDecorated()); - - return function ($value) use ($dumper, $cloner) { - return rtrim($dumper->dump($cloner->cloneVar($value)->withRefHandles(false), true)); - }; - } } diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index 4319a23f10..fd6a8db2ad 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -153,6 +153,43 @@ TXT $this->createCommandTester()->execute(['class' => 'test']); } + public function testDebugCustomFormTypeOption() + { + $tester = $this->createCommandTester([], [FooType::class]); + $ret = $tester->execute(['class' => FooType::class, 'option' => 'foo'], ['decorated' => false]); + + $this->assertEquals(0, $ret, 'Returns 0 in case of success'); + $this->assertStringMatchesFormat(<<<'TXT' + +Symfony\Component\Form\Tests\Command\FooType (foo) +================================================== + + ---------------- ---------------------------------------------------------------------------%s + Required true %w + ---------------- ---------------------------------------------------------------------------%s + Default - %w + ---------------- ---------------------------------------------------------------------------%s + Allowed types [ %w + "string" %w + ] %w + ---------------- ---------------------------------------------------------------------------%s + Allowed values [ %w + "bar", %w + "baz" %w + ] %w + ---------------- ---------------------------------------------------------------------------%s + Normalizer Closure(Options $options, $value) { %w + class: "Symfony\Component\Form\Tests\Command\FooType" %w + this: Symfony\Component\Form\Tests\Command\FooType { …} %w + file: "%s"%w + line: "%d to %d"%w + } %w + ---------------- ---------------------------------------------------------------------------%s + +TXT + , $tester->getDisplay(true)); + } + private function createCommandTester(array $namespaces = ['Symfony\Component\Form\Extension\Core\Type'], array $types = []) { $formRegistry = new FormRegistry([], new ResolvedFormTypeFactory()); diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 256041a7c1..6de2563a7b 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -29,15 +29,16 @@ "symfony/validator": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/config": "~3.4|~4.0", - "symfony/console": "~3.4|~4.0", + "symfony/console": "^4.3", "symfony/http-foundation": "~3.4|~4.0", "symfony/http-kernel": "~4.3", "symfony/security-csrf": "~3.4|~4.0", "symfony/translation": "~4.2", - "symfony/var-dumper": "~3.4|~4.0" + "symfony/var-dumper": "^4.3" }, "conflict": { "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", + "symfony/console": "<4.3", "symfony/dependency-injection": "<3.4", "symfony/doctrine-bridge": "<3.4", "symfony/framework-bundle": "<3.4",