Skip to content

Commit 30d6383

Browse files
committed
Modernize codebase to use PHP 8.2 features
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
1 parent 035e7a3 commit 30d6383

18 files changed

+55
-110
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require-dev": {
2424
"contributte/console": "^0.11.0 || ^0.12.0",
25-
"contributte/phpstan": "^0.1.0",
25+
"contributte/phpstan": "^0.3.1",
2626
"contributte/qa": "^0.4.0",
2727
"contributte/tester": "^0.4.0",
2828
"latte/latte": "^3.0.12",

src/Cache/Cleaners/LocalFilesystemCleaner.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@
99
class LocalFilesystemCleaner implements ICleaner
1010
{
1111

12-
/** @var string[] */
13-
private array $directories;
14-
15-
/** @var string[] */
16-
private array $ignored;
17-
1812
/**
1913
* @param string[] $directories
2014
* @param string[] $ignored
2115
*/
22-
public function __construct(array $directories, array $ignored = [])
16+
public function __construct(
17+
private readonly array $directories,
18+
private readonly array $ignored = [],
19+
)
2320
{
24-
$this->directories = $directories;
25-
$this->ignored = $ignored;
2621
}
2722

2823
public function getDescription(): string

src/Cache/Cleaners/MemcachedCleaner.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
class MemcachedCleaner implements ICleaner
1111
{
1212

13-
/** @var Memcached[]|Memcache[] */
14-
private array $memcaches;
15-
1613
/**
1714
* @param Memcached[]|Memcache[] $memcaches
1815
*/
19-
public function __construct(array $memcaches)
16+
public function __construct(
17+
private readonly array $memcaches,
18+
)
2019
{
21-
$this->memcaches = $memcaches;
2220
}
2321

2422
public function getDescription(): string

src/Cache/Cleaners/NetteCachingStorageCleaner.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
class NetteCachingStorageCleaner implements ICleaner
1111
{
1212

13-
/** @var Storage[] */
14-
private array $storages;
15-
1613
/**
1714
* @param Storage[] $storages
1815
*/
19-
public function __construct(array $storages)
16+
public function __construct(
17+
private readonly array $storages,
18+
)
2019
{
21-
$this->storages = $storages;
2220
}
2321

2422
public function getDescription(): string

src/Cache/Generators/DiContainersCacheGenerator.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,14 @@
99
class DiContainersCacheGenerator implements IGenerator
1010
{
1111

12-
/** @var mixed[] */
13-
private array $config;
14-
15-
private Configurator $configurator;
16-
1712
/**
1813
* @param mixed[] $config
1914
*/
20-
public function __construct(array $config, Configurator $configurator)
15+
public function __construct(
16+
private readonly array $config,
17+
private readonly Configurator $configurator,
18+
)
2119
{
22-
$this->config = $config;
23-
$this->configurator = $configurator;
2420
}
2521

2622
public function getDescription(): string

src/Cache/Generators/LatteTemplatesCacheGenerator.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,17 @@
1212
class LatteTemplatesCacheGenerator implements IGenerator
1313
{
1414

15-
private TemplateFactory $templateFactory;
16-
17-
/** @var string[] */
18-
private array $dirs;
19-
20-
/** @var string[] */
21-
private array $excludeDirs;
22-
23-
private ?string $rootDir = null;
24-
2515
/**
2616
* @param string[] $dirs
2717
* @param string[] $excludeDirs
2818
*/
29-
public function __construct(TemplateFactory $templateFactory, array $dirs, array $excludeDirs = [], ?string $rootDir = null)
19+
public function __construct(
20+
private readonly TemplateFactory $templateFactory,
21+
private readonly array $dirs,
22+
private readonly array $excludeDirs = [],
23+
private readonly ?string $rootDir = null,
24+
)
3025
{
31-
$this->templateFactory = $templateFactory;
32-
$this->dirs = $dirs;
33-
$this->excludeDirs = $excludeDirs;
34-
$this->rootDir = $rootDir;
3526
}
3627

3728
public function getDescription(): string

src/Command/AdvancedCache/CacheCleanCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@
2020
class CacheCleanCommand extends Command
2121
{
2222

23-
/** @var ICleaner[] */
24-
private array $cleaners = [];
25-
2623
/**
2724
* @param ICleaner[] $cleaners
2825
*/
29-
public function __construct(array $cleaners)
26+
public function __construct(
27+
private readonly array $cleaners = [],
28+
)
3029
{
3130
parent::__construct();
32-
33-
$this->cleaners = $cleaners;
3431
}
3532

3633
protected function configure(): void

src/Command/Cache/CachePurgeCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@
1818
class CachePurgeCommand extends Command
1919
{
2020

21-
/** @var string[] */
22-
private array $dirs;
23-
2421
/**
2522
* @param string[] $dirs
2623
*/
27-
public function __construct(array $dirs)
24+
public function __construct(
25+
private readonly array $dirs,
26+
)
2827
{
2928
parent::__construct();
30-
31-
$this->dirs = $dirs;
3229
}
3330

3431
protected function configure(): void

src/Command/Caching/CachingClearCommand.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
class CachingClearCommand extends Command
2020
{
2121

22-
private Storage $storage;
23-
24-
public function __construct(Storage $storage)
22+
public function __construct(
23+
private readonly Storage $storage,
24+
)
2525
{
2626
parent::__construct();
27-
28-
$this->storage = $storage;
2927
}
3028

3129
protected function configure(): void

src/Command/DI/DIPurgeCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@
1616
class DIPurgeCommand extends Command
1717
{
1818

19-
/** @var string[] */
20-
private array $dirs;
21-
2219
/**
2320
* @param string[] $dirs
2421
*/
25-
public function __construct(array $dirs)
22+
public function __construct(
23+
private readonly array $dirs,
24+
)
2625
{
2726
parent::__construct();
28-
29-
$this->dirs = $dirs;
3027
}
3128

3229
protected function execute(InputInterface $input, OutputInterface $output): int

0 commit comments

Comments
 (0)