Skip to content

Commit 11ac772

Browse files
committed
added rector
1 parent 7ae5731 commit 11ac772

File tree

8 files changed

+32
-11
lines changed

8 files changed

+32
-11
lines changed

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
"spatie/laravel-package-tools": "^1.13.0"
2323
},
2424
"require-dev": {
25+
"driftingly/rector-laravel": "^0.17.0",
2526
"laravel/pint": "^1.7",
2627
"nunomaduro/collision": "^7.3.3",
2728
"nunomaduro/larastan": "^2.5.1",
2829
"orchestra/testbench": "^8.0.11",
2930
"phpstan/extension-installer": "^1.2",
3031
"phpstan/phpstan-deprecation-rules": "^1.1.3",
3132
"phpstan/phpstan-phpunit": "^1.3.10",
32-
"phpunit/phpunit": "^10.0.18"
33+
"phpunit/phpunit": "^10.0.18",
34+
"rector/rector": "^0.15.23"
3335
},
3436
"autoload": {
3537
"psr-4": {
@@ -52,7 +54,8 @@
5254
"analyse": "vendor/bin/phpstan analyse",
5355
"test": "vendor/bin/phpunit",
5456
"test-coverage": "vendor/bin/phpunit --coverage",
55-
"format": "vendor/bin/pint"
57+
"format": "vendor/bin/pint",
58+
"rector": "vendor/bin/rector process"
5659
},
5760
"config": {
5861
"sort-packages": true,

rector.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
use RectorLaravel\Set\LaravelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__.'/config',
12+
__DIR__.'/src',
13+
__DIR__.'/tests',
14+
]);
15+
16+
$rectorConfig->sets([
17+
LevelSetList::UP_TO_PHP_81,
18+
LaravelSetList::LARAVEL_100,
19+
]);
20+
};

src/Client/ElasticaClient.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public function disableEventListener(): void
4343

4444
public function listensToEvents(): bool
4545
{
46-
return self::$listenToEvents !== null
47-
? self::$listenToEvents
48-
: config('elastica-bridge.events.listen', true);
46+
return self::$listenToEvents ?? config('elastica-bridge.events.listen', true);
4947
}
5048
}

src/Commands/StatusCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function handle(): int
5757
if ($hasBlueGreen) {
5858
try {
5959
$activeBlueGreen = $indexConfig->getBlueGreenActiveElasticaIndex()->getName();
60-
} catch (BlueGreenIndicesIncorrectlySetupException $exception) {
60+
} catch (BlueGreenIndicesIncorrectlySetupException) {
6161
$hasBlueGreen = false;
6262
}
6363
}

src/Events/EventHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
class EventHandler
1111
{
1212
public function __construct(
13-
private ElasticaClient $elasticaClient,
14-
private ModelEventListener $modelEventListener
13+
private readonly ElasticaClient $elasticaClient,
14+
private readonly ModelEventListener $modelEventListener
1515
) {
1616
}
1717

src/Index/AbstractIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ final public function getBlueGreenInactiveElasticaIndex(): Index
172172

173173
final public function indexingLock(): Lock
174174
{
175-
return Cache::lock(__CLASS__.$this->getName());
175+
return Cache::lock(self::class.$this->getName());
176176
}
177177

178178
public function ingoreIndexingErrors(): bool

src/Jobs/SetupIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private function setup(ElasticaClient $elastica): void
8383
{
8484
try {
8585
$this->indexConfig->getBlueGreenActiveSuffix();
86-
} catch (BlueGreenIndicesIncorrectlySetupException $exception) {
86+
} catch (BlueGreenIndicesIncorrectlySetupException) {
8787
$elastica->getIndex($this->indexConfig->getName().IndexInterface::INDEX_SUFFIX_BLUE)->addAlias($this->indexConfig->getName());
8888
}
8989
}

src/Services/ModelEventListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ModelEventListener
2222

2323
private const EVENT_DELETED = 'deleted';
2424

25-
public const EVENTS = [
25+
final public const EVENTS = [
2626
self::EVENT_CREATED,
2727
self::EVENT_UPDATED,
2828
self::EVENT_SAVED,

0 commit comments

Comments
 (0)