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
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 @@ -36,6 +36,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.14.3",
"roave/infection-static-analysis-plugin": "^1.20",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.23",
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,
]);
};
20 changes: 1 addition & 19 deletions src/ApplicationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
*/
abstract class ApplicationRunner implements RunnerInterface
{
protected bool $debug;
protected string $rootPath;
protected ?string $environment;
protected ?ConfigInterface $config = null;
protected ?ContainerInterface $container = null;
protected ?string $bootstrapGroup = null;
Expand All @@ -35,11 +32,8 @@ abstract class ApplicationRunner implements RunnerInterface
* @param bool $debug Whether the debug mode is enabled.
* @param string|null $environment The environment name.
*/
public function __construct(string $rootPath, bool $debug, ?string $environment)
public function __construct(protected string $rootPath, protected bool $debug, protected ?string $environment)
{
$this->rootPath = $rootPath;
$this->debug = $debug;
$this->environment = $environment;
}

abstract public function run(): void;
Expand All @@ -48,8 +42,6 @@ abstract public function run(): void;
* Returns a new instance with the specified bootstrap configuration group name.
*
* @param string $bootstrapGroup The bootstrap configuration group name.
*
* @return static
*/
public function withBootstrap(string $bootstrapGroup): static
{
Expand All @@ -60,8 +52,6 @@ public function withBootstrap(string $bootstrapGroup): static

/**
* Returns a new instance with bootstrapping disabled.
*
* @return static
*/
public function withoutBootstrap(): static
{
Expand All @@ -76,8 +66,6 @@ public function withoutBootstrap(): static
* Note: The configuration of events is checked in debug mode only.
*
* @param string $eventsGroup Name of event configuration group to check.
*
* @return static
*/
public function withCheckingEvents(string $eventsGroup): static
{
Expand All @@ -88,8 +76,6 @@ public function withCheckingEvents(string $eventsGroup): static

/**
* Returns a new instance with disabled event configuration check.
*
* @return static
*/
public function withoutCheckingEvents(): static
{
Expand All @@ -102,8 +88,6 @@ public function withoutCheckingEvents(): static
* Returns a new instance with the specified config instance {@see ConfigInterface}.
*
* @param ConfigInterface $config The config instance.
*
* @return static
*/
public function withConfig(ConfigInterface $config): static
{
Expand All @@ -116,8 +100,6 @@ public function withConfig(ConfigInterface $config): static
* Returns a new instance with the specified container instance {@see ContainerInterface}.
*
* @param ContainerInterface $container The container instance.
*
* @return static
*/
public function withContainer(ContainerInterface $container): static
{
Expand Down
7 changes: 1 addition & 6 deletions src/BootstrapRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
*/
final class BootstrapRunner implements RunnerInterface
{
private ContainerInterface $container;
private array $bootstrapList;

public function __construct(ContainerInterface $container, array $bootstrapList = [])
public function __construct(private ContainerInterface $container, private array $bootstrapList = [])
{
$this->container = $container;
$this->bootstrapList = $bootstrapList;
}

/**
Expand Down