Skip to content

Commit 785f8c1

Browse files
committed
Use constructor property promotion where possible
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 48f671d commit 785f8c1

232 files changed

Lines changed: 462 additions & 1744 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libraries/classes/Advisory/Advisor.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
*/
3232
class Advisor
3333
{
34-
private DatabaseInterface $dbi;
35-
3634
/** @var array */
3735
private $variables;
3836

@@ -53,16 +51,12 @@ class Advisor
5351
'errors' => [],
5452
];
5553

56-
private ExpressionLanguage $expression;
57-
5854
/**
5955
* @param DatabaseInterface $dbi DatabaseInterface object
6056
* @param ExpressionLanguage $expression ExpressionLanguage object
6157
*/
62-
public function __construct(DatabaseInterface $dbi, ExpressionLanguage $expression)
58+
public function __construct(private DatabaseInterface $dbi, private ExpressionLanguage $expression)
6359
{
64-
$this->dbi = $dbi;
65-
$this->expression = $expression;
6660
/**
6761
* Register functions for ExpressionLanguage, we intentionally
6862
* do not implement support for compile as we do not use it.

libraries/classes/Bookmark.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,8 @@ class Bookmark
5656
*/
5757
private $query;
5858

59-
private DatabaseInterface $dbi;
60-
61-
private Relation $relation;
62-
63-
public function __construct(DatabaseInterface $dbi, Relation $relation)
59+
public function __construct(private DatabaseInterface $dbi, private Relation $relation)
6460
{
65-
$this->dbi = $dbi;
66-
$this->relation = $relation;
6761
}
6862

6963
/**

libraries/classes/CheckUserPrivileges.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@
2121
*/
2222
class CheckUserPrivileges
2323
{
24-
private DatabaseInterface $dbi;
25-
2624
/**
2725
* @param DatabaseInterface $dbi DatabaseInterface object
2826
*/
29-
public function __construct(DatabaseInterface $dbi)
27+
public function __construct(private DatabaseInterface $dbi)
3028
{
31-
$this->dbi = $dbi;
3229
}
3330

3431
/**

libraries/classes/Config/FormDisplayTemplate.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@ class FormDisplayTemplate
2323
/** @var int */
2424
public $group;
2525

26-
protected Config $config;
27-
2826
/** @var Template */
2927
public $template;
3028

3129
/**
3230
* @param Config $config Config instance
3331
*/
34-
public function __construct(Config $config)
32+
public function __construct(protected Config $config)
3533
{
36-
$this->config = $config;
3734
$this->template = new Template();
3835
}
3936

libraries/classes/ConfigStorage/Relation.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@
5757
*/
5858
class Relation
5959
{
60-
/** @var DatabaseInterface */
61-
public $dbi;
62-
6360
/** @param DatabaseInterface $dbi */
64-
public function __construct($dbi)
61+
public function __construct(public $dbi)
6562
{
66-
$this->dbi = $dbi;
6763
}
6864

6965
public function getRelationParameters(): RelationParameters

libraries/classes/ConfigStorage/RelationCleanup.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@ class RelationCleanup
1515
/** @var Relation */
1616
public $relation;
1717

18-
/** @var DatabaseInterface */
19-
public $dbi;
20-
2118
/**
2219
* @param DatabaseInterface $dbi DatabaseInterface object
2320
* @param Relation $relation Relation object
2421
*/
25-
public function __construct($dbi, Relation $relation)
22+
public function __construct(public $dbi, Relation $relation)
2623
{
27-
$this->dbi = $dbi;
2824
$this->relation = $relation;
2925
}
3026

libraries/classes/Console.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,11 @@ class Console
3333
*/
3434
private $isAjax = false;
3535

36-
private Relation $relation;
37-
3836
/** @var Template */
3937
public $template;
4038

41-
public function __construct(Relation $relation, Template $template)
39+
public function __construct(private Relation $relation, Template $template)
4240
{
43-
$this->relation = $relation;
4441
$this->template = $template;
4542
}
4643

libraries/classes/Controllers/AbstractController.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,8 @@
1818

1919
abstract class AbstractController
2020
{
21-
protected ResponseRenderer $response;
22-
23-
protected Template $template;
24-
25-
public function __construct(ResponseRenderer $response, Template $template)
21+
public function __construct(protected ResponseRenderer $response, protected Template $template)
2622
{
27-
$this->response = $response;
28-
$this->template = $template;
2923
}
3024

3125
/**

libraries/classes/Controllers/BrowseForeignersController.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,13 @@
1515
*/
1616
class BrowseForeignersController extends AbstractController
1717
{
18-
private BrowseForeigners $browseForeigners;
19-
20-
private Relation $relation;
21-
2218
public function __construct(
2319
ResponseRenderer $response,
2420
Template $template,
25-
BrowseForeigners $browseForeigners,
26-
Relation $relation
21+
private BrowseForeigners $browseForeigners,
22+
private Relation $relation
2723
) {
2824
parent::__construct($response, $template);
29-
$this->browseForeigners = $browseForeigners;
30-
$this->relation = $relation;
3125
}
3226

3327
public function __invoke(ServerRequest $request): void

libraries/classes/Controllers/CheckRelationsController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
*/
1818
class CheckRelationsController extends AbstractController
1919
{
20-
private Relation $relation;
21-
22-
public function __construct(ResponseRenderer $response, Template $template, Relation $relation)
20+
public function __construct(ResponseRenderer $response, Template $template, private Relation $relation)
2321
{
2422
parent::__construct($response, $template);
25-
$this->relation = $relation;
2623
}
2724

2825
public function __invoke(ServerRequest $request): void

0 commit comments

Comments
 (0)