From fe08ebe765d12652013e0681ddd9062f2fda0109 Mon Sep 17 00:00:00 2001 From: Luiz Marin <67489841+luizcmarin@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:14:21 -0300 Subject: [PATCH 1/6] translation into brazilian portuguese --- docs/guide/en/README.md | 2 +- docs/guide/en/hydrator-attributes.md | 20 +-- docs/guide/en/parameters-resolvers.md | 14 +- docs/guide/en/request-input.md | 8 +- docs/guide/pt-BR/README.md | 5 + docs/guide/pt-BR/hydrator-attributes.md | 149 ++++++++++++++++ docs/guide/pt-BR/parameters-resolvers.md | 174 +++++++++++++++++++ docs/guide/pt-BR/request-input.md | 90 ++++++++++ tests/RequestInputParametersResolverTest.php | 2 +- 9 files changed, 441 insertions(+), 23 deletions(-) create mode 100644 docs/guide/pt-BR/README.md create mode 100644 docs/guide/pt-BR/hydrator-attributes.md create mode 100644 docs/guide/pt-BR/parameters-resolvers.md create mode 100644 docs/guide/pt-BR/request-input.md diff --git a/docs/guide/en/README.md b/docs/guide/en/README.md index 27ef144..c4ed84f 100644 --- a/docs/guide/en/README.md +++ b/docs/guide/en/README.md @@ -2,4 +2,4 @@ - [Hydrator attributes](hydrator-attributes.md) - [Request input](request-input.md) -- [Parameters' resolvers](parameters-resolvers.md) +- [parameters resolvers](parameters-resolvers.md) diff --git a/docs/guide/en/hydrator-attributes.md b/docs/guide/en/hydrator-attributes.md index a999145..095e876 100644 --- a/docs/guide/en/hydrator-attributes.md +++ b/docs/guide/en/hydrator-attributes.md @@ -4,12 +4,12 @@ This package provides some additional attributes for [hydrator](https://github.c ## Parameter attributes -These attributes are used for a single DTO parameter: +These attributes are used for a single DTO parameter: - `#[Query]` - maps with request's query parameter. - `#[Body]` - maps with request's body parameter. - `#[Request]` - maps with request's attribute. This is useful when middleware prior writes the value. -- `#[UploadedFiles]` - maps with request's uploaded files. +- `#[UploadedFiles]` - maps with request's uploaded files. The usage of all available parameters is shown below in the single example: @@ -112,13 +112,13 @@ final class CreateUserInput } ``` -`SearchInput` will be mapped from query parameters, while `CreateUserInput` will be mapped from parsed request body. +`SearchInput` will be mapped from query parameters, while `CreateUserInput` will be mapped from parsed request body. -### Customization +### Customizing parameter names -Similar to parameter attributes, the names of request's parameters can be customized. Here it's done via a map where -keys are DTO properties' names and values according to request's parameter names, which are expected. Besides that, you -can narrow down the scope where exactly to parse the request parameters from. Also, it's possible to throw the exception +Similar to parameter attributes, the names of request's parameters can be customized. Here it's done via a map where +keys are DTO properties' names and values according to request's parameter names, which are expected. Besides that, you +can narrow down the scope where exactly to parse the request parameters from. Also, it's possible to throw an exception when there are some parameters present in the selected request's scope that were not specified in the map. ```php @@ -143,7 +143,7 @@ final class SearchInput In the above example: - The query string expected in the format such as - `?search[q]=input&search[c]=package`. `input` value is mapped to -`$query` property, while `package` value - to `$category` property. -- If the query string contains extra parameters within the selected scope, the exception will be thrown - -`?search[q]=input&search[c]=package&search[s]=desc`. Extra parameters outside the scope are allowed though - +`$query` property, while `package` value - to `$category` property. +- If the query string contains extra parameters within the selected scope, the exception will be thrown - +`?search[q]=input&search[c]=package&search[s]=desc`. Extra parameters outside the scope are allowed though - `?search[q]=input&search[c]=package&user=john`. diff --git a/docs/guide/en/parameters-resolvers.md b/docs/guide/en/parameters-resolvers.md index 4d5b8db..a868342 100644 --- a/docs/guide/en/parameters-resolvers.md +++ b/docs/guide/en/parameters-resolvers.md @@ -1,7 +1,7 @@ -# Parameters' resolvers +# parameters resolvers This package offers multiple -[custom implementations of parameters' resolver](https://github.com/yiisoft/middleware-dispatcher?tab=readme-ov-file#creating-your-own-implementation-of-parameters-resolver) +[custom implementations of parameters resolver](https://github.com/yiisoft/middleware-dispatcher?tab=readme-ov-file#creating-your-own-implementation-of-parameters-resolver) from [Yii Middleware Dispatcher](https://github.com/yiisoft/middleware-dispatcher) package: - [`HydratorAttributeParametersResolver`](#hydratorattributeparametersresolver) @@ -57,7 +57,7 @@ final class PostController ### Adding to middleware dispatcher -An example of applying parameters' resolver to middleware dispatcher: +An example of applying parameters resolver to middleware dispatcher: ```php use Psr\Container\ContainerInterface; @@ -85,11 +85,11 @@ $resolver = new HydratorAttributeParametersResolver( $dispatcher = new MiddlewareDispatcher(new MiddlewareFactory($container, $resolver), $eventDispatcher); ``` -More info about dependencies from [Yii Hydrator](https://github.com/yiisoft/hydrator) package can be found in its docs +More info about dependencies from [Yii Hydrator](https://github.com/yiisoft/hydrator) package can be found in its docs and guide: - + - [attribute resolver factory](https://github.com/yiisoft/hydrator/blob/master/docs/guide/en/attribute-resolver-factory.md) -- [type casting](https://github.com/yiisoft/hydrator/blob/master/docs/guide/en/typecasting.md) +- [type casting](https://github.com/yiisoft/hydrator/blob/master/docs/guide/en/typecasting.md) - [hydrator](https://github.com/yiisoft/hydrator) Using within a group of resolvers: @@ -153,7 +153,7 @@ final class UpdatePostController The used DTO is [request input](request-input.md) with [hydrator attribute](hydrator-attributes.md) applied. -> As an alternative, [Yii Validating Hydrator](https://github.com/yiisoft/hydrator-validator) can be used instead for +> As an alternative, [Yii Validating Hydrator](https://github.com/yiisoft/hydrator-validator) can be used instead for > automatic validation of request input DTO. ### Adding to middleware dispatcher diff --git a/docs/guide/en/request-input.md b/docs/guide/en/request-input.md index f16f092..043480f 100644 --- a/docs/guide/en/request-input.md +++ b/docs/guide/en/request-input.md @@ -36,13 +36,13 @@ final class UpdatePostInput implements RequestInputInterface For more available options, see [Hydrator attributes](hydrator-attributes.md) section. -The main concept of request input is to ease automatic filling with according +The main concept of request input is to ease automatic filling with according [resolver](parameters-resolvers.md#requestinputparametersresolver). It's possible to use hydrator directly too, though. ## Combining with validation -If you need validation features additionally, extend the DTO from `AbstractInput` class which also implements +If you need validation features additionally, extend the DTO from `AbstractInput` class which also implements `ValidatedInputInterface`. This way you can use validation attributes for properties: ```php @@ -86,5 +86,5 @@ $isValid = $result->isValid(); $errorMessagesMap = $result->getErrorMessagesIndexedByPath(); ``` -More thorough guide for working with the validation result is available in the -[validator guide](https://github.com/yiisoft/validator/blob/1.x/docs/guide/en/result.md). +More thorough guide for working with the validation result is available in the +[validator guide](https://github.com/yiisoft/validator/blob/1.x/docs/guide/en/result.md). diff --git a/docs/guide/pt-BR/README.md b/docs/guide/pt-BR/README.md new file mode 100644 index 0000000..c4ed84f --- /dev/null +++ b/docs/guide/pt-BR/README.md @@ -0,0 +1,5 @@ +# Yii Input HTTP + +- [Hydrator attributes](hydrator-attributes.md) +- [Request input](request-input.md) +- [parameters resolvers](parameters-resolvers.md) diff --git a/docs/guide/pt-BR/hydrator-attributes.md b/docs/guide/pt-BR/hydrator-attributes.md new file mode 100644 index 0000000..9ebcc3c --- /dev/null +++ b/docs/guide/pt-BR/hydrator-attributes.md @@ -0,0 +1,149 @@ +# Atributos do Hydrator + +Este pacote fornece alguns atributos adicionais para [hydrator](https://github.com/yiisoft/hydrator). + +## Atributos de parâmetro + +Esses atributos são usados para um único parâmetro DTO: + +- `#[Query]` - mapeia com o parâmetro de consulta da solicitação. +- `#[Body]` - mapeia com o parâmetro body da solicitação. +- `#[Request]` - mapeia com o atributo da solicitação. Isso é útil quando o middleware grava o valor antes. +- `#[UploadedFiles]` - mapeia com os arquivos carregados da solicitação. + +O uso de todos os parâmetros disponíveis é mostrado abaixo no exemplo: + +```php +use Yiisoft\Input\Http\Attribute\Parameter\Body; +use Yiisoft\Input\Http\Attribute\Parameter\Query; +use Yiisoft\Input\Http\Attribute\Parameter\Request;use \Yiisoft\Input\Http\Attribute\Parameter\UploadedFiles; + +final class UpdatePostInput +{ + public function __construct( + #[Query] + private string $id, + #[Body] + private string $title, + #[Body] + private string $content, + #[UploadedFiles] + private $uploads, + #[Request] + private string $clientInfo = ''; + ) { + } + + // getters +} +``` + +Aqui: + +- O ID do post será mapeado a partir do parâmetro de consulta da solicitação; +- Título e conteúdo serão mapeados a partir do corpo da solicitação; +- Os uploads serão mapeados a partir dos arquivos carregados da solicitação; +- As informações do cliente serão mapeadas a partir do atributo da solicitação. + +### Personalização + +Por padrão, espera-se que os parâmetros de solicitação tenham o mesmo nome das propriedades DTO. Para mudar isso, passe o nome +ao anexar o atributo: + +```php +use Yiisoft\Input\Http\Attribute\Parameter\Body; +use Yiisoft\Input\Http\Attribute\Parameter\Query; +use Yiisoft\Input\Http\Attribute\Parameter\Request; +use Yiisoft\Input\Http\Attribute\Parameter\UploadedFiles; + +final class UpdatePostInput +{ + public function __construct( + #[Query('post_id')] + private string $id, + #[Body('post_title')] + private string $title, + #[Body('post_content')] + private string $content, + #[UploadedFiles('post_uploads')] + private $uploads, + #[Request('clientData')] + private string $clientInfo = ''; + ) { + } +} +``` + +## Atributos de dados + +Eles são mais organizados quando a fonte dos valores é comum: + +- `#[FromQuery]` - mapeia com parâmetros de consulta da solicitação. +- `#[FromBody]` - mapeia com os parâmetros do corpo da solicitação. + +A diferença aqui é que esses atributos estão vinculados à classe como um todo, e não a um atributo individual: + +```php +use Yiisoft\Input\Http\Attribute\Data\FromBody; +use Yiisoft\Input\Http\Attribute\Data\FromQuery; + +#[FromQuery] +final class SearchInput +{ + public function __construct( + private string $query, + private string $category, + ) { + } + + // getters +} + +#[FromBody] +final class CreateUserInput +{ + public function __construct( + private string $username, + private string $email, + ) { + } + + // getters +} +``` + +`SearchInput` será mapeado a partir dos parâmetros de consulta, enquanto `CreateUserInput` será mapeado a partir do corpo da solicitação analisado. + +### Personalização dos nomes dos parâmetros + +Semelhante aos atributos de parâmetro, os nomes dos parâmetros da solicitação podem ser customizados. Aqui isso é feito através de um mapa onde as +chaves são nomes e valores de propriedades DTO de acordo com os nomes dos parâmetros da solicitação, que são esperados. Além disso, você +pode restringir o escopo de onde exatamente analisar os parâmetros da solicitação. Além disso, é possível lançar uma exceção +quando existem alguns parâmetros presentes no escopo da solicitação selecionada que não foram especificados no mapa. + +```php +use Yiisoft\Input\Http\Attribute\Data\FromBody; +use Yiisoft\Input\Http\Attribute\Data\FromQuery; + +#[FromQuery( + 'search', // Use an array for bigger level of nesting, for example, `['client', 'search']`. + ['query' => 'q', 'category' => 'c'], + strict: true, +)] +final class SearchInput +{ + public function __construct( + private string $query, + private string $category, + ) { + } +} +``` + +No exemplo acima: + +- A string de consulta esperada no formato como - `?search[q]=input&search[c]=package`. O valor `input` é mapeado para a +propriedade `$query`, enquanto o valor `package` - para a propriedade `$category`. +- Se a string de consulta contiver parâmetros extras dentro do escopo selecionado, a exceção será lançada - +`?search[q]=input&search[c]=pacote&search[s]=desc`. Parâmetros extras fora do escopo são permitidos - +`?search[q]=input&search[c]=pacote&user=john`. diff --git a/docs/guide/pt-BR/parameters-resolvers.md b/docs/guide/pt-BR/parameters-resolvers.md new file mode 100644 index 0000000..07ce379 --- /dev/null +++ b/docs/guide/pt-BR/parameters-resolvers.md @@ -0,0 +1,174 @@ +# Parameters resolvers (Resolvedores de parâmetros) + +Este pacote oferece várias +[implementações personalizadas do resolvedor de parâmetros](https://github.com/yiisoft/middleware-dispatcher?tab=readme-ov-file#creating-your-own-implementation-of-parameters-resolver) +do pacote [Yii Middleware Dispatcher](https://github.com/yiisoft/middleware-dispatcher): + +- [`HydratorAttributeParametersResolver`](#hydratorattributeparametersresolver) +- [`RequestInputParametersResolver`](#requestinputparametersresolver) + +## `HydratorAttributeParametersResolver` + +Permite usar atributos do hydrator no middleware executado pelo despachante do middleware. + +O caso de uso prático é mapear parâmetros de consulta para argumentos da ação do controlador: + +```php +use Psr\Http\Message\ResponseInterface; +use Yiisoft\Input\Http\Attribute\Parameter\Query; + +final class PostController +{ + public function get(#[Query('id')] string $id): ResponseInterface + { + // ... + + /** + * @var string $id + * @var ResponseInterface $response + */ + return $response; + } +} +``` + +É útil se você não precisa do DTO. + +Você pode alterar a dica de tipo do argumento para conversão automática de tipo: + +```php +use Psr\Http\Message\ResponseInterface; +use Yiisoft\Input\Http\Attribute\Parameter\Query; + +final class PostController +{ + public function get(#[Query('id')] int $id): ResponseInterface + { + // ... + + /** + * @var int $id + * @var ResponseInterface $response + */ + return $response; + } +} +``` + +### Adicionando ao middleware dispatcher + +Um exemplo de aplicação do parameters resolver para o middleware dispatcher: + +```php +use Psr\Container\ContainerInterface; +use Psr\EventDispatcher\EventDispatcherInterface; +use Yiisoft\Hydrator\AttributeHandling\ParameterAttributesHandler; +use Yiisoft\Hydrator\AttributeHandling\ResolverFactory\ContainerAttributeResolverFactory; +use Yiisoft\Hydrator\HydratorInterface; +use Yiisoft\Hydrator\TypeCaster\TypeCasterInterface; +use Yiisoft\Input\Http\HydratorAttributeParametersResolver; +use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher; +use Yiisoft\Middleware\Dispatcher\MiddlewareFactory; +use Yiisoft\Middleware\Dispatcher\ParametersResolverInterface; + +/** + * @var ContainerInterface $container + * @var EventDispatcherInterface $eventDispatcher + * @var TypeCasterInterface $typeCaster + * @var HydratorInterface $hydrator + */ +$resolver = new HydratorAttributeParametersResolver( + new ParameterAttributesHandler(new ContainerAttributeResolverFactory($container)), + $typeCaster, // Optional, for customizing type casting + $hydrator, // Optional, for customizing hydration +); +$dispatcher = new MiddlewareDispatcher(new MiddlewareFactory($container, $resolver), $eventDispatcher); +``` + +Mais informações sobre dependências do pacote [Yii Hydrator](https://github.com/yiisoft/hydrator) podem ser encontradas em sua documentação +e + +- [attribute resolver factory](https://github.com/yiisoft/hydrator/blob/master/docs/guide/en/attribute-resolver-factory.md) +- [type casting](https://github.com/yiisoft/hydrator/blob/master/docs/guide/en/typecasting.md) +- [hydrator](https://github.com/yiisoft/hydrator) + +Usando dentro de um grupo de resolvers: + +```php +use Psr\Container\ContainerInterface; +use Psr\EventDispatcher\EventDispatcherInterface; +use Yiisoft\Input\Http\HydratorAttributeParametersResolver; +use Yiisoft\Middleware\Dispatcher\CompositeParametersResolver; +use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher; +use Yiisoft\Middleware\Dispatcher\MiddlewareFactory; +use Yiisoft\Middleware\Dispatcher\ParametersResolverInterface; + +/** + * @var ContainerInterface $container + * @var ParametersResolverInterface $existingResolver1 + * @var ParametersResolverInterface $existingResolver2 + * @var HydratorAttributeParametersResolver $addedResolver + * @var EventDispatcherInterface $eventDispatcher + */ +$dispatcher = new MiddlewareDispatcher( + new MiddlewareFactory( + $container, + new CompositeParametersResolver($existingResolver1, $existingResolver1, $addedResolver), + ), + $eventDispatcher, +); +``` + +## `RequestInputParametersResolver` + +Permite usar classes [request input](request-input.md) como dicas de tipo no middleware executado pelo middleware dispatcher. + +O caso de uso prático é mapear classes de entrada de solicitação para argumentos de ação do controlador: + +```php +use Psr\Http\Message\ResponseInterface; +use Yiisoft\Input\Http\AbstractInput; +use Yiisoft\Input\Http\Attribute\Data\FromBody; + +#[FromBody] +final class UpdatePostInput extends AbstractInput +{ + public int $id; + public string $title; + public string $description = ''; + public string $content; +} + +final class UpdatePostController +{ + public function update(UpdatePostInput $post): ResponseInterface + { + // ... + + /** @var ResponseInterface $response */ + return $response; + } +} +``` + +O DTO usado é [request input](request-input.md) com [atributo do hydrator](hydrator-attributes.md) aplicado. + +> Como alternativa, [Yii Validating Hydrator](https://github.com/yiisoft/hydrator-validator) pode ser usado em vez disso para +> validação automática de solicitação de entrada DTO. + +### Adicionando ao middleware dispatcher + +O processo é muito semelhante a [adicionar `HydratorAttributeParametersResolver`](#adicionando-ao-middleware-dispatcher); espere a +inicialização do resolver (dependências): + +```php +use Yiisoft\Hydrator\HydratorInterface; +use Yiisoft\Input\Http\RequestInputParametersResolver; + +/** @var HydratorInterface $hydrator */ +$resolver = new RequestInputParametersResolver( + $hydrator, + // This allows throwing the exception when the validation result is not valid. + throwInputValidationException: true, +); +``` diff --git a/docs/guide/pt-BR/request-input.md b/docs/guide/pt-BR/request-input.md new file mode 100644 index 0000000..ee0a57d --- /dev/null +++ b/docs/guide/pt-BR/request-input.md @@ -0,0 +1,90 @@ +# Request input (Solicitar entrada) + +A entrada da solicitação é um DTO que implementa `RequestInputInterface`: + +```php +use Yiisoft\Input\Http\AbstractInput; +use Yiisoft\Input\Http\RequestInputInterface; +use Yiisoft\Validator\Rule\Required; + +final class UpdatePostInput implements RequestInputInterface +{ + public int $id; + public string $title; + public string $description = ''; + public string $content; +} +``` + +Pode ser preparado para ser preenchido automaticamente a partir dos parâmetros da solicitação utilizando atributos: + +```php +use Yiisoft\Input\Http\AbstractInput; +use Yiisoft\Input\Http\Attribute\Data\FromBody; +use Yiisoft\Input\Http\RequestInputInterface; +use Yiisoft\Validator\Rule\Required; + +#[FromBody] +final class UpdatePostInput implements RequestInputInterface +{ + public int $id; + public string $title; + public string $description = ''; + public string $content; +} +``` + +Para obter mais opções disponíveis, consulte a seção [Atributos do hydrator](hydrator-attributes.md). + +O principal conceito de entrada de solicitação é facilitar o preenchimento automático de acordo com o +[resolver](parameters-resolvers.md#requestinputparametersresolver). +No entanto, também é possível usar o hydrator diretamente. + +## Combinando com validação + +Se você precisar de recursos de validação adicionais, estenda o DTO da classe `AbstractInput` que também implementa +`ValidatedInputInterface`. Desta forma você pode usar atributos de validação para propriedades: + +```php +use Yiisoft\Input\Http\Attribute\Data\FromBody + +;use Yiisoft\Validator\Rule\Integer; +use Yiisoft\Validator\Rule\Length; +use Yiisoft\Validator\Rule\Required; +use Yiisoft\Validator\Rule\StringValue; + +#[FromBody] +final class UpdatePostInput extends AbstractInput +{ + public function __construct( + #[Required] + #[Integer(min: 1)] + public int $id; + #[Required] + #[StringValue] + #[Length(max: 100)] + public string $title; + #[Length(max: 255)] + #[StringValue] + public string $description = ''; + #[Required] + #[StringValue] + public string $content; + ) { + } +} +``` + +Assim, ao ser preenchido, o DTO poderá ser validado imediatamente, e você poderá recuperar o resultado da validação: + +```php +use Yiisoft\Hydrator\Validator\ValidatedInputInterface; + +/** @var ValidatedInputInterface $person */ +$result = $person->getValidationResult(); +$isValid = $result->isValid(); +$errorMessagesMap = $result->getErrorMessagesIndexedByPath(); +``` + +Um guia mais completo para trabalhar com o resultado da validação está disponível na +[documentação do validator](https://github.com/yiisoft/validator/blob/1.x/docs/guide/pt-BR/result.md). diff --git a/tests/RequestInputParametersResolverTest.php b/tests/RequestInputParametersResolverTest.php index ecd06c0..6d0547c 100644 --- a/tests/RequestInputParametersResolverTest.php +++ b/tests/RequestInputParametersResolverTest.php @@ -65,7 +65,7 @@ public static function dataParameters(): array ]; } - #[DataProvider('dataParameters')] + #[DataProvider('dataparameters)] public function testParameters(array $expected, Closure $closure): void { $request = $this->createMock(ServerRequestInterface::class); From 2141dec50bae170593200126ff9b8add8a2799d3 Mon Sep 17 00:00:00 2001 From: Luiz Marin <67489841+luizcmarin@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:07:57 -0300 Subject: [PATCH 2/6] Docs folder standardization and other fixes --- docs/internals.md | 8 +++++++- phpunit.xml.dist | 2 +- psalm.xml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/internals.md b/docs/internals.md index 6ef50da..b715d9f 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -25,7 +25,7 @@ The code is statically analyzed with [Psalm](https://psalm.dev/). To run static ./vendor/bin/psalm ``` -## Code style +## Rector Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or use either newest or any specific version of PHP: @@ -38,3 +38,9 @@ use either newest or any specific version of PHP: Use [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker) to detect transitive [Composer](https://getcomposer.org/) dependencies. + +To run the checker, execute the following command: + +```shell +./vendor/bin/composer-require-checker +``` diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6f2acf3..aa049cd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - From 08283b335254350eaa69ac7f48e39ef9fe95f8b1 Mon Sep 17 00:00:00 2001 From: Luiz Marin <67489841+luizcmarin@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:13:36 -0300 Subject: [PATCH 3/6] Update conflicts --- docs/guide/en/README.md | 2 +- docs/guide/en/parameters-resolvers.md | 6 +++--- docs/guide/pt-BR/README.md | 2 +- docs/guide/pt-BR/parameters-resolvers.md | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/guide/en/README.md b/docs/guide/en/README.md index c4ed84f..27ef144 100644 --- a/docs/guide/en/README.md +++ b/docs/guide/en/README.md @@ -2,4 +2,4 @@ - [Hydrator attributes](hydrator-attributes.md) - [Request input](request-input.md) -- [parameters resolvers](parameters-resolvers.md) +- [Parameters' resolvers](parameters-resolvers.md) diff --git a/docs/guide/en/parameters-resolvers.md b/docs/guide/en/parameters-resolvers.md index a868342..cd3be9b 100644 --- a/docs/guide/en/parameters-resolvers.md +++ b/docs/guide/en/parameters-resolvers.md @@ -1,7 +1,7 @@ -# parameters resolvers +# Parameters' resolvers This package offers multiple -[custom implementations of parameters resolver](https://github.com/yiisoft/middleware-dispatcher?tab=readme-ov-file#creating-your-own-implementation-of-parameters-resolver) +[custom implementations of parameters' resolver](https://github.com/yiisoft/middleware-dispatcher?tab=readme-ov-file#creating-your-own-implementation-of-parameters-resolver) from [Yii Middleware Dispatcher](https://github.com/yiisoft/middleware-dispatcher) package: - [`HydratorAttributeParametersResolver`](#hydratorattributeparametersresolver) @@ -57,7 +57,7 @@ final class PostController ### Adding to middleware dispatcher -An example of applying parameters resolver to middleware dispatcher: +An example of applying parameters' resolver to middleware dispatcher: ```php use Psr\Container\ContainerInterface; diff --git a/docs/guide/pt-BR/README.md b/docs/guide/pt-BR/README.md index c4ed84f..27ef144 100644 --- a/docs/guide/pt-BR/README.md +++ b/docs/guide/pt-BR/README.md @@ -2,4 +2,4 @@ - [Hydrator attributes](hydrator-attributes.md) - [Request input](request-input.md) -- [parameters resolvers](parameters-resolvers.md) +- [Parameters' resolvers](parameters-resolvers.md) diff --git a/docs/guide/pt-BR/parameters-resolvers.md b/docs/guide/pt-BR/parameters-resolvers.md index 07ce379..74ebe14 100644 --- a/docs/guide/pt-BR/parameters-resolvers.md +++ b/docs/guide/pt-BR/parameters-resolvers.md @@ -1,4 +1,4 @@ -# Parameters resolvers (Resolvedores de parâmetros) +# Parameters' resolvers (Resolvedores de parâmetros) Este pacote oferece várias [implementações personalizadas do resolvedor de parâmetros](https://github.com/yiisoft/middleware-dispatcher?tab=readme-ov-file#creating-your-own-implementation-of-parameters-resolver) @@ -57,7 +57,7 @@ final class PostController ### Adicionando ao middleware dispatcher -Um exemplo de aplicação do parameters resolver para o middleware dispatcher: +Um exemplo de aplicação do parameters' resolver para o middleware dispatcher: ```php use Psr\Container\ContainerInterface; From 7158bf15f67ab4110b902a1a7a0d70fbf5f29c3c Mon Sep 17 00:00:00 2001 From: Luiz Marin <67489841+luizcmarin@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:16:47 -0300 Subject: [PATCH 4/6] update xml files --- phpunit.xml.dist | 2 +- psalm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aa049cd..6f2acf3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - From ead9317552fa2039f74f328130b8883e589d8c5c Mon Sep 17 00:00:00 2001 From: Luiz Marin <67489841+luizcmarin@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:39:16 -0300 Subject: [PATCH 5/6] Docs folder standardization and other fixes --- LICENSE.md | 8 ++++---- README.md | 25 +++++++++++++++++++------ docs/internals.md | 7 +++---- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index bc5674f..6a920d6 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,17 +1,17 @@ -Copyright © 2008 by Yii Software (https://www.yiiframework.com/) +Copyright © 2008 by Yii Software () All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Yii Software nor the names of its +* Neither the name of Yii Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/README.md b/README.md index 3114424..26b1b69 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ The package provides [Yii Hydrator](https://github.com/yiisoft/hydrator) attributes to get data from [PSR-7 HTTP request](https://www.php-fig.org/psr/psr-7/) and adds extra abilities to middlewares processed by [Yii Middleware Dispatcher](https://github.com/yiisoft/middleware-dispatcher): + - maps data from PSR-7 HTTP request to PHP DTO representing user input; - uses Yii Hydrator parameter attributes for resolving middleware parameters. @@ -78,15 +79,20 @@ For other available options, see the [guide](docs/guide/en). ## Documentation -- [Guide](docs/guide/en) -- [Internals](docs/internals.md) +- [English](docs/guide/en/README.md) +- [Portuguese - Brazil](docs/guide/pt-BR/README.md) -## License +Testing: -The Yii Input HTTP is free software. It is released under the terms of the BSD License. -Please see [`LICENSE`](./LICENSE.md) for more information. +- [English](docs/guide/en/testing.md) +- [Portuguese - Brazil](docs/guide/pt-BR/testing.md) -Maintained by [Yii Software](https://www.yiiframework.com/). +- More information can be found in the [Internals.](docs/internals.md) + +## Support + +If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that. +You may also check out other [Yii Community Resources](https://www.yiiframework.com/community). ## Support the project @@ -99,3 +105,10 @@ Maintained by [Yii Software](https://www.yiiframework.com/). [![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat&logo=telegram)](https://t.me/yii3en) [![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat&logo=facebook&logoColor=ffffff)](https://www.facebook.com/groups/yiitalk) [![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat&logo=slack)](https://yiiframework.com/go/slack) + +## License + +The Yii Input HTTP is free software. It is released under the terms of the BSD License. +Please see [`LICENSE`](./LICENSE.md) for more information. + +Maintained by [Yii Software](https://www.yiiframework.com/). diff --git a/docs/internals.md b/docs/internals.md index b715d9f..d10f517 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -25,7 +25,7 @@ The code is statically analyzed with [Psalm](https://psalm.dev/). To run static ./vendor/bin/psalm ``` -## Rector +## Code style Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or use either newest or any specific version of PHP: @@ -34,10 +34,9 @@ use either newest or any specific version of PHP: ./vendor/bin/rector ``` -## Dependencies +## Composer require checker -Use [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker) to detect transitive -[Composer](https://getcomposer.org/) dependencies. +This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`. To run the checker, execute the following command: From 0192d182687d34f9bd0b1e76666dd916149c65f8 Mon Sep 17 00:00:00 2001 From: Luiz Marin <67489841+luizcmarin@users.noreply.github.com> Date: Sun, 21 Apr 2024 06:39:10 -0300 Subject: [PATCH 6/6] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26b1b69..c688b51 100644 --- a/README.md +++ b/README.md @@ -80,14 +80,14 @@ For other available options, see the [guide](docs/guide/en). ## Documentation - [English](docs/guide/en/README.md) -- [Portuguese - Brazil](docs/guide/pt-BR/README.md) +- [Português - Brasil](docs/guide/pt-BR/readme.md) Testing: - [English](docs/guide/en/testing.md) -- [Portuguese - Brazil](docs/guide/pt-BR/testing.md) +- [Português - Brasil:](docs/guide/pt-BR/testing.md) -- More information can be found in the [Internals.](docs/internals.md) +- [Internals](docs/internals.md) ## Support