Skip to content

Commit

Permalink
rector: add ReadOnlyPropertyRector
Browse files Browse the repository at this point in the history
If class properties are never set outside the ctor, they can be marked
as readonly.
  • Loading branch information
hemberger committed Dec 25, 2024
1 parent a5c4d37 commit 81ae13b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
Expand All @@ -24,6 +25,7 @@
IfIssetToCoalescingRector::class,
JsonThrowOnErrorRector::class,
NullCoalescingOperatorRector::class,
ReadOnlyPropertyRector::class,
])
->withSets([
PHPUnitSetList::PHPUNIT_100,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Smr/Blackjack/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
class Table {

private Deck $deck;
private readonly Deck $deck;
public Hand $playerHand;
public Hand $dealerHand;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/Smr/Routes/RouteIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
class RouteIterator {

/** @var InfiniteIterator<int, OneWayRoute, ArrayIterator<int, OneWayRoute>> */
private InfiniteIterator $routeIterator;
private readonly InfiniteIterator $routeIterator;

private TransactionType $transaction = TransactionType::Buy;

public function __construct(
private MultiplePortRoute $route,
private readonly MultiplePortRoute $route,
) {
$oneWayRoutes = $route->getOneWayRoutes();
$this->routeIterator = new InfiniteIterator(new ArrayIterator($oneWayRoutes));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Smr/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Session {
private array $requestData = [];
private bool $generate;
public readonly bool $ajax;
private string $SN;
private readonly string $SN;
private string $lastSN;
private int $accountID;
private float $lastAccessed;
Expand Down

0 comments on commit 81ae13b

Please sign in to comment.