Skip to content

Commit f677eb4

Browse files
committed
minor #19875 Don't capitalize acronyms in class names (javiereguiluz)
This PR was merged into the 6.4 branch. Discussion ---------- Don't capitalize acronyms in class names PHP has approved a new policy banning the usage of capitalized acronyms in class names (https://wiki.php.net/rfc/class-naming-acronyms): | Wrong | Correct | ----- | ------- | `FooDTO` | `FooDto` | `HTTPFoo` | `HttpFoo` | `PDOFooPHP` | `PdoFooPhp` So, I propose to use this same policy for Symfony Docs. Note: we need to be careful because some class are defined by external projects and the use the "wrong" names (`ReactPHPRunner`, etc.) Commits ------- 5b8e198 Don't capitalize acronyms in class names
2 parents e7d5408 + 5b8e198 commit f677eb4

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

controller.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ optional validation constraints::
401401

402402
use Symfony\Component\Validator\Constraints as Assert;
403403

404-
class UserDTO
404+
class UserDto
405405
{
406406
public function __construct(
407407
#[Assert\NotBlank]
@@ -419,14 +419,14 @@ optional validation constraints::
419419
You can then use the :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString`
420420
attribute in your controller::
421421

422-
use App\Model\UserDTO;
422+
use App\Model\UserDto;
423423
use Symfony\Component\HttpFoundation\Response;
424424
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
425425

426426
// ...
427427

428428
public function dashboard(
429-
#[MapQueryString] UserDTO $userDto
429+
#[MapQueryString] UserDto $userDto
430430
): Response
431431
{
432432
// ...
@@ -443,7 +443,7 @@ HTTP status to return if the validation fails::
443443
#[MapQueryString(
444444
validationGroups: ['strict', 'edit'],
445445
validationFailedStatusCode: Response::HTTP_UNPROCESSABLE_ENTITY
446-
)] UserDTO $userDto
446+
)] UserDto $userDto
447447
): Response
448448
{
449449
// ...
@@ -454,14 +454,14 @@ The default status code returned if the validation fails is 404.
454454
If you need a valid DTO even when the request query string is empty, set a
455455
default value for your controller arguments::
456456

457-
use App\Model\UserDTO;
457+
use App\Model\UserDto;
458458
use Symfony\Component\HttpFoundation\Response;
459459
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
460460

461461
// ...
462462

463463
public function dashboard(
464-
#[MapQueryString] UserDTO $userDto = new UserDTO()
464+
#[MapQueryString] UserDto $userDto = new UserDto()
465465
): Response
466466
{
467467
// ...
@@ -497,14 +497,14 @@ In this case, it is also possible to directly map this payload to your DTO by
497497
using the :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload`
498498
attribute::
499499

500-
use App\Model\UserDTO;
500+
use App\Model\UserDto;
501501
use Symfony\Component\HttpFoundation\Response;
502502
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
503503

504504
// ...
505505

506506
public function dashboard(
507-
#[MapRequestPayload] UserDTO $userDto
507+
#[MapRequestPayload] UserDto $userDto
508508
): Response
509509
{
510510
// ...
@@ -519,7 +519,7 @@ your DTO::
519519
serializationContext: ['...'],
520520
resolver: App\Resolver\UserDtoResolver
521521
)]
522-
UserDTO $userDto
522+
UserDto $userDto
523523
): Response
524524
{
525525
// ...
@@ -537,7 +537,7 @@ the validation fails as well as supported payload formats::
537537
acceptFormat: 'json',
538538
validationGroups: ['strict', 'read'],
539539
validationFailedStatusCode: Response::HTTP_NOT_FOUND
540-
)] UserDTO $userDto
540+
)] UserDto $userDto
541541
): Response
542542
{
543543
// ...
@@ -557,16 +557,16 @@ Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
557557
if you want to map a nested array of specific DTOs::
558558

559559
public function dashboard(
560-
#[MapRequestPayload()] EmployeesDTO $employeesDto
560+
#[MapRequestPayload()] EmployeesDto $employeesDto
561561
): Response
562562
{
563563
// ...
564564
}
565565

566-
final class EmployeesDTO
566+
final class EmployeesDto
567567
{
568568
/**
569-
* @param UserDTO[] $users
569+
* @param UserDto[] $users
570570
*/
571571
public function __construct(
572572
public readonly array $users = []

form/type_guesser.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ This interface requires four methods:
4444

4545
Start by creating the class and these methods. Next, you'll learn how to fill each in::
4646

47-
// src/Form/TypeGuesser/PHPDocTypeGuesser.php
47+
// src/Form/TypeGuesser/PhpDocTypeGuesser.php
4848
namespace App\Form\TypeGuesser;
4949

5050
use Symfony\Component\Form\FormTypeGuesserInterface;
5151
use Symfony\Component\Form\Guess\TypeGuess;
5252
use Symfony\Component\Form\Guess\ValueGuess;
5353

54-
class PHPDocTypeGuesser implements FormTypeGuesserInterface
54+
class PhpDocTypeGuesser implements FormTypeGuesserInterface
5555
{
5656
public function guessType(string $class, string $property): ?TypeGuess
5757
{
@@ -90,9 +90,9 @@ The ``TypeGuess`` constructor requires three options:
9090
type with the highest confidence is used.
9191

9292
With this knowledge, you can implement the ``guessType()`` method of the
93-
``PHPDocTypeGuesser``::
93+
``PhpDocTypeGuesser``::
9494

95-
// src/Form/TypeGuesser/PHPDocTypeGuesser.php
95+
// src/Form/TypeGuesser/PhpDocTypeGuesser.php
9696
namespace App\Form\TypeGuesser;
9797

9898
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -102,7 +102,7 @@ With this knowledge, you can implement the ``guessType()`` method of the
102102
use Symfony\Component\Form\Guess\Guess;
103103
use Symfony\Component\Form\Guess\TypeGuess;
104104

105-
class PHPDocTypeGuesser implements FormTypeGuesserInterface
105+
class PhpDocTypeGuesser implements FormTypeGuesserInterface
106106
{
107107
public function guessType(string $class, string $property): ?TypeGuess
108108
{
@@ -188,7 +188,7 @@ and tag it with ``form.type_guesser``:
188188
services:
189189
# ...
190190
191-
App\Form\TypeGuesser\PHPDocTypeGuesser:
191+
App\Form\TypeGuesser\PhpDocTypeGuesser:
192192
tags: [form.type_guesser]
193193
194194
.. code-block:: xml
@@ -201,7 +201,7 @@ and tag it with ``form.type_guesser``:
201201
https://symfony.com/schema/dic/services/services-1.0.xsd">
202202
203203
<services>
204-
<service id="App\Form\TypeGuesser\PHPDocTypeGuesser">
204+
<service id="App\Form\TypeGuesser\PhpDocTypeGuesser">
205205
<tag name="form.type_guesser"/>
206206
</service>
207207
</services>
@@ -210,9 +210,9 @@ and tag it with ``form.type_guesser``:
210210
.. code-block:: php
211211
212212
// config/services.php
213-
use App\Form\TypeGuesser\PHPDocTypeGuesser;
213+
use App\Form\TypeGuesser\PhpDocTypeGuesser;
214214
215-
$container->register(PHPDocTypeGuesser::class)
215+
$container->register(PhpDocTypeGuesser::class)
216216
->addTag('form.type_guesser')
217217
;
218218
@@ -223,12 +223,12 @@ and tag it with ``form.type_guesser``:
223223
:method:`Symfony\\Component\\Form\\FormFactoryBuilder::addTypeGuessers` of
224224
the ``FormFactoryBuilder`` to register new type guessers::
225225

226-
use App\Form\TypeGuesser\PHPDocTypeGuesser;
226+
use App\Form\TypeGuesser\PhpDocTypeGuesser;
227227
use Symfony\Component\Form\Forms;
228228

229229
$formFactory = Forms::createFormFactoryBuilder()
230230
// ...
231-
->addTypeGuesser(new PHPDocTypeGuesser())
231+
->addTypeGuesser(new PhpDocTypeGuesser())
232232
->getFormFactory();
233233

234234
// ...

0 commit comments

Comments
 (0)