-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Use constructor property promotion in module Sales Inventory #37230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.4-develop
Are you sure you want to change the base?
Use constructor property promotion in module Sales Inventory #37230
Conversation
Replace allmost all properties with constructor property promotion in module Sales inventory: 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.
Hi @leonhelmus. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. 👍
{ | ||
$this->orderItemRepository = $orderItemRepository; | ||
public function __construct( | ||
private readonly OrderItemRepositoryInterface $orderItemRepository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A trailing comma makes future additions easier to review.
private readonly OrderItemRepositoryInterface $orderItemRepository | |
private readonly OrderItemRepositoryInterface $orderItemRepository, |
/** | ||
* InvoiceRefundCreationArguments constructor. | ||
* @param ReturnValidator $returnValidator | ||
*/ | ||
public function __construct( | ||
ReturnValidator $returnValidator | ||
private readonly ReturnValidator $returnValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A trailing comma makes future additions easier to review.
private readonly ReturnValidator $returnValidator | |
private readonly ReturnValidator $returnValidator, |
/** | ||
* OrderRefundCreationArguments constructor. | ||
* @param ReturnValidator $returnValidator | ||
*/ | ||
public function __construct( | ||
ReturnValidator $returnValidator | ||
private readonly ReturnValidator $returnValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A trailing comma makes future additions easier to review.
private readonly ReturnValidator $returnValidator | |
private readonly ReturnValidator $returnValidator, |
private readonly StockProcessor $stockIndexerProcessor, | ||
private readonly PriceProcessor $priceIndexer, | ||
private readonly ReturnProcessor $returnProcessor, | ||
private readonly OrderRepositoryInterface $orderRepository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A trailing comma makes future additions easier to review.
private readonly OrderRepositoryInterface $orderRepository | |
private readonly OrderRepositoryInterface $orderRepository, |
StockProcessor $stockIndexer, | ||
private readonly PriceProcessor $priceIndexer, | ||
private readonly StoreManagerInterface $storeManager, | ||
private readonly OrderItemRepositoryInterface $orderItemRepository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A trailing comma makes future additions easier to review.
private readonly OrderItemRepositoryInterface $orderItemRepository | |
private readonly OrderItemRepositoryInterface $orderItemRepository, |
\Magento\Store\Model\StoreManagerInterface $storeManager, | ||
\Magento\Sales\Api\OrderItemRepositoryInterface $orderItemRepository | ||
private readonly StockManagementInterface $stockManagement, | ||
StockProcessor $stockIndexer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why has this not been promoted?
StockProcessor $stockIndexer, | |
private readonly StockProcessor $stockIndexerProcessor, |
Description (*)
Replace allmost all properties with constructor property promotion in module Sales inventory: https://stitcher.io/blog/constructor-promotion-in-php-8
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.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)