Skip to content

Commit

Permalink
rector: add ClassPropertyAssignToConstructorPromotionRector
Browse files Browse the repository at this point in the history
This rule simplifies the class interface by combining the ctor argument
with the property declaration.
  • Loading branch information
hemberger committed Dec 25, 2024
1 parent e84a2ca commit a5c4d37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
Expand All @@ -17,6 +18,7 @@
->withImportNames(true, false)
->withRules([
ClassOnObjectRector::class,
ClassPropertyAssignToConstructorPromotionRector::class,
DirNameFileConstantToDirConstantRector::class,
FirstClassCallableRector::class,
IfIssetToCoalescingRector::class,
Expand Down
7 changes: 2 additions & 5 deletions src/lib/Smr/AbstractShip.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class AbstractShip {
RACE_NIJARIN => SHIP_TYPE_REDEEMER,
];

protected AbstractPlayer $player;

protected int $gameID;
protected ShipType $shipType;

Expand All @@ -51,9 +49,8 @@ class AbstractShip {
protected bool $hasChangedCloak = false;
protected bool $hasChangedIllusion = false;

public function __construct(AbstractPlayer $player) {
$this->player = $player;
$this->gameID = $player->getGameID();
public function __construct(protected AbstractPlayer $player) {
$this->gameID = $this->player->getGameID();
$this->regenerateShipType();
}

Expand Down

0 comments on commit a5c4d37

Please sign in to comment.