Revert "[make:form] suffix with "Form" instead of "Type""

This reverts commit 6456718e87.
This commit is contained in:
Kevin Bond
2025-06-23 11:56:19 -04:00
parent 81eb8d9df6
commit 33591e684b
28 changed files with 68 additions and 68 deletions

View File

@@ -1,16 +1,16 @@
The <info>%command.name%</info> command generates a new form class.
<info>php %command.full_name% UserForm</info>
<info>php %command.full_name% UserType</info>
If the argument is missing, the command will ask for the form class interactively.
You can optionally specify the bound class in a second argument.
This can be the name of an entity like <info>User</info>
<info>php %command.full_name% UserForm User</info>
<info>php %command.full_name% UserType User</info>
You can also specify a fully qualified name to another class like <info>\App\Dto\UserData</info>.
Slashes must be escaped in the argument.
<info>php %command.full_name% UserForm \\App\\Dto\\UserData</info>
<info>php %command.full_name% UserType \\App\\Dto\\UserData</info>

View File

@@ -140,9 +140,9 @@ final class MakeCrud extends AbstractMaker
$iter = 0;
do {
$formClassDetails = $generator->createClassNameDetails(
$entityClassDetails->getRelativeNameWithoutSuffix().($iter ?: ''),
$entityClassDetails->getRelativeNameWithoutSuffix().($iter ?: '').'Type',
'Form\\',
'Form'
'Type'
);
++$iter;
} while (class_exists($formClassDetails->getFullName()));

View File

@@ -51,7 +51,7 @@ final class MakeForm extends AbstractMaker
public function configureCommand(Command $command, InputConfiguration $inputConfig): void
{
$command
->addArgument('name', InputArgument::OPTIONAL, \sprintf('The name of the form class (e.g. <fg=yellow>%Form</>)', Str::asClassName(Str::getRandomTerm())))
->addArgument('name', InputArgument::OPTIONAL, \sprintf('The name of the form class (e.g. <fg=yellow>%sType</>)', Str::asClassName(Str::getRandomTerm())))
->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)')
->setHelp($this->getHelpFileContents('MakeForm.txt'))
;
@@ -80,7 +80,7 @@ final class MakeForm extends AbstractMaker
$formClassNameDetails = $generator->createClassNameDetails(
$input->getArgument('name'),
'Form\\',
'Form'
'Type'
);
$formFields = ['field_name' => null];

View File

@@ -548,7 +548,7 @@ final class MakeRegistrationForm extends AbstractMaker
private function generateFormClass(ClassNameDetails $userClassDetails, Generator $generator, string $usernameField): ClassNameDetails
{
$formClassDetails = $generator->createClassNameDetails(
'RegistrationForm',
'RegistrationFormType',
'Form\\'
);

View File

@@ -227,12 +227,12 @@ class MakeResetPassword extends AbstractMaker
);
$requestFormTypeClassNameDetails = $generator->createClassNameDetails(
'ResetPasswordRequestForm',
'ResetPasswordRequestFormType',
'Form\\'
);
$changePasswordFormTypeClassNameDetails = $generator->createClassNameDetails(
'ChangePasswordForm',
'ChangePasswordFormType',
'Form\\'
);
@@ -301,7 +301,7 @@ class MakeResetPassword extends AbstractMaker
$generator->generateClass(
$requestFormTypeClassNameDetails->getFullName(),
'resetPassword/ResetPasswordRequestForm.tpl.php',
'resetPassword/ResetPasswordRequestFormType.tpl.php',
[
'use_statements' => $useStatements,
'email_field' => $this->emailPropertyName,
@@ -322,7 +322,7 @@ class MakeResetPassword extends AbstractMaker
$generator->generateClass(
$changePasswordFormTypeClassNameDetails->getFullName(),
'resetPassword/ChangePasswordForm.tpl.php',
'resetPassword/ChangePasswordFormType.tpl.php',
['use_statements' => $useStatements]
);

View File

@@ -70,7 +70,7 @@ final class FormTypeRenderer
$this->generator->generateClass(
$formClassDetails->getFullName(),
'form/Form.tpl.php',
'form/Type.tpl.php',
[
'use_statements' => $useStatements,
'bounded_class_name' => $boundClassDetails ? $boundClassDetails->getShortName() : null,

View File

@@ -39,7 +39,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->runCrudTest($runner, 'it_generates_basic_crud.php');
}),
@@ -59,7 +59,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodAdminController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->runCrudTest($runner, 'it_generates_crud_with_custom_controller.php');
}),
@@ -80,7 +80,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->assertStringContainsString('tests/Controller/SweetFoodControllerTest.php', $output);
$this->runCrudTest($runner, 'it_generates_basic_crud.php');
@@ -107,7 +107,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->assertStringContainsString('tests/Controller/SweetFoodControllerTest.php', $output);
$this->runCrudTest($runner, 'it_generates_basic_crud.php');
@@ -145,7 +145,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->runCrudTest($runner, 'it_generates_crud_with_custom_root_namespace.php');
}),
@@ -169,7 +169,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->runCrudTest($runner, 'it_generates_basic_crud.php');
self::assertFileEquals(
@@ -195,7 +195,7 @@ class MakeCrudTest extends MakerTestCase
]);
$this->assertStringContainsString('src/Controller/SweetFoodController.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodForm.php', $output);
$this->assertStringContainsString('src/Form/SweetFoodType.php', $output);
$this->runCrudTest($runner, 'it_generates_basic_crud.php');
}),

View File

@@ -50,7 +50,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'SourFoodForm',
'SourFoodType',
'SourFood',
]);
@@ -67,7 +67,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'TaskForm',
'TaskType',
'\\App\\Form\\Data\\TaskData',
]);
@@ -89,7 +89,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'SourFoodForm',
'SourFoodType',
'SourFood',
]);
@@ -111,7 +111,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'BookForm',
'BookType',
'Book',
]);
@@ -132,7 +132,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'AuthorForm',
'AuthorType',
'Author',
]);
@@ -153,7 +153,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'BookForm',
'BookType',
'Book',
]);
@@ -174,7 +174,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'LibraryForm',
'LibraryType',
'Library',
]);
@@ -195,7 +195,7 @@ class MakeFormTest extends MakerTestCase
$runner->runMaker([
// Entity name
'FoodForm',
'FoodType',
'Food',
]);

View File

@@ -44,8 +44,8 @@ class MakeResetPasswordTest extends MakerTestCase
$generatedFiles = [
'src/Controller/ResetPasswordController.php',
'src/Entity/ResetPasswordRequest.php',
'src/Form/ChangePasswordForm.php',
'src/Form/ResetPasswordRequestForm.php',
'src/Form/ChangePasswordFormType.php',
'src/Form/ResetPasswordRequestFormType.php',
'src/Repository/ResetPasswordRequestRepository.php',
'templates/reset_password/check_email.html.twig',
'templates/reset_password/email.html.twig',
@@ -148,8 +148,8 @@ class MakeResetPasswordTest extends MakerTestCase
$generatedFiles = [
'src/Controller/ResetPasswordController.php',
'src/Entity/ResetPasswordRequest.php',
'src/Form/ChangePasswordForm.php',
'src/Form/ResetPasswordRequestForm.php',
'src/Form/ChangePasswordFormType.php',
'src/Form/ResetPasswordRequestFormType.php',
'src/Repository/ResetPasswordRequestRepository.php',
'templates/reset_password/check_email.html.twig',
'templates/reset_password/email.html.twig',
@@ -208,8 +208,8 @@ class MakeResetPasswordTest extends MakerTestCase
$generatedFiles = [
'src/Controller/ResetPasswordController.php',
'src/Entity/ResetPasswordRequest.php',
'src/Form/ChangePasswordForm.php',
'src/Form/ResetPasswordRequestForm.php',
'src/Form/ChangePasswordFormType.php',
'src/Form/ResetPasswordRequestFormType.php',
'src/Repository/ResetPasswordRequestRepository.php',
'templates/reset_password/check_email.html.twig',
'templates/reset_password/email.html.twig',
@@ -361,7 +361,7 @@ class MakeResetPasswordTest extends MakerTestCase
$this->assertStringContainsString('ORM\ManyToOne', $contentResetPasswordRequest);
// check ResetPasswordRequestFormType
$contentResetPasswordRequestFormType = file_get_contents($runner->getPath('/src/Form/ResetPasswordRequestForm.php'));
$contentResetPasswordRequestFormType = file_get_contents($runner->getPath('/src/Form/ResetPasswordRequestFormType.php'));
$this->assertStringContainsString('->add(\'emailAddress\', EmailType::class, [', $contentResetPasswordRequestFormType);
// check request.html.twig
$contentRequestHtml = file_get_contents($runner->getPath('templates/reset_password/request.html.twig'));

View File

@@ -3,7 +3,7 @@
namespace App\Controller;
use App\Entity\SweetFood;
use App\Form\SweetFoodForm;
use App\Form\SweetFoodType;
use App\Repository\SweetFoodRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -26,7 +26,7 @@ final class SweetFoodController extends AbstractController
public function new(Request $request, EntityManagerInterface $entityManager): Response
{
$sweetFood = new SweetFood();
$form = $this->createForm(SweetFoodForm::class, $sweetFood);
$form = $this->createForm(SweetFoodType::class, $sweetFood);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
@@ -53,7 +53,7 @@ final class SweetFoodController extends AbstractController
#[Route('/{id}/edit', name: 'app_sweet_food_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, SweetFood $sweetFood, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(SweetFoodForm::class, $sweetFood);
$form = $this->createForm(SweetFoodType::class, $sweetFood);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {

View File

@@ -22,7 +22,7 @@ class GeneratedCrudControllerTest extends WebTestCase
$this->assertStringContainsString('New SweetFood', $client->getResponse()->getContent());
$newForm = $crawler->selectButton('Save')->form();
$client->submit($newForm, ['sweet_food_form[title]' => 'Candy']);
$client->submit($newForm, ['sweet_food[title]' => 'Candy']);
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();
@@ -38,7 +38,7 @@ class GeneratedCrudControllerTest extends WebTestCase
$this->assertGreaterThan(0, $crawler->filter('input[type=text]')->count());
$editForm = $crawler->selectButton('Update')->form();
$client->submit($editForm, ['sweet_food_form[title]' => 'Candy edited']);
$client->submit($editForm, ['sweet_food[title]' => 'Candy edited']);
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();

View File

@@ -22,7 +22,7 @@ class GeneratedCrudControllerTest extends WebTestCase
$this->assertStringContainsString('New SweetFood', $client->getResponse()->getContent());
$newForm = $crawler->selectButton('Save')->form();
$client->submit($newForm, ['sweet_food_form[title]' => 'Candy']);
$client->submit($newForm, ['sweet_food[title]' => 'Candy']);
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();
@@ -38,7 +38,7 @@ class GeneratedCrudControllerTest extends WebTestCase
$this->assertGreaterThan(0, $crawler->filter('input[type=text]')->count());
$editForm = $crawler->selectButton('Update')->form();
$client->submit($editForm, ['sweet_food_form[title]' => 'Candy edited']);
$client->submit($editForm, ['sweet_food[title]' => 'Candy edited']);
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();

View File

@@ -22,7 +22,7 @@ class GeneratedCrudControllerTest extends WebTestCase
$this->assertStringContainsString('New SweetFood', $client->getResponse()->getContent());
$newForm = $crawler->selectButton('Save')->form();
$client->submit($newForm, ['sweet_food_form[title]' => 'Candy']);
$client->submit($newForm, ['sweet_food[title]' => 'Candy']);
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();
@@ -38,7 +38,7 @@ class GeneratedCrudControllerTest extends WebTestCase
$this->assertGreaterThan(0, $crawler->filter('input[type=text]')->count());
$editForm = $crawler->selectButton('Update')->form();
$client->submit($editForm, ['sweet_food_form[title]' => 'Candy edited']);
$client->submit($editForm, ['sweet_food[title]' => 'Candy edited']);
$this->assertTrue($client->getResponse()->isRedirect());
$crawler = $client->followRedirect();

View File

@@ -2,7 +2,7 @@
namespace App\Tests;
use App\Form\FooBarForm;
use App\Form\FooBarType;
use Symfony\Component\Form\Test\TypeTestCase;
class GeneratedFormTest extends TypeTestCase
@@ -13,7 +13,7 @@ class GeneratedFormTest extends TypeTestCase
'field_name' => 'field_value',
];
$form = $this->factory->create(FooBarForm::class);
$form = $this->factory->create(FooBarType::class);
$form->submit($formData);
$this->assertTrue($form->isSynchronized());

View File

@@ -3,7 +3,7 @@
namespace App\Tests;
use App\Entity\Food;
use App\Form\FoodForm;
use App\Form\FoodType;
use Symfony\Component\Form\Test\TypeTestCase;
class GeneratedFormTest extends TypeTestCase
@@ -14,7 +14,7 @@ class GeneratedFormTest extends TypeTestCase
'title' => 'lemon',
];
$form = $this->factory->create(FoodForm::class);
$form = $this->factory->create(FoodType::class);
$form->submit($formData);
$object = new Food();

View File

@@ -3,7 +3,7 @@
namespace App\Tests;
use App\Entity\SourFood;
use App\Form\SourFoodForm;
use App\Form\SourFoodType;
use Symfony\Component\Form\Test\TypeTestCase;
class GeneratedFormTest extends TypeTestCase
@@ -14,7 +14,7 @@ class GeneratedFormTest extends TypeTestCase
'title' => 'lemon',
];
$form = $this->factory->create(SourFoodForm::class);
$form = $this->factory->create(SourFoodType::class);
$form->submit($formData);
$object = new SourFood();

View File

@@ -4,7 +4,7 @@ namespace App\Tests;
use App\Entity\Library;
use App\Entity\Book;
use App\Form\BookForm;
use App\Form\BookType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
@@ -23,7 +23,7 @@ class GeneratedFormTest extends TypeTestCase
*/
public function testGeneratedFormWithMultipleChoices($formData, $collection)
{
$form = $this->factory->create(BookForm::class);
$form = $this->factory->create(BookType::class);
$form->submit($formData);
$object = new Book();

View File

@@ -4,7 +4,7 @@ namespace App\Tests;
use App\Entity\Author;
use App\Entity\Book;
use App\Form\BookForm;
use App\Form\BookType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -26,7 +26,7 @@ class GeneratedFormTest extends TypeTestCase
'author' => 0,
];
$form = $this->factory->create(BookForm::class);
$form = $this->factory->create(BookType::class);
$form->submit($formData);
$object = new Book();

View File

@@ -12,7 +12,7 @@
namespace App\Tests;
use App\Form\Data\TaskData;
use App\Form\TaskForm;
use App\Form\TaskType;
use Symfony\Component\Form\Test\TypeTestCase;
class GeneratedFormTest extends TypeTestCase
@@ -28,7 +28,7 @@ class GeneratedFormTest extends TypeTestCase
$objectToCompare = new TaskData();
$form = $this->factory->create(TaskForm::class, $objectToCompare);
$form = $this->factory->create(TaskType::class, $objectToCompare);
$form->submit($formData);
$object = new TaskData();

View File

@@ -4,7 +4,7 @@ namespace App\Tests;
use App\Entity\Author;
use App\Entity\Book;
use App\Form\AuthorForm;
use App\Form\AuthorType;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\Test\TypeTestCase;
@@ -16,7 +16,7 @@ class GeneratedFormTest extends TypeTestCase
'name' => 'foo',
];
$form = $this->factory->create(AuthorForm::class);
$form = $this->factory->create(AuthorType::class);
$form->submit($formData);
$object = new Author();

View File

@@ -4,7 +4,7 @@ namespace App\Tests;
use App\Entity\Librarian;
use App\Entity\Library;
use App\Form\LibraryForm;
use App\Form\LibraryType;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\ClassMetadata;
@@ -26,7 +26,7 @@ class GeneratedFormTest extends TypeTestCase
'librarian' => 0,
];
$form = $this->factory->create(LibraryForm::class);
$form = $this->factory->create(LibraryType::class);
$form->submit($formData);
$object = new Library();

View File

@@ -3,7 +3,7 @@
namespace App\Tests;
use App\Entity\SourFood;
use App\Form\SourFoodForm;
use App\Form\SourFoodType;
use Symfony\Component\Form\Test\TypeTestCase;
class GeneratedFormTest extends TypeTestCase
@@ -14,7 +14,7 @@ class GeneratedFormTest extends TypeTestCase
'title' => 'lemon',
];
$form = $this->factory->create(SourFoodForm::class);
$form = $this->factory->create(SourFoodType::class);
$form->submit($formData);
$object = new SourFood();

View File

@@ -3,7 +3,7 @@
namespace App\Controller;
use App\Entity\User;
use App\Form\RegistrationForm;
use App\Form\RegistrationFormType;
use App\Security\StubAuthenticator;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -19,7 +19,7 @@ class RegistrationController extends AbstractController
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security, EntityManagerInterface $entityManager): Response
{
$user = new User();
$form = $this->createForm(RegistrationForm::class, $user);
$form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {

View File

@@ -3,7 +3,7 @@
namespace App\Controller;
use App\Entity\User;
use App\Form\RegistrationForm;
use App\Form\RegistrationFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
@@ -18,7 +18,7 @@ class RegistrationController extends AbstractController
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, Security $security, EntityManagerInterface $entityManager): Response
{
$user = new User();
$form = $this->createForm(RegistrationForm::class, $user);
$form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {

View File

@@ -3,7 +3,7 @@
namespace App\Controller;
use App\Entity\User;
use App\Form\RegistrationForm;
use App\Form\RegistrationFormType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -17,7 +17,7 @@ class RegistrationController extends AbstractController
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response
{
$user = new User();
$form = $this->createForm(RegistrationForm::class, $user);
$form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {