Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/rector-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Rector + PHP CS Fixer

on:
pull_request_target:
paths:
- 'config/**'
- 'src/**'
- 'tests/**'
- '.github/workflows/rector-cs.yml'
- 'composer.json'
- 'rector.php'
- '.php-cs-fixer.dist.php'

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
secrets:
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
php: '8.1'
24 changes: 0 additions & 24 deletions .github/workflows/rector.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ composer.phar
/phpunit.phar
/phpunit.xml
/.phpunit.cache

# PHP CS Fixer
/.php-cs-fixer.cache
/.php-cs-fixer.php
22 changes: 22 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
use Yiisoft\CodeStyle\ConfigBuilder;

$finder = (new Finder())->in([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return ConfigBuilder::build()
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@Yiisoft/Core' => true,
'@Yiisoft/Core:risky' => true,
])
->setFinder($finder);
85 changes: 0 additions & 85 deletions .styleci.yml

This file was deleted.

5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@
"yiisoft/request-provider": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.93",
"maglnet/composer-require-checker": "^4.7.1",
"phpunit/phpunit": "^10.5.45",
"rector/rector": "^2.0.11",
"roave/infection-static-analysis-plugin": "^1.35",
"spatie/phpunit-watcher": "^1.24",
"vimeo/psalm": "^5.26.1 || ^6.10",
"yiisoft/code-style": "^1.0",
"yiisoft/di": "^1.3",
"yiisoft/test-support": "^3.0.2"
},
Expand Down Expand Up @@ -82,6 +84,7 @@
},
"scripts": {
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
"test-watch": "phpunit-watcher watch",
"cs-fix": "php-cs-fixer fix"
}
}
4 changes: 2 additions & 2 deletions config/di-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
RequestInputParametersResolver::class => [
'__construct()' => [
'hydrator' => Reference::to(ValidatingHydrator::class),
'throwInputValidationException' =>
$params['yiisoft/input-http']['requestInputParametersResolver']['throwInputValidationException'],
'throwInputValidationException'
=> $params['yiisoft/input-http']['requestInputParametersResolver']['throwInputValidationException'],
],
],
];
3 changes: 1 addition & 2 deletions src/Attribute/Data/FromBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public function __construct(
private string|array|null $name = null,
private array $map = [],
private bool $strict = false,
) {
}
) {}

/**
* Get the name of the field in the request body to get data from.
Expand Down
3 changes: 1 addition & 2 deletions src/Attribute/Data/FromBodyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ final class FromBodyResolver implements DataAttributeResolverInterface
*/
public function __construct(
private RequestProviderInterface $requestProvider,
) {
}
) {}

public function prepareData(DataAttributeInterface $attribute, DataInterface $data): DataInterface
{
Expand Down
3 changes: 1 addition & 2 deletions src/Attribute/Data/FromQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public function __construct(
private string|array|null $name = null,
private array $map = [],
private bool $strict = false,
) {
}
) {}

/**
* Get the name of the field in the query string to get data from.
Expand Down
3 changes: 1 addition & 2 deletions src/Attribute/Data/FromQueryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ final class FromQueryResolver implements DataAttributeResolverInterface
*/
public function __construct(
private RequestProviderInterface $requestProvider,
) {
}
) {}

public function prepareData(DataAttributeInterface $attribute, DataInterface $data): DataInterface
{
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ final class Body implements ParameterAttributeInterface
* @psalm-param string|list<string>|null $name
*/
public function __construct(
private string|array|null $name = null
) {
}
private string|array|null $name = null,
) {}

/**
* Get the name of the field in the request body to get data from.
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/BodyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
* @param RequestProviderInterface $requestProvider The request provider.
*/
public function __construct(
private RequestProviderInterface $requestProvider
) {
}
private RequestProviderInterface $requestProvider,
) {}

public function getParameterValue(
ParameterAttributeInterface $attribute,
Expand All @@ -44,7 +43,7 @@
}

if (!ArrayHelper::pathExists($parsedBody, $name)) {
return Result::fail();

Check warning on line 46 in src/Attribute/Parameter/BodyResolver.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "ReturnRemoval": @@ @@ } if (!ArrayHelper::pathExists($parsedBody, $name)) { - return Result::fail(); + } return Result::success(ArrayHelper::getValueByPath($parsedBody, $name));
}

return Result::success(ArrayHelper::getValueByPath($parsedBody, $name));
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ final class Query implements ParameterAttributeInterface
* @psalm-param string|list<string>|null $name
*/
public function __construct(
private string|array|null $name = null
) {
}
private string|array|null $name = null,
) {}

/**
* Get the name of the field in the query string to get data from.
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/QueryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ final class QueryResolver implements ParameterAttributeResolverInterface
* @param RequestProviderInterface $requestProvider The request provider.
*/
public function __construct(
private RequestProviderInterface $requestProvider
) {
}
private RequestProviderInterface $requestProvider,
) {}

public function getParameterValue(
ParameterAttributeInterface $attribute,
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ final class Request implements ParameterAttributeInterface
* @psalm-param string|list<string>|null $name
*/
public function __construct(
private string|array|null $name = null
) {
}
private string|array|null $name = null,
) {}

/**
* Get the name of the field in the request attributes to get data from.
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/RequestResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
* @param RequestProviderInterface $requestProvider The request provider.
*/
public function __construct(
private RequestProviderInterface $requestProvider
) {
}
private RequestProviderInterface $requestProvider,
) {}

public function getParameterValue(
ParameterAttributeInterface $attribute,
Expand All @@ -38,7 +37,7 @@
$name = $attribute->getName() ?? $context->getParameter()->getName();

if (!ArrayHelper::pathExists($requestAttributes, $name)) {
return Result::fail();

Check warning on line 40 in src/Attribute/Parameter/RequestResolver.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "ReturnRemoval": @@ @@ $name = $attribute->getName() ?? $context->getParameter()->getName(); if (!ArrayHelper::pathExists($requestAttributes, $name)) { - return Result::fail(); + } return Result::success(ArrayHelper::getValueByPath($requestAttributes, $name));
}

return Result::success(ArrayHelper::getValueByPath($requestAttributes, $name));
Expand Down
5 changes: 2 additions & 3 deletions src/Attribute/Parameter/UploadedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ final class UploadedFiles implements ParameterAttributeInterface
* @psalm-param string|list<string>|null $name
*/
public function __construct(
private string|array|null $name = null
) {
}
private string|array|null $name = null,
) {}

/**
* Get the name of the field in the uploaded files to get data from.
Expand Down
3 changes: 1 addition & 2 deletions src/Attribute/Parameter/UploadedFilesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ final class UploadedFilesResolver implements ParameterAttributeResolverInterface
*/
public function __construct(
private RequestProviderInterface $requestProvider,
) {
}
) {}

public function getParameterValue(
ParameterAttributeInterface $attribute,
Expand Down
2 changes: 1 addition & 1 deletion src/HydratorAttributeParametersResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private function prepareValue(Result $handleResult, ReflectionParameter $paramet

$typeCastResult = $this->typeCaster->cast(
$value,
new TypeCastContext($this->hydrator, $parameter)
new TypeCastContext($this->hydrator, $parameter),
);

return $typeCastResult->isResolved() ? $typeCastResult->getValue() : $value;
Expand Down
4 changes: 1 addition & 3 deletions src/RequestInputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
/**
* `RequestInputInterface` marks a DTO as a request input.
*/
interface RequestInputInterface
{
}
interface RequestInputInterface {}
3 changes: 1 addition & 2 deletions src/RequestInputParametersResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ final class RequestInputParametersResolver implements ParametersResolverInterfac
public function __construct(
private HydratorInterface $hydrator,
private bool $throwInputValidationException = false,
) {
}
) {}

/**
* @param ReflectionParameter[] $parameters The parameters to resolve.
Expand Down
6 changes: 3 additions & 3 deletions tests/Attribute/Parameter/BodyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testBase(): void
'c' => 'three',
]);

$input = new class () {
$input = new class {
#[Body('a')]
public string $a = '';
#[Body('b')]
Expand All @@ -45,7 +45,7 @@ public function testWithoutBody(): void
{
$hydrator = $this->createHydrator(null);

$input = new class () {
$input = new class {
#[Body('a')]
public string $a = '';
#[Body('b')]
Expand All @@ -68,7 +68,7 @@ public function testNonExistPath(): void
'b' => 'two',
]);

$input = new class () {
$input = new class {
#[Body('a.b')]
public string $a = '';
};
Expand Down
Loading
Loading