Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add rector [batch] #32

Merged
merged 9 commits into from
Sep 29, 2022
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
21 changes: 21 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: rector

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.0']
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"require-dev": {
"httpsoft/http-message": "^1.0",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.14.3",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18",
Expand Down
27 changes: 27 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
]);
};
4 changes: 0 additions & 4 deletions src/RoadRunnerApplicationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public function __construct(string $rootPath, bool $debug, ?string $environment)
* then the error handler configured in your application configuration will be used.
*
* @param ErrorHandler $temporaryErrorHandler The temporary error handler instance.
*
* @return self
*/
public function withTemporaryErrorHandler(ErrorHandler $temporaryErrorHandler): self
{
Expand All @@ -67,8 +65,6 @@ public function withTemporaryErrorHandler(ErrorHandler $temporaryErrorHandler):
* Returns a new instance with the specified PSR-7 worker instance {@see PSR7WorkerInterface}.
*
* @param PSR7WorkerInterface $worker The PSR-7 worker instance.
*
* @return self
*/
public function withPsr7Worker(PSR7WorkerInterface $worker): self
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/PlainTextRendererMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function renderVerbose(Throwable $t, ServerRequestInterface $request = nu
'request-method' => (string) $request?->getMethod(),
'request-uri' => (string) $request?->getUri(),
'request-attribute-exists' => (bool) $request?->getAttribute('applicationStartTime'),
]));
], JSON_THROW_ON_ERROR));
}
}
6 changes: 2 additions & 4 deletions tests/Support/Psr7WorkerMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@

final class Psr7WorkerMock implements PSR7WorkerInterface
{
private ServerRequestInterface|Throwable|null $request;
private int $requestCount = 0;

public function __construct(ServerRequestInterface|Throwable $request = null)
public function __construct(private ServerRequestInterface|Throwable|null $request = null)
{
$this->request = $request;
}

public function getRequestCount(): int
Expand All @@ -47,7 +45,7 @@ public function respond(ResponseInterface $response): void
'status' => $response->getStatusCode(),
'headers' => $response->getHeaders(),
'body' => (string) $response->getBody(),
]);
], JSON_THROW_ON_ERROR);
}

public function getWorker(): WorkerInterface
Expand Down
7 changes: 2 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ static function (ContainerInterface $container) use ($throwException) {
->get(MiddlewareDispatcher::class)
->withMiddlewares([
static fn () => new class ($throwException) implements MiddlewareInterface {
private bool $throwException;

public function __construct(bool $throwException)
public function __construct(private bool $throwException)
{
$this->throwException = $throwException;
}

public function process(
Expand Down Expand Up @@ -120,6 +117,6 @@ protected function getResponseData(int $status = Status::OK, array $headers = []
'status' => $status,
'headers' => $headers,
'body' => $body,
]);
], JSON_THROW_ON_ERROR);
}
}