-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Use constructor property promotion in module Shipping #37217
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 Shipping #37217
Conversation
Replace allmost all properties with constructor property promotion in module Shipping: 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. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
{ | ||
/** | ||
* Core registry | ||
* | ||
* @var \Magento\Framework\Registry | ||
* @var Registry | ||
*/ | ||
protected $_coreRegistry = null; |
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 not promote this property?
{ | ||
/** | ||
* Sales data | ||
* | ||
* @var \Magento\Sales\Helper\Data | ||
* @var SalesHelper | ||
*/ | ||
protected $_salesData; |
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 not promote this property?
*/ | ||
protected $_salesData; | ||
|
||
/** | ||
* @var \Magento\Shipping\Model\CarrierFactory | ||
* @var CarrierFactory | ||
*/ | ||
protected $_carrierFactory; |
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 not promote this property?
*/ | ||
protected $_jsonEncoder; | ||
|
||
/** | ||
* @var \Magento\Shipping\Model\CarrierFactory | ||
* @var CarrierFactory | ||
*/ | ||
protected $_carrierFactory; |
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 not promote this property?
*/ | ||
protected $_coreRegistry = null; | ||
|
||
/** | ||
* @var \Magento\Framework\Json\EncoderInterface | ||
* @var EncoderInterface | ||
*/ | ||
protected $_jsonEncoder; |
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 not promote this property?
*/ | ||
protected $_scopeConfig; | ||
|
||
/** | ||
* @var \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory | ||
* @var ErrorFactory | ||
*/ | ||
protected $_rateErrorFactory; |
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 not promote this property?
@@ -72,30 +82,30 @@ abstract class AbstractCarrier extends \Magento\Framework\DataObject implements | |||
/** | |||
* Core store config | |||
* | |||
* @var \Magento\Framework\App\Config\ScopeConfigInterface | |||
* @var ScopeConfigInterface | |||
*/ | |||
protected $_scopeConfig; |
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 not promote this property?
ScopeConfigInterface $scopeConfig, | ||
RateResultErrorFactory $rateErrorFactory, | ||
LoggerInterface $logger, | ||
protected readonly Security $xmlSecurity, | ||
ElementFactory $xmlElFactory, | ||
RateResultFactory $rateFactory, | ||
MethodFactory $rateMethodFactory, | ||
ResultFactory $trackFactory, | ||
ErrorFactory $trackErrorFactory, | ||
StatusFactory $trackStatusFactory, | ||
RegionFactory $regionFactory, | ||
CountryFactory $countryFactory, | ||
CurrencyFactory $currencyFactory, | ||
DirectoryHelper $directoryData, |
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 not promote these properties?
{ | ||
/** | ||
* Core store config | ||
* | ||
* @var \Magento\Framework\App\Config\ScopeConfigInterface | ||
* @var ScopeConfigInterface | ||
*/ | ||
protected $_scopeConfig; |
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 not promote this property?
*/ | ||
protected $_scopeConfig; | ||
|
||
/** | ||
* @var \Magento\Shipping\Model\Config | ||
* @var ShippingConfig | ||
*/ | ||
protected $_shippingConfig; |
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 not promote this property?
Description (*)
Replace allmost all properties with constructor property promotion in module Shipping: 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 (*)