Skip to content

Commit

Permalink
PHP81 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Mar 22, 2024
1 parent 3e15a20 commit d6e1ba2
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 54 deletions.
8 changes: 3 additions & 5 deletions app/Components/ApiResults/ApiResultsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

class ApiResultsComponent extends DIComponent
{
private Connector $gameServerApiConnector;
private FKSDBDownloader $downloader;
private int $eventId;
private readonly Connector $gameServerApiConnector;

Check failure on line 20 in app/Components/ApiResults/ApiResultsComponent.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\ApiResults\ApiResultsComponent has an uninitialized readonly property $gameServerApiConnector. Assign it in the constructor.

Check failure on line 20 in app/Components/ApiResults/ApiResultsComponent.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\ApiResults\ApiResultsComponent has an uninitialized readonly property $gameServerApiConnector. Assign it in the constructor.
private readonly FKSDBDownloader $downloader;

Check failure on line 21 in app/Components/ApiResults/ApiResultsComponent.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\ApiResults\ApiResultsComponent has an uninitialized readonly property $downloader. Assign it in the constructor.

Check failure on line 21 in app/Components/ApiResults/ApiResultsComponent.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\ApiResults\ApiResultsComponent has an uninitialized readonly property $downloader. Assign it in the constructor.

public function __construct(Container $container, int $eventId)
public function __construct(Container $container, private readonly int $eventId)
{
parent::__construct($container);
$this->eventId = $eventId;
}

public function inject(Connector $connector, FKSDBDownloader $downloader): void
Expand Down
11 changes: 6 additions & 5 deletions app/Components/Countdown/CountdownComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

class CountdownComponent extends DIComponent
{
private \DateTimeInterface $countdownTo;
private string $id;
private readonly string $id;

public function __construct(Container $container, \DateTimeInterface $countdownTo, string $id = null)
{
public function __construct(
Container $container,
private readonly \DateTimeInterface $countdownTo,
string $id = null
) {
parent::__construct($container);
$this->countdownTo = $countdownTo;
$this->id = $id ?? uniqid();
}

Expand Down
4 changes: 2 additions & 2 deletions app/Components/ImageGallery/ImageGalleryControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

class ImageGalleryControl extends DIComponent
{
private string $wwwDir;
private Cache $cache;
private readonly string $wwwDir;
private readonly Cache $cache;

Check failure on line 18 in app/Components/ImageGallery/ImageGalleryControl.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\ImageGallery\ImageGalleryControl has an uninitialized readonly property $cache. Assign it in the constructor.

Check failure on line 18 in app/Components/ImageGallery/ImageGalleryControl.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\ImageGallery\ImageGalleryControl has an uninitialized readonly property $cache. Assign it in the constructor.

public function __construct(Container $container)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Components/Map/MapComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MapComponent extends DIComponent
{
private static int $uniqueId = 0;

private DummyService $dummyService;
private readonly DummyService $dummyService;

Check failure on line 18 in app/Components/Map/MapComponent.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\Map\MapComponent has an uninitialized readonly property $dummyService. Assign it in the constructor.

Check failure on line 18 in app/Components/Map/MapComponent.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\Map\MapComponent has an uninitialized readonly property $dummyService. Assign it in the constructor.

protected int $teamCount;
/** @var string[] */
Expand Down
4 changes: 2 additions & 2 deletions app/Components/PdfGallery/PdfGalleryControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

class PdfGalleryControl extends DIComponent
{
private string $wwwDir;
private Cache $cache;
private readonly string $wwwDir;
private readonly Cache $cache;

Check failure on line 17 in app/Components/PdfGallery/PdfGalleryControl.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\PdfGallery\PdfGalleryControl has an uninitialized readonly property $cache. Assign it in the constructor.

Check failure on line 17 in app/Components/PdfGallery/PdfGalleryControl.php

View workflow job for this annotation

GitHub Actions / PHPStan 8.1

Class App\Components\PdfGallery\PdfGalleryControl has an uninitialized readonly property $cache. Assign it in the constructor.

public function __construct(Container $container)
{
Expand Down
8 changes: 3 additions & 5 deletions app/Components/PersonSchedule/AllScheduleListComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@

final class AllScheduleListComponent extends DIComponent
{
private ServiceEventDetail $serviceEventDetail;
private int $eventId;
private FKSDBDownloader $downloader;
private readonly ServiceEventDetail $serviceEventDetail;
private readonly FKSDBDownloader $downloader;

/** @var ModelPersonSchedule[][] | null */
private ?array $groupedPersonSchedule = null;

public function __construct(int $eventId, Container $container)
public function __construct(private readonly int $eventId, Container $container)
{
$this->eventId = $eventId;
parent::__construct($container);
}

Expand Down
6 changes: 2 additions & 4 deletions app/Components/TeamList/TeamListComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@

class TeamListComponent extends DIComponent
{
protected DummyService $serviceTeam;
protected int $eventId;
protected readonly DummyService $serviceTeam;

protected string $category;
protected array $teams;

public function __construct(Container $container, int $eventId)
public function __construct(Container $container, protected readonly int $eventId)
{
parent::__construct($container);
$this->eventId = $eventId;
}

public function injectServiceTeam(DummyService $serviceTeam): void
Expand Down
6 changes: 2 additions & 4 deletions app/Components/TeamResults/TeamResultsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

class TeamResultsComponent extends DIComponent
{
protected DummyService $serviceTeam;
protected int $eventId;
protected readonly DummyService $serviceTeam;
protected ?array $filterData = null;

public function __construct(Container $container, int $eventId)
public function __construct(Container $container,protected readonly int $eventId)
{
parent::__construct($container);
$this->eventId = $eventId;
}

public function injectServiceTeam(DummyService $serviceTeam): void
Expand Down
2 changes: 1 addition & 1 deletion app/Components/UpperHomeMap/UpperHomeMapComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class UpperHomeMapComponent extends DIComponent
{
private GamePhaseCalculator $gamePhaseCalculator;
private readonly GamePhaseCalculator $gamePhaseCalculator;

public function __construct(Container $container, private readonly ModelEvent $event)
{
Expand Down
4 changes: 2 additions & 2 deletions app/Components/UpperHomePrague/UpperHomePrague.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

final class UpperHomePrague extends DIComponent
{
private GamePhaseCalculator $gamePhaseCalculator;
private readonly GamePhaseCalculator $gamePhaseCalculator;

public function __construct(Container $container,private readonly ModelEvent $event)
public function __construct(Container $container, private readonly ModelEvent $event)
{
parent::__construct($container);
}
Expand Down
26 changes: 6 additions & 20 deletions app/Models/GamePhaseCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@
use Nette\SmartObject;
use Throwable;

class GamePhaseCalculator
final class GamePhaseCalculator
{
use SmartObject;

private ServiceEventList $serviceEventList;
private Container $container;

private int $eventTypeId;

public function __construct(int $eventTypeId, ServiceEventList $serviceEventList, Container $container)
{
$this->eventTypeId = $eventTypeId;
$this->serviceEventList = $serviceEventList;
$this->container = $container;
public function __construct(
private readonly int $eventTypeId,
private readonly ServiceEventList $serviceEventList,
private readonly Container $container
) {
}

/**
Expand All @@ -38,15 +33,6 @@ public function getGameBegin(): \DateTime
return $time;
}

/**
* Returns true about a week after the event when no one is interested in game already.
* @throws Throwable
*/
public function isLongAfterTheEvent(): bool
{
return $this->getFKSDBEvent()->isLongAfterTheEvent();
}

/**
* Returns newest FKSDB event. That means by creating a new one, the application automatically switches to the new
* year.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/NetteDownloader/ORM/Models/ModelEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getNearEventPeriod(): Period
}
/**
* Returns true about a week after the event when no one is interested in game already.
* @throws Throwable
* @throws \Throwable
*/
public function isLongAfterTheEvent(): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract class AbstractJSONService
use SmartObject;

protected NetteDownloader $downloader;
protected Cache $cache;
protected string $expiration;
protected readonly Cache $cache;
protected readonly string $expiration;

public function __construct(string $expiration, Storage $storage)
{
Expand Down

0 comments on commit d6e1ba2

Please sign in to comment.