Skip to content

Commit 1ac7d60

Browse files
Use constructor property promotion in module Vault graph Ql
Replace allmost all properties with constructor property promotion in module version: https://stitcher.io/blog/constructor-promotion-in-php-8 * Readable code * Make Magento less complex by removing properties which take up a lot of lines. * Imported all classes to make code more readable. I think the code would be a lot cleaner if all modules start using constructor promotions, since of 2.4.6 php 7.4 is dropped we can now make use of it. So let's start on it right now :).
1 parent aab3ee6 commit 1ac7d60

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

app/code/Magento/VaultGraphQl/Model/Resolver/DeletePaymentToken.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,14 @@
2121
*/
2222
class DeletePaymentToken implements ResolverInterface
2323
{
24-
/**
25-
* @var PaymentTokenManagementInterface
26-
*/
27-
private $paymentTokenManagement;
28-
29-
/**
30-
* @var PaymentTokenRepositoryInterface
31-
*/
32-
private $paymentTokenRepository;
33-
3424
/**
3525
* @param PaymentTokenManagementInterface $paymentTokenManagement
3626
* @param PaymentTokenRepositoryInterface $paymentTokenRepository
3727
*/
3828
public function __construct(
39-
PaymentTokenManagementInterface $paymentTokenManagement,
40-
PaymentTokenRepositoryInterface $paymentTokenRepository
29+
private readonly PaymentTokenManagementInterface $paymentTokenManagement,
30+
private readonly PaymentTokenRepositoryInterface $paymentTokenRepository
4131
) {
42-
$this->paymentTokenManagement = $paymentTokenManagement;
43-
$this->paymentTokenRepository = $paymentTokenRepository;
4432
}
4533

4634
/**

app/code/Magento/VaultGraphQl/Model/Resolver/PaymentTokens.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@
1919
*/
2020
class PaymentTokens implements ResolverInterface
2121
{
22-
/**
23-
* @var PaymentTokenManagement
24-
*/
25-
private $paymentTokenManagement;
26-
2722
/**
2823
* @param PaymentTokenManagement $paymentTokenManagement
2924
*/
3025
public function __construct(
31-
PaymentTokenManagement $paymentTokenManagement
26+
private readonly PaymentTokenManagement $paymentTokenManagement
3227
) {
33-
$this->paymentTokenManagement = $paymentTokenManagement;
3428
}
3529

3630
/**

app/code/Magento/VaultGraphQl/registration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@
77

88
use Magento\Framework\Component\ComponentRegistrar;
99

10-
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_VaultGraphQl', __DIR__);
10+
ComponentRegistrar::register(
11+
ComponentRegistrar::MODULE,
12+
'Magento_VaultGraphQl',
13+
__DIR__
14+
);

0 commit comments

Comments
 (0)