Skip to content

Commit fa62051

Browse files
committed
fix: refactor constructors for property promotion
1 parent 9d8a769 commit fa62051

5 files changed

Lines changed: 15 additions & 82 deletions

File tree

src/Block/Inspector.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,13 @@ class Inspector extends Template
1919
{
2020
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
2121

22-
private State $state;
23-
24-
private ScopeConfigInterface $scopeConfig;
25-
26-
private DevHelper $devHelper;
27-
28-
/**
29-
* @param Context $context
30-
* @param State $state
31-
* @param ScopeConfigInterface $scopeConfig
32-
* @param DevHelper $devHelper
33-
* @param array $data
34-
*/
3522
public function __construct(
3623
Context $context,
37-
State $state,
38-
ScopeConfigInterface $scopeConfig,
39-
DevHelper $devHelper,
24+
private readonly State $state,
25+
private readonly ScopeConfigInterface $scopeConfig,
26+
private readonly DevHelper $devHelper,
4027
array $data = []
4128
) {
42-
$this->state = $state;
43-
$this->scopeConfig = $scopeConfig;
44-
$this->devHelper = $devHelper;
4529
parent::__construct($context, $data);
4630
}
4731

src/Console/Command/Dev/InspectorCommand.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,12 @@ class InspectorCommand extends AbstractCommand
2121
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
2222
private const ARGUMENT_ACTION = 'action';
2323

24-
private WriterInterface $configWriter;
25-
26-
private State $state;
27-
28-
private CacheManager $cacheManager;
29-
30-
/**
31-
* @param WriterInterface $configWriter
32-
* @param State $state
33-
* @param CacheManager $cacheManager
34-
* @param string|null $name
35-
*/
3624
public function __construct(
37-
WriterInterface $configWriter,
38-
State $state,
39-
CacheManager $cacheManager,
25+
private readonly WriterInterface $configWriter,
26+
private readonly State $state,
27+
private readonly CacheManager $cacheManager,
4028
?string $name = null
4129
) {
42-
$this->configWriter = $configWriter;
43-
$this->state = $state;
44-
$this->cacheManager = $cacheManager;
4530
parent::__construct($name);
4631
}
4732

src/Model/TemplateEngine/Decorator/InspectorHints.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
*/
1717
class InspectorHints implements TemplateEngineInterface
1818
{
19-
private TemplateEngineInterface $subject;
20-
21-
private bool $showBlockHints;
22-
23-
private Random $random;
24-
2519
private string $magentoRoot;
2620

2721
/**
@@ -30,14 +24,10 @@ class InspectorHints implements TemplateEngineInterface
3024
* @param Random $random
3125
*/
3226
public function __construct(
33-
TemplateEngineInterface $subject,
34-
bool $showBlockHints,
35-
Random $random
27+
private readonly TemplateEngineInterface $subject,
28+
private readonly bool $showBlockHints,
29+
private readonly Random $random
3630
) {
37-
$this->subject = $subject;
38-
$this->showBlockHints = $showBlockHints;
39-
$this->random = $random;
40-
4131
// Get Magento root directory - try multiple strategies
4232
// 1. Try from BP constant (most reliable)
4333
if (defined('BP')) {

src/Model/TemplateEngine/Plugin/InspectorHints.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,13 @@ class InspectorHints
2222
{
2323
private const XML_PATH_INSPECTOR_ENABLED = 'dev/mageforge_inspector/enabled';
2424

25-
private ScopeConfigInterface $scopeConfig;
26-
27-
private StoreManagerInterface $storeManager;
28-
29-
private DevHelper $devHelper;
30-
31-
private InspectorHintsFactory $inspectorHintsFactory;
32-
33-
private State $state;
34-
35-
/**
36-
* @param ScopeConfigInterface $scopeConfig
37-
* @param StoreManagerInterface $storeManager
38-
* @param DevHelper $devHelper
39-
* @param InspectorHintsFactory $inspectorHintsFactory
40-
* @param State $state
41-
*/
4225
public function __construct(
43-
ScopeConfigInterface $scopeConfig,
44-
StoreManagerInterface $storeManager,
45-
DevHelper $devHelper,
46-
InspectorHintsFactory $inspectorHintsFactory,
47-
State $state
26+
private readonly ScopeConfigInterface $scopeConfig,
27+
private readonly StoreManagerInterface $storeManager,
28+
private readonly DevHelper $devHelper,
29+
private readonly InspectorHintsFactory $inspectorHintsFactory,
30+
private readonly State $state
4831
) {
49-
$this->scopeConfig = $scopeConfig;
50-
$this->storeManager = $storeManager;
51-
$this->devHelper = $devHelper;
52-
$this->inspectorHintsFactory = $inspectorHintsFactory;
53-
$this->state = $state;
5432
}
5533

5634
/**

src/Service/ThemeBuilder/BuilderPool.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66

77
class BuilderPool
88
{
9-
/** @var BuilderInterface[] */
10-
private array $builders;
11-
129
/**
1310
* @param BuilderInterface[] $builders
1411
*/
1512
public function __construct(
16-
array $builders = []
13+
private readonly array $builders = []
1714
) {
18-
$this->builders = $builders;
1915
}
2016

2117
public function getBuilder(string $themePath): ?BuilderInterface

0 commit comments

Comments
 (0)