Skip to content

Commit fe65f38

Browse files
committed
used constructor promotion
1 parent 887ba0b commit fe65f38

File tree

7 files changed

+29
-94
lines changed

7 files changed

+29
-94
lines changed

src/Application/ErrorPresenter.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ final class ErrorPresenter implements Application\IPresenter
2222
{
2323
use Nette\SmartObject;
2424

25-
private ?ILogger $logger;
26-
27-
28-
public function __construct(ILogger $logger = null)
29-
{
30-
$this->logger = $logger;
25+
public function __construct(
26+
private ?ILogger $logger = null,
27+
) {
3128
}
3229

3330

src/Application/LinkGenerator.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ final class LinkGenerator
2121
{
2222
use Nette\SmartObject;
2323

24-
private Router $router;
25-
26-
private UrlScript $refUrl;
27-
28-
private ?IPresenterFactory $presenterFactory;
29-
30-
31-
public function __construct(Router $router, UrlScript $refUrl, IPresenterFactory $presenterFactory = null)
32-
{
33-
$this->router = $router;
34-
$this->refUrl = $refUrl;
35-
$this->presenterFactory = $presenterFactory;
24+
public function __construct(
25+
private Router $router,
26+
private UrlScript $refUrl,
27+
private ?IPresenterFactory $presenterFactory = null,
28+
) {
3629
}
3730

3831

src/Application/MicroPresenter.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,14 @@ final class MicroPresenter implements Application\IPresenter
2424
{
2525
use Nette\SmartObject;
2626

27-
private ?Nette\DI\Container $context;
28-
29-
private ?Nette\Http\IRequest $httpRequest;
30-
31-
private ?Router $router;
32-
3327
private ?Application\Request $request;
3428

3529

3630
public function __construct(
37-
Nette\DI\Container $context = null,
38-
Http\IRequest $httpRequest = null,
39-
Router $router = null,
31+
private ?Nette\DI\Container $context = null,
32+
private ?Nette\Http\IRequest $httpRequest = null,
33+
private ?Router $router = null,
4034
) {
41-
$this->context = $context;
42-
$this->httpRequest = $httpRequest;
43-
$this->router = $router;
4435
}
4536

4637

src/Application/Request.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,18 @@ final class Request
3737
/** flag */
3838
public const VARYING = 'varying';
3939

40-
private ?string $method;
41-
42-
private array $flags = [];
43-
44-
private string $name;
45-
46-
private array $params;
47-
48-
private array $post;
49-
50-
private array $files;
51-
5240

5341
/**
5442
* @param string $name presenter name (module:module:presenter)
5543
*/
5644
public function __construct(
57-
string $name,
58-
string $method = null,
59-
array $params = [],
60-
array $post = [],
61-
array $files = [],
62-
array $flags = [],
45+
private string $name,
46+
private ?string $method = null,
47+
private array $params = [],
48+
private array $post = [],
49+
private array $files = [],
50+
private array $flags = [],
6351
) {
64-
$this->name = $name;
65-
$this->method = $method;
66-
$this->params = $params;
67-
$this->post = $post;
68-
$this->files = $files;
69-
$this->flags = $flags;
7052
}
7153

7254

src/Bridges/ApplicationDI/ApplicationExtension.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,18 @@
2222
*/
2323
final class ApplicationExtension extends Nette\DI\CompilerExtension
2424
{
25-
private bool $debugMode;
26-
2725
private array $scanDirs;
2826

29-
private ?Nette\Loaders\RobotLoader $robotLoader;
30-
3127
private int $invalidLinkMode;
3228

33-
private ?string $tempDir;
34-
3529

3630
public function __construct(
37-
bool $debugMode = false,
31+
private bool $debugMode = false,
3832
array $scanDirs = null,
39-
string $tempDir = null,
40-
Nette\Loaders\RobotLoader $robotLoader = null,
33+
private ?string $tempDir = null,
34+
private ?Nette\Loaders\RobotLoader $robotLoader = null,
4135
) {
42-
$this->debugMode = $debugMode;
4336
$this->scanDirs = (array) $scanDirs;
44-
$this->tempDir = $tempDir;
45-
$this->robotLoader = $robotLoader;
4637
}
4738

4839

src/Bridges/ApplicationDI/PresenterFactoryCallback.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,11 @@
1818
*/
1919
final class PresenterFactoryCallback
2020
{
21-
private Nette\DI\Container $container;
22-
23-
private int $invalidLinkMode;
24-
25-
private ?string $touchToRefresh;
26-
27-
28-
public function __construct(Nette\DI\Container $container, int $invalidLinkMode, ?string $touchToRefresh)
29-
{
30-
$this->container = $container;
31-
$this->invalidLinkMode = $invalidLinkMode;
32-
$this->touchToRefresh = $touchToRefresh;
21+
public function __construct(
22+
private Nette\DI\Container $container,
23+
private int $invalidLinkMode,
24+
private ?string $touchToRefresh,
25+
) {
3326
}
3427

3528

src/Bridges/ApplicationLatte/TemplateFactory.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,16 @@ class TemplateFactory implements UI\TemplateFactory
2424
/** @var array<callable(Template): void> Occurs when a new template is created */
2525
public $onCreate = [];
2626

27-
private LatteFactory $latteFactory;
28-
29-
private ?Nette\Http\IRequest $httpRequest;
30-
31-
private ?Nette\Security\User $user;
32-
33-
private ?Nette\Caching\Storage $cacheStorage;
34-
3527
private string $templateClass;
3628

3729

3830
public function __construct(
39-
LatteFactory $latteFactory,
40-
Nette\Http\IRequest $httpRequest = null,
41-
Nette\Security\User $user = null,
42-
Nette\Caching\Storage $cacheStorage = null,
31+
private LatteFactory $latteFactory,
32+
private ?Nette\Http\IRequest $httpRequest = null,
33+
private ?Nette\Security\User $user = null,
34+
private ?Nette\Caching\Storage $cacheStorage = null,
4335
$templateClass = null,
4436
) {
45-
$this->latteFactory = $latteFactory;
46-
$this->httpRequest = $httpRequest;
47-
$this->user = $user;
48-
$this->cacheStorage = $cacheStorage;
4937
if ($templateClass && (!class_exists($templateClass) || !is_a($templateClass, Template::class, true))) {
5038
throw new Nette\InvalidArgumentException("Class $templateClass does not implement " . Template::class . ' or it does not exist.');
5139
}

0 commit comments

Comments
 (0)