Add maker command for form type extensions

by @yceruto

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

$ curl https://fabbot.io/patch/symfony/maker-bundle/85/891b7e56f93db3584d7eaad7a669ae6696057938/cs.diff | patch -p0
diff -ru src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php
--- src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php	2018-01-12 00:58:09.611975566 +0000
+++ src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php	2018-01-12 00:58:11.227941820 +0000
@@ -29,10 +29,10 @@
             $container->register(
                 sprintf('maker.auto_command.%s', Str::asTwigVariable($class::getCommandName())),
                 MakerCommand::class
-            )->setArguments([
+            )->setArguments(array(
                 new Reference($id),
                 new Reference('maker.generator'),
-            ])->addTag('console.command', ['command' => $class::getCommandName()]);
+            ))->addTag('console.command', array('command' => $class::getCommandName()));
         }
     }
 
@@ -42,7 +42,7 @@
             return;
         }
 
-        $typesMap = [];
+        $typesMap = array();
         // add core form types
         $coreExtension = new CoreExtension();
         $loadTypesRefMethod = (new \ReflectionObject($coreExtension))->getMethod('loadTypes');
@@ -61,7 +61,7 @@
             if (isset($typesMap[$cn])) {
                 if (!\in_array($fqcn, (array) $typesMap[$cn], true)) {
                     // preparing for ambiguous question
-                    $typesMap[$cn] = array_merge((array) $typesMap[$cn], [$fqcn]);
+                    $typesMap[$cn] = array_merge((array) $typesMap[$cn], array($fqcn));
                 }
             } else {
                 $typesMap[$cn] = $fqcn;
diff -ru src/Maker/MakeFormTypeExtension.php src/Maker/MakeFormTypeExtension.php
--- src/Maker/MakeFormTypeExtension.php	2018-01-12 00:58:09.736972956 +0000
+++ src/Maker/MakeFormTypeExtension.php	2018-01-12 00:58:11.082944848 +0000
@@ -29,7 +29,7 @@
 {
     private $types;
 
-    public function __construct(array $types = [])
+    public function __construct(array $types = array())
     {
         $this->types = $types;
     }
@@ -83,28 +83,28 @@
         $extendedTypeClass = $input->getArgument('extended_type');
         Validator::validateClassExists($extendedTypeClass);
 
-        return [
+        return array(
             'type_extension_class_name' => $typeExtensionClassName,
             'extended_type_class' => $extendedTypeClass,
             'extended_type_class_name' => \array_slice(explode('\\', $extendedTypeClass), -1)[0],
-        ];
+        );
     }
 
     public function getFiles(array $params): array
     {
-        return [
+        return array(
             __DIR__.'/../Resources/skeleton/form/TypeExtension.tpl.php' => 'src/Form/Extension/'.$params['type_extension_class_name'].'.php',
-        ];
+        );
     }
 
     public function writeSuccessMessage(array $params, ConsoleStyle $io)
     {
         parent::writeSuccessMessage($params, $io);
 
-        $io->text([
+        $io->text(array(
             'Next: Make Symfony aware of your form type extension by registering it as a service.',
             'Find the documentation at <fg=yellow>https://symfony.com/doc/current/form/create_form_type_extension.html</>',
-        ]);
+        ));
     }
 
     public function configureDependencies(DependencyBuilder $dependencies)
diff -ru src/Resources/skeleton/form/TypeExtension.tpl.php src/Resources/skeleton/form/TypeExtension.tpl.php
--- src/Resources/skeleton/form/TypeExtension.tpl.php	2018-01-12 00:58:10.131964707 +0000
+++ src/Resources/skeleton/form/TypeExtension.tpl.php	2018-01-12 00:58:10.915948335 +0000
@@ -1,12 +1,12 @@
-<?= "<?php\n" ?>
+<?= "<?php\n"; ?>
 
 namespace App\Form\Extension;
 
 use Symfony\Component\Form\AbstractTypeExtension;
 use Symfony\Component\OptionsResolver\OptionsResolver;
-use <?= $extended_type_class ?>;
+use <?= $extended_type_class; ?>;
 
-class <?= $type_extension_class_name ?> extends AbstractTypeExtension
+class <?= $type_extension_class_name; ?> extends AbstractTypeExtension
 {
     public function configureOptions(OptionsResolver $resolver)
     {
@@ -17,6 +17,6 @@
 
     public function getExtendedType()
     {
-        return <?= $extended_type_class_name ?>::class;
+        return <?= $extended_type_class_name; ?>::class;
     }
 }
diff -ru tests/Maker/FunctionalTest.php tests/Maker/FunctionalTest.php
--- tests/Maker/FunctionalTest.php	2018-01-12 00:58:10.406958965 +0000
+++ tests/Maker/FunctionalTest.php	2018-01-12 00:58:11.843928956 +0000
@@ -51,30 +51,30 @@
 
     public function getCommandTests()
     {
-        yield 'command' => [MakerTestDetails::createTest(
+        yield 'command' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeCommand::class),
-            [
+            array(
                 // command name
                 'app:foo',
-            ])
-            ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeCommand')
-        ];
+            ))
+            ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeCommand'),
+        );
 
-        yield 'controller' => [MakerTestDetails::createTest(
+        yield 'controller' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeController::class),
-            [
+            array(
                 // controller class name
                 'FooBar',
-            ])
-            ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeController')
-        ];
+            ))
+            ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeController'),
+        );
 
-        yield 'entity' => [MakerTestDetails::createTest(
+        yield 'entity' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeEntity::class),
-            [
+            array(
                 // entity class name
                 'TastyFood',
-            ])
+            ))
             ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeEntity')
             ->addReplacement(
                 'phpunit.xml.dist',
@@ -88,109 +88,109 @@
                 'mysql://db_user:db_password@127.0.0.1:3306/db_name',
                 'sqlite:///%kernel.project_dir%/var/app.db'
             )
-            ->addPostMakeCommand('./bin/console doctrine:schema:create --env=test')
-        ];
+            ->addPostMakeCommand('./bin/console doctrine:schema:create --env=test'),
+        );
 
-        yield 'form' => [MakerTestDetails::createTest(
+        yield 'form' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeForm::class),
-            [
+            array(
                 // form name
                 'FooBar',
-            ])
-        ];
+            )),
+        );
 
-        yield 'form_type_extension' => [MakerTestDetails::createTest(
+        yield 'form_type_extension' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeFormTypeExtension::class),
-            [
+            array(
                 // form name
                 'FooBar',
                 // extended type
-                'FormType'
-            ])
-        ];
+                'FormType',
+            )),
+        );
 
-        yield 'functional' => [MakerTestDetails::createTest(
+        yield 'functional' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeFunctionalTest::class),
-            [
+            array(
                 // functional test class name
                 'FooBar',
-            ])
-            ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeFunctional')
-        ];
+            ))
+            ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeFunctional'),
+        );
 
-        yield 'subscriber' => [MakerTestDetails::createTest(
+        yield 'subscriber' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeSubscriber::class),
-            [
+            array(
                 // subscriber name
                 'FooBar',
                 // event name
                 'kernel.request',
-            ])
-        ];
+            )),
+        );
 
-        yield 'subscriber_unknown_event_class' => [MakerTestDetails::createTest(
+        yield 'subscriber_unknown_event_class' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeSubscriber::class),
-            [
+            array(
                 // subscriber name
                 'FooBar',
                 // event name
                 'foo.unknown_event',
-            ])
-        ];
+            )),
+        );
 
-        yield 'serializer_encoder' => [MakerTestDetails::createTest(
+        yield 'serializer_encoder' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeSerializerEncoder::class),
-            [
+            array(
                 // encoder class name
                 'FooBarEncoder',
                 // encoder format
                 'foobar',
-            ])
-        ];
+            )),
+        );
 
-        yield 'twig_extension' => [MakerTestDetails::createTest(
+        yield 'twig_extension' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeTwigExtension::class),
-            [
+            array(
                 // extension class name
                 'FooBar',
-            ])
-        ];
+            )),
+        );
 
-        yield 'unit_test' => [MakerTestDetails::createTest(
+        yield 'unit_test' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeUnitTest::class),
-            [
+            array(
                 // class name
                 'FooBar',
-            ])
-        ];
+            )),
+        );
 
-        yield 'validator' => [MakerTestDetails::createTest(
+        yield 'validator' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeValidator::class),
-            [
+            array(
                 // validator name
                 'FooBar',
-            ])
-        ];
+            )),
+        );
 
-        yield 'voter' => [MakerTestDetails::createTest(
+        yield 'voter' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeVoter::class),
-            [
+            array(
                 // voter class name
                 'FooBar',
-            ])
-        ];
+            )),
+        );
 
-        yield 'auth_empty' => [MakerTestDetails::createTest(
+        yield 'auth_empty' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeAuthenticator::class),
-            [
+            array(
                 // class name
                 'AppCustomAuthenticator',
-            ])
-        ];
+            )),
+        );
 
-        yield 'migration_with_changes' => [MakerTestDetails::createTest(
+        yield 'migration_with_changes' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeMigration::class),
-            [/* no input */])
+            array(/* no input */))
             ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeMigration')
             ->addReplacement(
                 '.env',
@@ -201,7 +201,7 @@
             // only requires doctrine/dbal. But we're testing with the ORM,
             // so let's install it
             ->addExtraDependencies('doctrine/orm')
-            ->assert(function(string $output, string $directory) {
+            ->assert(function (string $output, string $directory) {
                 $this->assertContains('Success', $output);
 
                 $finder = new Finder();
@@ -213,12 +213,12 @@
                 $iterator = $finder->getIterator();
                 $iterator->rewind();
                 $this->assertContains(sprintf('"src/Migrations/%s"', $iterator->current()->getFilename()), $output);
-            })
-        ];
+            }),
+        );
 
-        yield 'migration_no_changes' => [MakerTestDetails::createTest(
+        yield 'migration_no_changes' => array(MakerTestDetails::createTest(
             $this->getMakerInstance(MakeMigration::class),
-            [/* no input */])
+            array(/* no input */))
             ->setFixtureFilesPath(__DIR__.'/../fixtures/MakeMigration')
             ->addReplacement(
                 '.env',
@@ -228,12 +228,12 @@
             ->addExtraDependencies('doctrine/orm')
             // sync the database, so no changes are needed
             ->addPreMakeCommand('./bin/console doctrine:schema:create --env=test')
-            ->assert(function(string $output, string $directory) {
+            ->assert(function (string $output, string $directory) {
                 $this->assertNotContains('Success', $output);
 
                 $this->assertContains('No database changes were detected', $output);
-            })
-        ];
+            }),
+        );
     }
 
     /**

0
Common Typos

0
File Permissions