diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..adacd73 --- /dev/null +++ b/.github/workflows/rector.yml @@ -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'] diff --git a/composer.json b/composer.json index bf410ca..d76f6c1 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ }, "require-dev": { "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" diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..63713ce --- /dev/null +++ b/rector.php @@ -0,0 +1,22 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + + // register a single rule + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + + // define sets of rules + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_80, + ]); +}; diff --git a/src/PgsqlMutex.php b/src/PgsqlMutex.php index c178491..12dc178 100644 --- a/src/PgsqlMutex.php +++ b/src/PgsqlMutex.php @@ -18,17 +18,15 @@ final class PgsqlMutex extends Mutex { private array $lockKeys; - private PDO $connection; /** * @param string $name Mutex name. * @param PDO $connection PDO connection instance to use. */ - public function __construct(string $name, PDO $connection) + public function __construct(string $name, private PDO $connection) { // Converts a string into two 16-bit integer keys using the SHA1 hash function. $this->lockKeys = array_values(unpack('n2', sha1($name, true))); - $this->connection = $connection; /** @var string $driverName */ $driverName = $connection->getAttribute(PDO::ATTR_DRIVER_NAME); diff --git a/src/PgsqlMutexFactory.php b/src/PgsqlMutexFactory.php index ca6b96b..393a69a 100644 --- a/src/PgsqlMutexFactory.php +++ b/src/PgsqlMutexFactory.php @@ -13,14 +13,11 @@ */ final class PgsqlMutexFactory extends MutexFactory { - private PDO $connection; - /** * @param PDO $connection PDO connection instance to use. */ - public function __construct(PDO $connection) + public function __construct(private PDO $connection) { - $this->connection = $connection; } public function create(string $name): MutexInterface