Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  Don't capitalize acronyms in class names
  • Loading branch information
OskarStark committed May 10, 2024
2 parents 1a2d339 + c36c412 commit 8c17143
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
26 changes: 13 additions & 13 deletions controller.rst
Expand Up @@ -392,7 +392,7 @@ optional validation constraints::

use Symfony\Component\Validator\Constraints as Assert;

class UserDTO
class UserDto
{
public function __construct(
#[Assert\NotBlank]
Expand All @@ -410,14 +410,14 @@ optional validation constraints::
You can then use the :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString`
attribute in your controller::

use App\Model\UserDTO;
use App\Model\UserDto;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;

// ...

public function dashboard(
#[MapQueryString] UserDTO $userDto
#[MapQueryString] UserDto $userDto
): Response
{
// ...
Expand All @@ -434,7 +434,7 @@ HTTP status to return if the validation fails::
#[MapQueryString(
validationGroups: ['strict', 'edit'],
validationFailedStatusCode: Response::HTTP_UNPROCESSABLE_ENTITY
)] UserDTO $userDto
)] UserDto $userDto
): Response
{
// ...
Expand All @@ -445,14 +445,14 @@ The default status code returned if the validation fails is 404.
If you need a valid DTO even when the request query string is empty, set a
default value for your controller arguments::

use App\Model\UserDTO;
use App\Model\UserDto;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;

// ...

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

use App\Model\UserDTO;
use App\Model\UserDto;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;

// ...

public function dashboard(
#[MapRequestPayload] UserDTO $userDto
#[MapRequestPayload] UserDto $userDto
): Response
{
// ...
Expand All @@ -501,7 +501,7 @@ your DTO::
serializationContext: ['...'],
resolver: App\Resolver\UserDtoResolver
)]
UserDTO $userDto
UserDto $userDto
): Response
{
// ...
Expand All @@ -519,7 +519,7 @@ the validation fails as well as supported payload formats::
acceptFormat: 'json',
validationGroups: ['strict', 'read'],
validationFailedStatusCode: Response::HTTP_NOT_FOUND
)] UserDTO $userDto
)] UserDto $userDto
): Response
{
// ...
Expand All @@ -539,16 +539,16 @@ Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
if you want to map a nested array of specific DTOs::

public function dashboard(
#[MapRequestPayload()] EmployeesDTO $employeesDto
#[MapRequestPayload()] EmployeesDto $employeesDto
): Response
{
// ...
}

final class EmployeesDTO
final class EmployeesDto
{
/**
* @param UserDTO[] $users
* @param UserDto[] $users
*/
public function __construct(
public readonly array $users = []
Expand Down
22 changes: 11 additions & 11 deletions form/type_guesser.rst
Expand Up @@ -44,14 +44,14 @@ This interface requires four methods:

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

// src/Form/TypeGuesser/PHPDocTypeGuesser.php
// src/Form/TypeGuesser/PhpDocTypeGuesser.php
namespace App\Form\TypeGuesser;

use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\Guess\TypeGuess;
use Symfony\Component\Form\Guess\ValueGuess;

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

With this knowledge, you can implement the ``guessType()`` method of the
``PHPDocTypeGuesser``::
``PhpDocTypeGuesser``::

// src/Form/TypeGuesser/PHPDocTypeGuesser.php
// src/Form/TypeGuesser/PhpDocTypeGuesser.php
namespace App\Form\TypeGuesser;

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

class PHPDocTypeGuesser implements FormTypeGuesserInterface
class PhpDocTypeGuesser implements FormTypeGuesserInterface
{
public function guessType(string $class, string $property): ?TypeGuess
{
Expand Down Expand Up @@ -188,7 +188,7 @@ and tag it with ``form.type_guesser``:
services:
# ...
App\Form\TypeGuesser\PHPDocTypeGuesser:
App\Form\TypeGuesser\PhpDocTypeGuesser:
tags: [form.type_guesser]
.. code-block:: xml
Expand All @@ -201,7 +201,7 @@ and tag it with ``form.type_guesser``:
https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="App\Form\TypeGuesser\PHPDocTypeGuesser">
<service id="App\Form\TypeGuesser\PhpDocTypeGuesser">
<tag name="form.type_guesser"/>
</service>
</services>
Expand All @@ -210,9 +210,9 @@ and tag it with ``form.type_guesser``:
.. code-block:: php
// config/services.php
use App\Form\TypeGuesser\PHPDocTypeGuesser;
use App\Form\TypeGuesser\PhpDocTypeGuesser;
$container->register(PHPDocTypeGuesser::class)
$container->register(PhpDocTypeGuesser::class)
->addTag('form.type_guesser')
;
Expand All @@ -223,12 +223,12 @@ and tag it with ``form.type_guesser``:
:method:`Symfony\\Component\\Form\\FormFactoryBuilder::addTypeGuessers` of
the ``FormFactoryBuilder`` to register new type guessers::

use App\Form\TypeGuesser\PHPDocTypeGuesser;
use App\Form\TypeGuesser\PhpDocTypeGuesser;
use Symfony\Component\Form\Forms;

$formFactory = Forms::createFormFactoryBuilder()
// ...
->addTypeGuesser(new PHPDocTypeGuesser())
->addTypeGuesser(new PhpDocTypeGuesser())
->getFormFactory();

// ...
Expand Down

0 comments on commit 8c17143

Please sign in to comment.