Skip to content
Draft
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 @@ -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"
Expand Down
22 changes: 22 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
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,
]);
};
4 changes: 1 addition & 3 deletions src/PgsqlMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions src/PgsqlMutexFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down