Skip to content

Commit d4992f4

Browse files
committed
[make:form] suffix with "Form" instead of "Type"
1 parent 2140aff commit d4992f4

18 files changed

+39
-39
lines changed

config/help/MakeForm.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
The <info>%command.name%</info> command generates a new form class.
22

3-
<info>php %command.full_name% UserType</info>
3+
<info>php %command.full_name% UserForm</info>
44

55
If the argument is missing, the command will ask for the form class interactively.
66

77
You can optionally specify the bound class in a second argument.
88
This can be the name of an entity like <info>User</info>
99

10-
<info>php %command.full_name% UserType User</info>
10+
<info>php %command.full_name% UserForm User</info>
1111

1212
You can also specify a fully qualified name to another class like <info>\App\Dto\UserData</info>.
1313
Slashes must be escaped in the argument.
1414

15-
<info>php %command.full_name% UserType \\App\\Dto\\UserData</info>
15+
<info>php %command.full_name% UserForm \\App\\Dto\\UserData</info>
1616

src/Maker/MakeForm.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function getCommandDescription(): string
5151
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
5252
{
5353
$command
54-
->addArgument('name', InputArgument::OPTIONAL, \sprintf('The name of the form class (e.g. <fg=yellow>%sType</>)', Str::asClassName(Str::getRandomTerm())))
54+
->addArgument('name', InputArgument::OPTIONAL, \sprintf('The name of the form class (e.g. <fg=yellow>%Form</>)', Str::asClassName(Str::getRandomTerm())))
5555
->addArgument('bound-class', InputArgument::OPTIONAL, 'The name of Entity or fully qualified model class name that the new form will be bound to (empty for none)')
5656
->setHelp($this->getHelpFileContents('MakeForm.txt'))
5757
;
@@ -80,7 +80,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
8080
$formClassNameDetails = $generator->createClassNameDetails(
8181
$input->getArgument('name'),
8282
'Form\\',
83-
'Type'
83+
'Form'
8484
);
8585

8686
$formFields = ['field_name' => null];

src/Maker/MakeRegistrationForm.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public function configureDependencies(DependencyBuilder $dependencies): void
548548
private function generateFormClass(ClassNameDetails $userClassDetails, Generator $generator, string $usernameField): ClassNameDetails
549549
{
550550
$formClassDetails = $generator->createClassNameDetails(
551-
'RegistrationFormType',
551+
'RegistrationForm',
552552
'Form\\'
553553
);
554554

src/Renderer/FormTypeRenderer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function render(ClassNameDetails $formClassDetails, array $formFields, ?C
7070

7171
$this->generator->generateClass(
7272
$formClassDetails->getFullName(),
73-
'form/Type.tpl.php',
73+
'form/Form.tpl.php',
7474
[
7575
'use_statements' => $useStatements,
7676
'bounded_class_name' => $boundClassDetails ? $boundClassDetails->getShortName() : null,
File renamed without changes.

tests/Maker/MakeFormTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getTestDetails(): \Generator
5050

5151
$runner->runMaker([
5252
// Entity name
53-
'SourFoodType',
53+
'SourFoodForm',
5454
'SourFood',
5555
]);
5656

@@ -67,7 +67,7 @@ public function getTestDetails(): \Generator
6767

6868
$runner->runMaker([
6969
// Entity name
70-
'TaskType',
70+
'TaskForm',
7171
'\\App\\Form\\Data\\TaskData',
7272
]);
7373

@@ -89,7 +89,7 @@ public function getTestDetails(): \Generator
8989

9090
$runner->runMaker([
9191
// Entity name
92-
'SourFoodType',
92+
'SourFoodForm',
9393
'SourFood',
9494
]);
9595

@@ -111,7 +111,7 @@ public function getTestDetails(): \Generator
111111

112112
$runner->runMaker([
113113
// Entity name
114-
'BookType',
114+
'BookForm',
115115
'Book',
116116
]);
117117

@@ -132,7 +132,7 @@ public function getTestDetails(): \Generator
132132

133133
$runner->runMaker([
134134
// Entity name
135-
'AuthorType',
135+
'AuthorForm',
136136
'Author',
137137
]);
138138

@@ -153,7 +153,7 @@ public function getTestDetails(): \Generator
153153

154154
$runner->runMaker([
155155
// Entity name
156-
'BookType',
156+
'BookForm',
157157
'Book',
158158
]);
159159

@@ -174,7 +174,7 @@ public function getTestDetails(): \Generator
174174

175175
$runner->runMaker([
176176
// Entity name
177-
'LibraryType',
177+
'LibraryForm',
178178
'Library',
179179
]);
180180

@@ -195,7 +195,7 @@ public function getTestDetails(): \Generator
195195

196196
$runner->runMaker([
197197
// Entity name
198-
'FoodType',
198+
'FoodForm',
199199
'Food',
200200
]);
201201

tests/fixtures/make-form/tests/it_generates_basic_form.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Tests;
44

5-
use App\Form\FooBarType;
5+
use App\Form\FooBarForm;
66
use Symfony\Component\Form\Test\TypeTestCase;
77

88
class GeneratedFormTest extends TypeTestCase
@@ -13,7 +13,7 @@ public function testGeneratedForm()
1313
'field_name' => 'field_value',
1414
];
1515

16-
$form = $this->factory->create(FooBarType::class);
16+
$form = $this->factory->create(FooBarForm::class);
1717
$form->submit($formData);
1818

1919
$this->assertTrue($form->isSynchronized());

tests/fixtures/make-form/tests/it_generates_form_with_embeddable_entity.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Tests;
44

55
use App\Entity\Food;
6-
use App\Form\FoodType;
6+
use App\Form\FoodForm;
77
use Symfony\Component\Form\Test\TypeTestCase;
88

99
class GeneratedFormTest extends TypeTestCase
@@ -14,7 +14,7 @@ public function testGeneratedForm()
1414
'title' => 'lemon',
1515
];
1616

17-
$form = $this->factory->create(FoodType::class);
17+
$form = $this->factory->create(FoodForm::class);
1818
$form->submit($formData);
1919

2020
$object = new Food();

tests/fixtures/make-form/tests/it_generates_form_with_entity.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Tests;
44

55
use App\Entity\SourFood;
6-
use App\Form\SourFoodType;
6+
use App\Form\SourFoodForm;
77
use Symfony\Component\Form\Test\TypeTestCase;
88

99
class GeneratedFormTest extends TypeTestCase
@@ -14,7 +14,7 @@ public function testGeneratedForm()
1414
'title' => 'lemon',
1515
];
1616

17-
$form = $this->factory->create(SourFoodType::class);
17+
$form = $this->factory->create(SourFoodForm::class);
1818
$form->submit($formData);
1919

2020
$object = new SourFood();

tests/fixtures/make-form/tests/it_generates_form_with_many_to_many_relation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Entity\Library;
66
use App\Entity\Book;
7-
use App\Form\BookType;
7+
use App\Form\BookForm;
88
use Doctrine\Common\Collections\ArrayCollection;
99
use Doctrine\ORM\EntityManager;
1010
use Doctrine\ORM\EntityRepository;
@@ -23,7 +23,7 @@ class GeneratedFormTest extends TypeTestCase
2323
*/
2424
public function testGeneratedFormWithMultipleChoices($formData, $collection)
2525
{
26-
$form = $this->factory->create(BookType::class);
26+
$form = $this->factory->create(BookForm::class);
2727
$form->submit($formData);
2828

2929
$object = new Book();

tests/fixtures/make-form/tests/it_generates_form_with_many_to_one_relation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Entity\Author;
66
use App\Entity\Book;
7-
use App\Form\BookType;
7+
use App\Form\BookForm;
88
use Doctrine\ORM\EntityManager;
99
use Doctrine\ORM\EntityRepository;
1010
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -26,7 +26,7 @@ public function testGeneratedForm()
2626
'author' => 0,
2727
];
2828

29-
$form = $this->factory->create(BookType::class);
29+
$form = $this->factory->create(BookForm::class);
3030
$form->submit($formData);
3131

3232
$object = new Book();

tests/fixtures/make-form/tests/it_generates_form_with_non_entity_dto.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace App\Tests;
1313

1414
use App\Form\Data\TaskData;
15-
use App\Form\TaskType;
15+
use App\Form\TaskForm;
1616
use Symfony\Component\Form\Test\TypeTestCase;
1717

1818
class GeneratedFormTest extends TypeTestCase
@@ -28,7 +28,7 @@ public function testGeneratedForm()
2828

2929
$objectToCompare = new TaskData();
3030

31-
$form = $this->factory->create(TaskType::class, $objectToCompare);
31+
$form = $this->factory->create(TaskForm::class, $objectToCompare);
3232
$form->submit($formData);
3333

3434
$object = new TaskData();

tests/fixtures/make-form/tests/it_generates_form_with_one_to_many_relation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Entity\Author;
66
use App\Entity\Book;
7-
use App\Form\AuthorType;
7+
use App\Form\AuthorForm;
88
use Symfony\Component\Form\PreloadedExtension;
99
use Symfony\Component\Form\Test\TypeTestCase;
1010

@@ -16,7 +16,7 @@ public function testGeneratedForm()
1616
'name' => 'foo',
1717
];
1818

19-
$form = $this->factory->create(AuthorType::class);
19+
$form = $this->factory->create(AuthorForm::class);
2020
$form->submit($formData);
2121

2222
$object = new Author();

tests/fixtures/make-form/tests/it_generates_form_with_one_to_one_relation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use App\Entity\Librarian;
66
use App\Entity\Library;
7-
use App\Form\LibraryType;
7+
use App\Form\LibraryForm;
88
use Doctrine\ORM\EntityManager;
99
use Doctrine\ORM\EntityRepository;
1010
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -26,7 +26,7 @@ public function testGeneratedForm()
2626
'librarian' => 0,
2727
];
2828

29-
$form = $this->factory->create(LibraryType::class);
29+
$form = $this->factory->create(LibraryForm::class);
3030
$form->submit($formData);
3131

3232
$object = new Library();

tests/fixtures/make-form/tests/it_generates_form_with_single_table_inheritance_entity.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Tests;
44

55
use App\Entity\SourFood;
6-
use App\Form\SourFoodType;
6+
use App\Form\SourFoodForm;
77
use Symfony\Component\Form\Test\TypeTestCase;
88

99
class GeneratedFormTest extends TypeTestCase
@@ -14,7 +14,7 @@ public function testGeneratedForm()
1414
'title' => 'lemon',
1515
];
1616

17-
$form = $this->factory->create(SourFoodType::class);
17+
$form = $this->factory->create(SourFoodForm::class);
1818
$form->submit($formData);
1919

2020
$object = new SourFood();

tests/fixtures/make-registration-form/expected/RegistrationControllerCustomAuthenticator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Controller;
44

55
use App\Entity\User;
6-
use App\Form\RegistrationFormType;
6+
use App\Form\RegistrationForm;
77
use App\Security\StubAuthenticator;
88
use Doctrine\ORM\EntityManagerInterface;
99
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -19,7 +19,7 @@ class RegistrationController extends AbstractController
1919
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security, EntityManagerInterface $entityManager): Response
2020
{
2121
$user = new User();
22-
$form = $this->createForm(RegistrationFormType::class, $user);
22+
$form = $this->createForm(RegistrationForm::class, $user);
2323
$form->handleRequest($request);
2424

2525
if ($form->isSubmitted() && $form->isValid()) {

tests/fixtures/make-registration-form/expected/RegistrationControllerFormLogin.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Controller;
44

55
use App\Entity\User;
6-
use App\Form\RegistrationFormType;
6+
use App\Form\RegistrationForm;
77
use Doctrine\ORM\EntityManagerInterface;
88
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
99
use Symfony\Bundle\SecurityBundle\Security;
@@ -18,7 +18,7 @@ class RegistrationController extends AbstractController
1818
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security, EntityManagerInterface $entityManager): Response
1919
{
2020
$user = new User();
21-
$form = $this->createForm(RegistrationFormType::class, $user);
21+
$form = $this->createForm(RegistrationForm::class, $user);
2222
$form->handleRequest($request);
2323

2424
if ($form->isSubmitted() && $form->isValid()) {

tests/fixtures/make-registration-form/expected/RegistrationControllerNoLogin.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace App\Controller;
44

55
use App\Entity\User;
6-
use App\Form\RegistrationFormType;
6+
use App\Form\RegistrationForm;
77
use Doctrine\ORM\EntityManagerInterface;
88
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
99
use Symfony\Component\HttpFoundation\Request;
@@ -17,7 +17,7 @@ class RegistrationController extends AbstractController
1717
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response
1818
{
1919
$user = new User();
20-
$form = $this->createForm(RegistrationFormType::class, $user);
20+
$form = $this->createForm(RegistrationForm::class, $user);
2121
$form->handleRequest($request);
2222

2323
if ($form->isSubmitted() && $form->isValid()) {

0 commit comments

Comments
 (0)