diff --git a/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php b/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php
index ae5da9e15cf53..40a622c5f47eb 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Frontend/Region/Updater.php
@@ -5,33 +5,31 @@
*/
namespace Magento\Tax\Block\Adminhtml\Frontend\Region;
+use Magento\Backend\Block\Template\Context;
+use Magento\Config\Block\System\Config\Form\Field;
+use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\SecureHtmlRenderer;
-class Updater extends \Magento\Config\Block\System\Config\Form\Field
+class Updater extends Field
{
/**
- * @var \Magento\Directory\Helper\Data
+ * @var DirectoryHelper
*/
protected $_directoryHelper;
/**
- * @var SecureHtmlRenderer
- */
- private $secureRenderer;
-
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Directory\Helper\Data $directoryHelper
+ * @param Context $context
+ * @param DirectoryHelper $directoryHelper
* @param array $data
* @param SecureHtmlRenderer|null $secureRenderer
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Directory\Helper\Data $directoryHelper,
+ Context $context,
+ DirectoryHelper $directoryHelper,
array $data = [],
- ?SecureHtmlRenderer $secureRenderer = null
+ private ?SecureHtmlRenderer $secureRenderer = null
) {
$this->_directoryHelper = $directoryHelper;
parent::__construct($context, $data);
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php b/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php
index a1f538e0b0c70..c86125a2c980e 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Items/Price/Renderer.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Tax\Block\Adminhtml\Items\Price;
+use Magento\Backend\Block\Template;
+use Magento\Backend\Block\Template\Context;
+use Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn;
use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem;
use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem;
use Magento\Sales\Model\Order\Item;
@@ -18,47 +21,35 @@
* @api
* @since 100.0.2
*/
-class Renderer extends \Magento\Backend\Block\Template
+class Renderer extends Template
{
/**
- * @var \Magento\Tax\Helper\Data
+ * @var TaxHelper
* @deprecated 100.3.0
* Marked as deprecated as it is unused.
*/
protected $taxHelper;
- /**
- * @var \Magento\Tax\Block\Item\Price\Renderer
- */
- protected $itemPriceRenderer;
-
- /**
- * @var \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn
- */
- protected $defaultColumnRenderer;
-
/**
* @var Item|QuoteItem|InvoiceItem|CreditmemoItem
*/
protected $item;
/**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer
+ * @param Context $context
+ * @param DefaultColumn $defaultColumnRenderer
* @param TaxHelper $taxHelper
* @param ItemPriceRenderer $itemPriceRenderer
* @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer,
+ Context $context,
+ protected readonly DefaultColumn $defaultColumnRenderer,
TaxHelper $taxHelper,
- ItemPriceRenderer $itemPriceRenderer,
+ protected readonly ItemPriceRenderer $itemPriceRenderer,
array $data = []
) {
- $this->defaultColumnRenderer = $defaultColumnRenderer;
- $this->itemPriceRenderer = $itemPriceRenderer;
$this->itemPriceRenderer->setZone('sales');
parent::__construct($context, $data);
}
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php
index 7ec16fd7f5373..df702aa4d9b22 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Form.php
@@ -13,10 +13,25 @@
namespace Magento\Tax\Block\Adminhtml\Rate;
+use Magento\Backend\Block\Template\Context;
+use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Directory\Helper\Data as DirectoryHelper;
+use Magento\Directory\Model\Config\Source\Country;
+use Magento\Directory\Model\RegionFactory;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Data\Form as FormData;
+use Magento\Framework\Data\FormFactory;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Registry;
+use Magento\Framework\View\Element\Template;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Tax\Api\TaxRateRepositoryInterface;
+use Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory;
use Magento\Tax\Controller\RegistryConstants;
+use Magento\Tax\Helper\Data as TaxHelper;
+use Magento\Tax\Model\Calculation\Rate\Converter;
+use Magento\Tax\Model\Config;
+use Magento\Tax\Model\TaxRateCollection;
/**
* Tax rate form.
@@ -25,7 +40,7 @@
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
-class Form extends \Magento\Backend\Block\Widget\Form\Generic
+class Form extends Generic
{
const FORM_ELEMENT_ID = 'rate-form';
@@ -42,66 +57,66 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic
/**
* Tax data
*
- * @var \Magento\Tax\Helper\Data|null
+ * @var TaxHelper|null
*/
protected $_taxData = null;
/**
- * @var \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory
+ * @var FieldsetFactory
*/
protected $_fieldsetFactory;
/**
- * @var \Magento\Directory\Model\Config\Source\Country
+ * @var Country
*/
protected $_country;
/**
- * @var \Magento\Directory\Model\RegionFactory
+ * @var RegionFactory
*/
protected $_regionFactory;
/**
- * @var \Magento\Tax\Api\TaxRateRepositoryInterface
+ * @var TaxRateRepositoryInterface
*/
protected $_taxRateRepository;
/**
- * @var \Magento\Tax\Model\TaxRateCollection
+ * @var TaxRateCollection
*/
protected $_taxRateCollection;
/**
- * @var \Magento\Tax\Model\Calculation\Rate\Converter
+ * @var Converter
*/
protected $_taxRateConverter;
/**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\Data\FormFactory $formFactory
- * @param \Magento\Directory\Model\RegionFactory $regionFactory
- * @param \Magento\Directory\Model\Config\Source\Country $country
- * @param \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory $fieldsetFactory
- * @param \Magento\Tax\Helper\Data $taxData
- * @param \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository
- * @param \Magento\Tax\Model\TaxRateCollection $taxRateCollection
- * @param \Magento\Tax\Model\Calculation\Rate\Converter $taxRateConverter
+ * @param Context $context
+ * @param Registry $registry
+ * @param FormFactory $formFactory
+ * @param RegionFactory $regionFactory
+ * @param Country $country
+ * @param FieldsetFactory $fieldsetFactory
+ * @param TaxHelper $taxData
+ * @param TaxRateRepositoryInterface $taxRateRepository
+ * @param TaxRateCollection $taxRateCollection
+ * @param Converter $taxRateConverter
* @param array $data
* @param DirectoryHelper|null $directoryHelper
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\Data\FormFactory $formFactory,
- \Magento\Directory\Model\RegionFactory $regionFactory,
- \Magento\Directory\Model\Config\Source\Country $country,
- \Magento\Tax\Block\Adminhtml\Rate\Title\FieldsetFactory $fieldsetFactory,
- \Magento\Tax\Helper\Data $taxData,
- \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository,
- \Magento\Tax\Model\TaxRateCollection $taxRateCollection,
- \Magento\Tax\Model\Calculation\Rate\Converter $taxRateConverter,
+ Context $context,
+ Registry $registry,
+ FormFactory $formFactory,
+ RegionFactory $regionFactory,
+ Country $country,
+ FieldsetFactory $fieldsetFactory,
+ TaxHelper $taxData,
+ TaxRateRepositoryInterface $taxRateRepository,
+ TaxRateCollection $taxRateCollection,
+ Converter $taxRateConverter,
array $data = [],
?DirectoryHelper $directoryHelper = null
) {
@@ -156,7 +171,7 @@ protected function _prepareForm()
$formData['tax_postcode'] = $formData['zip_from'] . '-' . $formData['zip_to'];
}
- /** @var \Magento\Framework\Data\Form $form */
+ /** @var FormData $form */
$form = $this->_formFactory->create();
$countries = $this->_country->toOptionArray(false, 'US');
@@ -164,15 +179,15 @@ protected function _prepareForm()
if (!isset($formData['tax_country_id'])) {
$formData['tax_country_id'] = $this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_COUNTRY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ Config::CONFIG_XML_PATH_DEFAULT_COUNTRY,
+ ScopeInterface::SCOPE_STORE
);
}
if (!isset($formData['tax_region_id'])) {
$formData['tax_region_id'] = $this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_REGION,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ Config::CONFIG_XML_PATH_DEFAULT_REGION,
+ ScopeInterface::SCOPE_STORE
);
}
@@ -226,8 +241,8 @@ protected function _prepareForm()
if (!isset($formData['tax_postcode'])) {
$formData['tax_postcode'] = $this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_POSTCODE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ Config::CONFIG_XML_PATH_DEFAULT_POSTCODE,
+ ScopeInterface::SCOPE_STORE
);
}
@@ -313,7 +328,7 @@ protected function _prepareForm()
$this->setChild(
'form_after',
$this->getLayout()->createBlock(
- \Magento\Framework\View\Element\Template::class
+ Template::class
)->setTemplate('Magento_Tax::rate/js.phtml')
);
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php
index 33ad7539be4bf..1b92ac60260bf 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Grid/Renderer/Data.php
@@ -11,6 +11,8 @@
*/
namespace Magento\Tax\Block\Adminhtml\Rate\Grid\Renderer;
-class Data extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
+use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
+
+class Data extends AbstractRenderer
{
}
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php
index 9612b57f8d5d8..078cb7e9b6170 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title.php
@@ -6,6 +6,11 @@
namespace Magento\Tax\Block\Adminhtml\Rate;
+use Magento\Framework\Registry;
+use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Store\Model\StoreFactory;
+use Magento\Tax\Api\TaxRateRepositoryInterface;
use Magento\Tax\Controller\RegistryConstants;
/**
@@ -13,7 +18,7 @@
*
* @author Magento Core Team
*/
-class Title extends \Magento\Framework\View\Element\Template
+class Title extends Template
{
/**
* @var array
@@ -26,34 +31,34 @@ class Title extends \Magento\Framework\View\Element\Template
protected $_template = 'Magento_Tax::rate/title.phtml';
/**
- * @var \Magento\Store\Model\StoreFactory
+ * @var StoreFactory
*/
protected $_storeFactory;
/**
- * @var \Magento\Framework\Registry
+ * @var Registry
*/
protected $_coreRegistry;
/**
- * @var \Magento\Tax\Api\TaxRateRepositoryInterface
+ * @var TaxRateRepositoryInterface
*/
protected $_taxRateRepository;
/**
* Initialize dependencies
*
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Store\Model\StoreFactory $storeFactory
- * @param \Magento\Framework\Registry $coreRegistry
- * @param \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository
+ * @param Context $context
+ * @param StoreFactory $storeFactory
+ * @param Registry $coreRegistry
+ * @param TaxRateRepositoryInterface $taxRateRepository
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Store\Model\StoreFactory $storeFactory,
- \Magento\Framework\Registry $coreRegistry,
- \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository,
+ Context $context,
+ StoreFactory $storeFactory,
+ Registry $coreRegistry,
+ TaxRateRepositoryInterface $taxRateRepository,
array $data = []
) {
$this->_coreRegistry = $coreRegistry;
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php
index 36e90804b1377..857a05e3d6c80 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Title/Fieldset.php
@@ -11,25 +11,31 @@
*/
namespace Magento\Tax\Block\Adminhtml\Rate\Title;
-class Fieldset extends \Magento\Framework\Data\Form\Element\Fieldset
+use Magento\Framework\Data\Form\Element\CollectionFactory;
+use Magento\Framework\Data\Form\Element\Factory;
+use Magento\Framework\Data\Form\Element\Fieldset as FormElementFieldset;
+use Magento\Framework\Escaper;
+use Magento\Tax\Block\Adminhtml\Rate\Title;
+
+class Fieldset extends FormElementFieldset
{
/**
- * @var \Magento\Tax\Block\Adminhtml\Rate\Title
+ * @var Title
*/
protected $_title;
/**
- * @param \Magento\Framework\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Framework\Escaper $escaper
- * @param \Magento\Tax\Block\Adminhtml\Rate\Title $title
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
+ * @param Title $title
* @param array $data
*/
public function __construct(
- \Magento\Framework\Data\Form\Element\Factory $factoryElement,
- \Magento\Framework\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Framework\Escaper $escaper,
- \Magento\Tax\Block\Adminhtml\Rate\Title $title,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
+ Title $title,
$data = []
) {
$this->_title = $title;
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php
index 16d828542c5b9..bbcf523c377b1 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Add.php
@@ -11,11 +11,18 @@
*/
namespace Magento\Tax\Block\Adminhtml\Rate\Toolbar;
+use Magento\Backend\Block\Template;
+use Magento\Backend\Block\Template\Context;
+use Magento\Backend\Block\Widget\Button\ButtonList;
+use Magento\Backend\Block\Widget\Button\Item;
+use Magento\Backend\Block\Widget\Button\ToolbarInterface;
+use Magento\Backend\Block\Widget\ContainerInterface;
+
/**
* @api
* @since 100.0.2
*/
-class Add extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\ContainerInterface
+class Add extends Template implements ContainerInterface
{
/**
* @var string
@@ -23,29 +30,17 @@ class Add extends \Magento\Backend\Block\Template implements \Magento\Backend\Bl
protected $_template = 'Magento_Tax::toolbar/rate/add.phtml';
/**
- * @var \Magento\Backend\Block\Widget\Button\ButtonList
- */
- protected $buttonList;
-
- /**
- * @var \Magento\Backend\Block\Widget\Button\ToolbarInterface
- */
- protected $toolbar;
-
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Backend\Block\Widget\Button\ButtonList $buttonList
- * @param \Magento\Backend\Block\Widget\Button\ToolbarInterface $toolbar
+ * @param Context $context
+ * @param ButtonList $buttonList
+ * @param ToolbarInterface $toolbar
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Backend\Block\Widget\Button\ButtonList $buttonList,
- \Magento\Backend\Block\Widget\Button\ToolbarInterface $toolbar,
+ Context $context,
+ protected readonly ButtonList $buttonList,
+ protected readonly ToolbarInterface $toolbar,
array $data = []
) {
- $this->buttonList = $buttonList;
- $this->toolbar = $toolbar;
parent::__construct($context, $data);
}
@@ -97,7 +92,7 @@ public function updateButton($buttonId, $key, $data)
/**
* {$@inheritdoc}
*/
- public function canRender(\Magento\Backend\Block\Widget\Button\Item $item)
+ public function canRender(Item $item)
{
return !$item->isDeleted();
}
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php
index 8ba846dc710b2..d18b9e4fab1db 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rate/Toolbar/Save.php
@@ -11,10 +11,17 @@
*/
namespace Magento\Tax\Block\Adminhtml\Rate\Toolbar;
+use Magento\Backend\Block\Template;
+use Magento\Backend\Block\Template\Context;
+use Magento\Backend\Block\Widget\Button\ButtonList;
+use Magento\Backend\Block\Widget\Button\Item;
+use Magento\Backend\Block\Widget\Button\ToolbarInterface;
+use Magento\Backend\Block\Widget\ContainerInterface;
+
/**
* Rate toolbar block
*/
-class Save extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\ContainerInterface
+class Save extends Template implements ContainerInterface
{
/**
* @var string
@@ -22,29 +29,17 @@ class Save extends \Magento\Backend\Block\Template implements \Magento\Backend\B
protected $_template = 'Magento_Tax::toolbar/rate/save.phtml';
/**
- * @var \Magento\Backend\Block\Widget\Button\ButtonList
- */
- protected $buttonList;
-
- /**
- * @var \Magento\Backend\Block\Widget\Button\ToolbarInterface
- */
- protected $toolbar;
-
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Backend\Block\Widget\Button\ButtonList $buttonList
- * @param \Magento\Backend\Block\Widget\Button\ToolbarInterface $toolbar
+ * @param Context $context
+ * @param ButtonList $buttonList
+ * @param ToolbarInterface $toolbar
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Backend\Block\Widget\Button\ButtonList $buttonList,
- \Magento\Backend\Block\Widget\Button\ToolbarInterface $toolbar,
+ Context $context,
+ protected readonly ButtonList $buttonList,
+ protected readonly ToolbarInterface $toolbar,
array $data = []
) {
- $this->buttonList = $buttonList;
- $this->toolbar = $toolbar;
parent::__construct($context, $data);
}
@@ -156,10 +151,10 @@ protected function _prepareLayout()
/**
* Check whether button rendering is allowed in current context
*
- * @param \Magento\Backend\Block\Widget\Button\Item $item
+ * @param Item $item
* @return bool
*/
- public function canRender(\Magento\Backend\Block\Widget\Button\Item $item)
+ public function canRender(Item $item)
{
return !$item->isDeleted();
}
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rule.php b/app/code/Magento/Tax/Block/Adminhtml/Rule.php
index fefb90bf11e2d..05112b615d2f2 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rule.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rule.php
@@ -11,11 +11,13 @@
*/
namespace Magento\Tax\Block\Adminhtml;
+use Magento\Backend\Block\Widget\Grid\Container;
+
/**
* @api
* @since 100.0.2
*/
-class Rule extends \Magento\Backend\Block\Widget\Grid\Container
+class Rule extends Container
{
/**
* @return void
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php
index a403ebaeb6a02..c6d4db99b0828 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit.php
@@ -9,27 +9,31 @@
*/
namespace Magento\Tax\Block\Adminhtml\Rule;
+use Magento\Backend\Block\Widget\Context;
+use Magento\Backend\Block\Widget\Form\Container;
+use Magento\Framework\Registry;
+
/**
* @api
* @since 100.0.2
*/
-class Edit extends \Magento\Backend\Block\Widget\Form\Container
+class Edit extends Container
{
/**
* Core registry
*
- * @var \Magento\Framework\Registry
+ * @var Registry
*/
protected $_coreRegistry = null;
/**
- * @param \Magento\Backend\Block\Widget\Context $context
- * @param \Magento\Framework\Registry $registry
+ * @param Context $context
+ * @param Registry $registry
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Widget\Context $context,
- \Magento\Framework\Registry $registry,
+ Context $context,
+ Registry $registry,
array $data = []
) {
$this->_coreRegistry = $registry;
diff --git a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php
index f1b11e3a31c9e..90ee08cf3f8cf 100644
--- a/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php
+++ b/app/code/Magento/Tax/Block/Adminhtml/Rule/Edit/Form.php
@@ -9,72 +9,55 @@
*/
namespace Magento\Tax\Block\Adminhtml\Rule\Edit;
+use Magento\Backend\Block\Template\Context;
+use Magento\Backend\Block\Widget\Form\Generic;
+use Magento\Framework\Data\Form as FormData;
+use Magento\Framework\Data\Form\FormKey;
+use Magento\Framework\Data\FormFactory;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Registry;
+use Magento\Tax\Api\Data\TaxRuleInterface;
use Magento\Tax\Api\TaxClassManagementInterface;
+use Magento\Tax\Api\TaxClassRepositoryInterface;
+use Magento\Tax\Api\TaxRuleRepositoryInterface;
+use Magento\Tax\Model\Rate\Source;
+use Magento\Tax\Model\TaxClass\Source\Customer;
+use Magento\Tax\Model\TaxClass\Source\Product;
/**
* @api
* @since 100.0.2
*/
-class Form extends \Magento\Backend\Block\Widget\Form\Generic
+class Form extends Generic
{
/**
- * @var \Magento\Tax\Model\Rate\Source
- */
- protected $rateSource;
-
- /**
- * @var \Magento\Framework\Data\Form\FormKey
+ * @var FormKey
*/
protected $formKey;
/**
- * @var \Magento\Tax\Api\TaxRuleRepositoryInterface
- */
- protected $ruleService;
-
- /**
- * @var \Magento\Tax\Api\TaxClassRepositoryInterface
- */
- protected $taxClassService;
-
- /**
- * @var \Magento\Tax\Model\TaxClass\Source\Customer
- */
- protected $customerTaxClassSource;
-
- /**
- * @var \Magento\Tax\Model\TaxClass\Source\Product
- */
- protected $productTaxClassSource;
-
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\Data\FormFactory $formFactory
- * @param \Magento\Tax\Model\Rate\Source $rateSource
- * @param \Magento\Tax\Api\TaxRuleRepositoryInterface $ruleService
- * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService
- * @param \Magento\Tax\Model\TaxClass\Source\Customer $customerTaxClassSource
- * @param \Magento\Tax\Model\TaxClass\Source\Product $productTaxClassSource
+ * @param Context $context
+ * @param Registry $registry
+ * @param FormFactory $formFactory
+ * @param Source $rateSource
+ * @param TaxRuleRepositoryInterface $ruleService
+ * @param TaxClassRepositoryInterface $taxClassService
+ * @param Customer $customerTaxClassSource
+ * @param Product $productTaxClassSource
* @param array $data
*/
public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\Data\FormFactory $formFactory,
- \Magento\Tax\Model\Rate\Source $rateSource,
- \Magento\Tax\Api\TaxRuleRepositoryInterface $ruleService,
- \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService,
- \Magento\Tax\Model\TaxClass\Source\Customer $customerTaxClassSource,
- \Magento\Tax\Model\TaxClass\Source\Product $productTaxClassSource,
+ Context $context,
+ Registry $registry,
+ FormFactory $formFactory,
+ protected readonly Source $rateSource,
+ protected readonly TaxRuleRepositoryInterface $ruleService,
+ protected readonly TaxClassRepositoryInterface $taxClassService,
+ protected readonly Customer $customerTaxClassSource,
+ protected readonly Product $productTaxClassSource,
array $data = []
) {
- $this->rateSource = $rateSource;
$this->formKey = $context->getFormKey();
- $this->ruleService = $ruleService;
- $this->taxClassService = $taxClassService;
- $this->customerTaxClassSource = $customerTaxClassSource;
- $this->productTaxClassSource = $productTaxClassSource;
parent::__construct($context, $registry, $formFactory, $data);
}
@@ -103,10 +86,10 @@ protected function _prepareForm()
$taxRuleId = $this->_coreRegistry->registry('tax_rule_id');
try {
$taxRule = $this->ruleService->get($taxRuleId);
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ } catch (NoSuchEntityException $e) {
/** Tax rule not found */
}
- /** @var \Magento\Framework\Data\Form $form */
+ /** @var FormData $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
);
@@ -343,7 +326,7 @@ public function getTaxRatesPageUrl()
/**
* Extract tax rule data in a format which is
*
- * @param \Magento\Tax\Api\Data\TaxRuleInterface $taxRule
+ * @param TaxRuleInterface $taxRule
* @return array
*/
protected function extractTaxRuleData($taxRule)
diff --git a/app/code/Magento/Tax/Block/Checkout/Discount.php b/app/code/Magento/Tax/Block/Checkout/Discount.php
index 70dac7c96c5ef..8ee78529a167b 100644
--- a/app/code/Magento/Tax/Block/Checkout/Discount.php
+++ b/app/code/Magento/Tax/Block/Checkout/Discount.php
@@ -5,33 +5,38 @@
*/
namespace Magento\Tax\Block\Checkout;
+use Magento\Checkout\Block\Total\DefaultTotal;
+use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Customer\Model\Session as CustomerSession;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\ConfigInterface;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Subtotal Total Row Renderer
*/
-class Discount extends \Magento\Checkout\Block\Total\DefaultTotal
+class Discount extends DefaultTotal
{
/**
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_taxConfig;
/**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param Context $context
+ * @param CustomerSession $customerSession
+ * @param CheckoutSession $checkoutSession
* @param ConfigInterface $salesConfig
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxConfig $taxConfig
* @param array $layoutProcessors
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Checkout\Model\Session $checkoutSession,
+ Context $context,
+ CustomerSession $customerSession,
+ CheckoutSession $checkoutSession,
ConfigInterface $salesConfig,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxConfig $taxConfig,
array $layoutProcessors = [],
array $data = []
) {
diff --git a/app/code/Magento/Tax/Block/Checkout/Grandtotal.php b/app/code/Magento/Tax/Block/Checkout/Grandtotal.php
index 607eef2f3bcdf..8c74270d82d43 100644
--- a/app/code/Magento/Tax/Block/Checkout/Grandtotal.php
+++ b/app/code/Magento/Tax/Block/Checkout/Grandtotal.php
@@ -5,12 +5,17 @@
*/
namespace Magento\Tax\Block\Checkout;
+use Magento\Checkout\Block\Total\DefaultTotal;
+use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Customer\Model\Session as CustomerSession;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\ConfigInterface;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Subtotal Total Row Renderer
*/
-class Grandtotal extends \Magento\Checkout\Block\Total\DefaultTotal
+class Grandtotal extends DefaultTotal
{
/**
* Path to template file
@@ -20,25 +25,25 @@ class Grandtotal extends \Magento\Checkout\Block\Total\DefaultTotal
protected $_template = 'Magento_Tax::checkout/grandtotal.phtml';
/**
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_taxConfig;
/**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param Context $context
+ * @param CustomerSession $customerSession
+ * @param CheckoutSession $checkoutSession
* @param ConfigInterface $salesConfig
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxConfig $taxConfig
* @param array $layoutProcessors
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Checkout\Model\Session $checkoutSession,
+ Context $context,
+ CustomerSession $customerSession,
+ CheckoutSession $checkoutSession,
ConfigInterface $salesConfig,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxConfig $taxConfig,
array $layoutProcessors = [],
array $data = []
) {
diff --git a/app/code/Magento/Tax/Block/Checkout/Shipping.php b/app/code/Magento/Tax/Block/Checkout/Shipping.php
index 45c6e42574770..7e9ca92824cec 100644
--- a/app/code/Magento/Tax/Block/Checkout/Shipping.php
+++ b/app/code/Magento/Tax/Block/Checkout/Shipping.php
@@ -5,12 +5,18 @@
*/
namespace Magento\Tax\Block\Checkout;
+use Magento\Checkout\Block\Total\DefaultTotal;
+use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Customer\Model\Session as CustomerSession;
+use Magento\Framework\Phrase;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\ConfigInterface;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Subtotal Total Row Renderer
*/
-class Shipping extends \Magento\Checkout\Block\Total\DefaultTotal
+class Shipping extends DefaultTotal
{
/**
* Template path
@@ -20,25 +26,25 @@ class Shipping extends \Magento\Checkout\Block\Total\DefaultTotal
protected $_template = 'Magento_Tax::checkout/shipping.phtml';
/**
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_taxConfig;
/**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param Context $context
+ * @param CustomerSession $customerSession
+ * @param CheckoutSession $checkoutSession
* @param ConfigInterface $salesConfig
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxConfig $taxConfig
* @param array $layoutProcessors
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Checkout\Model\Session $checkoutSession,
+ Context $context,
+ CustomerSession $customerSession,
+ CheckoutSession $checkoutSession,
ConfigInterface $salesConfig,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxConfig $taxConfig,
array $layoutProcessors = [],
array $data = []
) {
@@ -90,7 +96,7 @@ public function getShippingExcludeTax()
/**
* Get label for shipping include tax
*
- * @return \Magento\Framework\Phrase
+ * @return Phrase
*/
public function getIncludeTaxLabel()
{
@@ -103,7 +109,7 @@ public function getIncludeTaxLabel()
/**
* Get label for shipping exclude tax
*
- * @return \Magento\Framework\Phrase
+ * @return Phrase
*/
public function getExcludeTaxLabel()
{
diff --git a/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php b/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php
index 3678e5fa7c22a..2f4290e436e7f 100644
--- a/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php
+++ b/app/code/Magento/Tax/Block/Checkout/Shipping/Price.php
@@ -5,36 +5,35 @@
*/
namespace Magento\Tax\Block\Checkout\Shipping;
+use Magento\Checkout\Block\Shipping\Price as ShippingPrice;
+use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Tax\Helper\Data as TaxHelper;
/**
* Class Price
* @deprecated 100.1.0
*/
-class Price extends \Magento\Checkout\Block\Shipping\Price
+class Price extends ShippingPrice
{
/**
- * @var \Magento\Tax\Helper\Data
- */
- protected $taxHelper;
-
- /**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param Context $context
+ * @param CustomerSession $customerSession
+ * @param CheckoutSession $checkoutSession
* @param PriceCurrencyInterface $priceCurrency
- * @param \Magento\Tax\Helper\Data $taxHelper
+ * @param TaxHelper $taxHelper
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Checkout\Model\Session $checkoutSession,
+ Context $context,
+ CustomerSession $customerSession,
+ CheckoutSession $checkoutSession,
PriceCurrencyInterface $priceCurrency,
- \Magento\Tax\Helper\Data $taxHelper,
+ protected readonly TaxHelper $taxHelper,
array $data = []
) {
- $this->taxHelper = $taxHelper;
parent::__construct(
$context,
$customerSession,
diff --git a/app/code/Magento/Tax/Block/Checkout/Subtotal.php b/app/code/Magento/Tax/Block/Checkout/Subtotal.php
index 23f9223ba51f3..e961908833a64 100644
--- a/app/code/Magento/Tax/Block/Checkout/Subtotal.php
+++ b/app/code/Magento/Tax/Block/Checkout/Subtotal.php
@@ -5,12 +5,17 @@
*/
namespace Magento\Tax\Block\Checkout;
+use Magento\Checkout\Block\Total\DefaultTotal;
+use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Customer\Model\Session as CustomerSession;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\ConfigInterface;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Subtotal Total Row Renderer
*/
-class Subtotal extends \Magento\Checkout\Block\Total\DefaultTotal
+class Subtotal extends DefaultTotal
{
/**
* Template path
@@ -20,25 +25,25 @@ class Subtotal extends \Magento\Checkout\Block\Total\DefaultTotal
protected $_template = 'Magento_Tax::checkout/subtotal.phtml';
/**
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_taxConfig;
/**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param Context $context
+ * @param CustomerSession $customerSession
+ * @param CheckoutSession $checkoutSession
* @param ConfigInterface $salesConfig
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxConfig $taxConfig
* @param array $layoutProcessors
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Checkout\Model\Session $checkoutSession,
+ Context $context,
+ CustomerSession $customerSession,
+ CheckoutSession $checkoutSession,
ConfigInterface $salesConfig,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxConfig $taxConfig,
array $layoutProcessors = [],
array $data = []
) {
diff --git a/app/code/Magento/Tax/Block/Checkout/Tax.php b/app/code/Magento/Tax/Block/Checkout/Tax.php
index a53db42be2ad6..82fcd44ac3c45 100644
--- a/app/code/Magento/Tax/Block/Checkout/Tax.php
+++ b/app/code/Magento/Tax/Block/Checkout/Tax.php
@@ -9,20 +9,24 @@
*/
namespace Magento\Tax\Block\Checkout;
+use Magento\Checkout\Block\Total\DefaultTotal;
use Magento\Checkout\Helper\Data as CheckoutHelper;
+use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Tax\Helper\Data as TaxHelper;
use Magento\Sales\Model\ConfigInterface;
/**
* Class for manage tax amount.
*/
-class Tax extends \Magento\Checkout\Block\Total\DefaultTotal
+class Tax extends DefaultTotal
{
/**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param Context $context
+ * @param CustomerSession $customerSession
+ * @param CheckoutSession $checkoutSession
* @param ConfigInterface $salesConfig
* @param array $layoutProcessors
* @param array $data
@@ -30,9 +34,9 @@ class Tax extends \Magento\Checkout\Block\Total\DefaultTotal
* @param TaxHelper|null $taxHelper
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Checkout\Model\Session $checkoutSession,
+ Context $context,
+ CustomerSession $customerSession,
+ CheckoutSession $checkoutSession,
ConfigInterface $salesConfig,
array $layoutProcessors = [],
array $data = [],
diff --git a/app/code/Magento/Tax/Block/Grid/Renderer/Codes.php b/app/code/Magento/Tax/Block/Grid/Renderer/Codes.php
index 6c4e754f7e316..fccb78710a38c 100644
--- a/app/code/Magento/Tax/Block/Grid/Renderer/Codes.php
+++ b/app/code/Magento/Tax/Block/Grid/Renderer/Codes.php
@@ -5,18 +5,21 @@
*/
namespace Magento\Tax\Block\Grid\Renderer;
+use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
+use Magento\Framework\DataObject;
+
/**
* Provides tax rates codes for each tax rule in the grid.
*/
-class Codes extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
+class Codes extends AbstractRenderer
{
/**
* Renders rates codes grid column
*
- * @param \Magento\Framework\DataObject $row
+ * @param DataObject $row
* @return string
*/
- public function render(\Magento\Framework\DataObject $row)
+ public function render(DataObject $row)
{
$ratesCodes = $row->getTaxRatesCodes();
diff --git a/app/code/Magento/Tax/Block/Item/Price/Renderer.php b/app/code/Magento/Tax/Block/Item/Price/Renderer.php
index caefd2661853d..ca44ee7df09fe 100644
--- a/app/code/Magento/Tax/Block/Item/Price/Renderer.php
+++ b/app/code/Magento/Tax/Block/Item/Price/Renderer.php
@@ -7,6 +7,7 @@
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Pricing\Render as PricingRender;
+use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Quote\Model\Quote\Item\AbstractItem as QuoteItem;
use Magento\Sales\Model\Order\CreditMemo\Item as CreditMemoItem;
@@ -21,13 +22,8 @@
* @author Magento Core Team
* @since 100.0.2
*/
-class Renderer extends \Magento\Framework\View\Element\Template
+class Renderer extends Template
{
- /**
- * @var \Magento\Tax\Helper\Data
- */
- protected $taxHelper;
-
/**
* @var QuoteItem|OrderItem|InvoiceItem|CreditMemoItem
*/
@@ -45,11 +41,6 @@ class Renderer extends \Magento\Framework\View\Element\Template
*/
protected $zone = null;
- /**
- * @var PriceCurrencyInterface
- */
- protected $priceCurrency;
-
/**
* @param Context $context
* @param TaxHelper $taxHelper
@@ -58,12 +49,10 @@ class Renderer extends \Magento\Framework\View\Element\Template
*/
public function __construct(
Context $context,
- TaxHelper $taxHelper,
- PriceCurrencyInterface $priceCurrency,
+ protected readonly TaxHelper $taxHelper,
+ protected readonly PriceCurrencyInterface $priceCurrency,
array $data = []
) {
- $this->priceCurrency = $priceCurrency;
- $this->taxHelper = $taxHelper;
if (isset($data['zone'])) {
$this->zone = $data['zone'];
}
diff --git a/app/code/Magento/Tax/Block/Sales/Order/Tax.php b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
index a08a07260e8c9..0d300b0083a56 100644
--- a/app/code/Magento/Tax/Block/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
@@ -9,7 +9,14 @@
*/
namespace Magento\Tax\Block\Sales\Order;
+use Magento\Framework\DataObject;
+use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Sales\Block\Adminhtml\Order\Invoice\Totals as InvoiceTotals;
+use Magento\Sales\Block\Order\Totals as OrderTotals;
use Magento\Sales\Model\Order;
+use Magento\Store\Model\Store;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Tax totals modification block.
@@ -17,12 +24,12 @@
* @api
* @since 100.0.2
*/
-class Tax extends \Magento\Framework\View\Element\Template
+class Tax extends Template
{
/**
* Tax configuration model
*
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_config;
@@ -32,18 +39,18 @@ class Tax extends \Magento\Framework\View\Element\Template
protected $_order;
/**
- * @var \Magento\Framework\DataObject
+ * @var DataObject
*/
protected $_source;
/**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param Context $context
+ * @param TaxConfig $taxConfig
* @param array $data
*/
public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Tax\Model\Config $taxConfig,
+ Context $context,
+ TaxConfig $taxConfig,
array $data = []
) {
$this->_config = $taxConfig;
@@ -63,7 +70,7 @@ public function displayFullSummary()
/**
* Get data (totals) source model
*
- * @return \Magento\Framework\DataObject
+ * @return DataObject
*/
public function getSource()
{
@@ -73,11 +80,11 @@ public function getSource()
/**
* Initialize all order totals relates with tax
*
- * @return \Magento\Tax\Block\Sales\Order\Tax
+ * @return Tax
*/
public function initTotals()
{
- /** @var $parent \Magento\Sales\Block\Adminhtml\Order\Invoice\Totals */
+ /** @var InvoiceTotals $parent */
$parent = $this->getParentBlock();
$this->_order = $parent->getOrder();
$this->_source = $parent->getSource();
@@ -100,11 +107,11 @@ public function initTotals()
* Add tax total string
*
* @param string $after
- * @return \Magento\Tax\Block\Sales\Order\Tax
+ * @return Tax
*/
protected function _addTax($after = 'discount')
{
- $taxTotal = new \Magento\Framework\DataObject(['code' => 'tax', 'block_name' => $this->getNameInLayout()]);
+ $taxTotal = new DataObject(['code' => 'tax', 'block_name' => $this->getNameInLayout()]);
$totals = $this->getParentBlock()->getTotals();
if (isset($totals['grand_total_incl'])) {
$this->getParentBlock()->addTotal($taxTotal, 'grand_total');
@@ -116,7 +123,7 @@ protected function _addTax($after = 'discount')
/**
* Get order store object
*
- * @return \Magento\Store\Model\Store
+ * @return Store
*/
public function getStore()
{
@@ -163,7 +170,7 @@ protected function _initSubtotal()
$subtotalIncl = max(0, $subtotalIncl);
$baseSubtotalIncl = max(0, $baseSubtotalIncl);
- $totalExcl = new \Magento\Framework\DataObject(
+ $totalExcl = new DataObject(
[
'code' => 'subtotal_excl',
'value' => $subtotal,
@@ -171,7 +178,7 @@ protected function _initSubtotal()
'label' => __('Subtotal (Excl.Tax)'),
]
);
- $totalIncl = new \Magento\Framework\DataObject(
+ $totalIncl = new DataObject(
[
'code' => 'subtotal_incl',
'value' => $subtotalIncl,
@@ -214,7 +221,7 @@ protected function _initSubtotal()
protected function _initShipping()
{
$store = $this->_order->getStore();
- /** @var \Magento\Sales\Block\Order\Totals $parent */
+ /** @var OrderTotals $parent */
$parent = $this->getParentBlock();
$shipping = $parent->getTotal('shipping');
if (!$shipping) {
@@ -235,7 +242,7 @@ protected function _initShipping()
$couponDescription = $this->getCouponDescription();
- $totalExcl = new \Magento\Framework\DataObject(
+ $totalExcl = new DataObject(
[
'code' => 'shipping',
'value' => $shipping,
@@ -243,7 +250,7 @@ protected function _initShipping()
'label' => __('Shipping & Handling (Excl.Tax)') . $couponDescription,
]
);
- $totalIncl = new \Magento\Framework\DataObject(
+ $totalIncl = new DataObject(
[
'code' => 'shipping_incl',
'value' => $shippingIncl,
@@ -304,7 +311,7 @@ protected function _initGrandTotal()
$baseGrandtotalExcl = $baseGrandtotal - $this->_source->getBaseTaxAmount();
$grandtotalExcl = max($grandtotalExcl, 0);
$baseGrandtotalExcl = max($baseGrandtotalExcl, 0);
- $totalExcl = new \Magento\Framework\DataObject(
+ $totalExcl = new DataObject(
[
'code' => 'grand_total',
'strong' => true,
@@ -313,7 +320,7 @@ protected function _initGrandTotal()
'label' => __('Grand Total (Excl.Tax)'),
]
);
- $totalIncl = new \Magento\Framework\DataObject(
+ $totalIncl = new DataObject(
[
'code' => 'grand_total_incl',
'strong' => true,
@@ -368,7 +375,7 @@ private function getCouponDescription(): string
{
$couponDescription = "";
- /** @var \Magento\Sales\Block\Order\Totals $parent */
+ /** @var OrderTotals $parent */
$parent = $this->getParentBlock();
$couponCode = $parent->getSource()
->getCouponCode();
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php
index b3add8ffab551..1e2a9b7cddc53 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate.php
@@ -6,14 +6,20 @@
namespace Magento\Tax\Controller\Adminhtml;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Registry;
+use Magento\Tax\Api\TaxRateRepositoryInterface;
+use Magento\Tax\Model\Calculation\Rate\Converter;
/**
* Adminhtml tax rate controller
*
* @author Magento Core Team
*/
-abstract class Rate extends \Magento\Backend\App\Action
+abstract class Rate extends Action
{
/**
* Authorization level of a basic admin session
@@ -23,31 +29,31 @@ abstract class Rate extends \Magento\Backend\App\Action
public const ADMIN_RESOURCE = 'Magento_Tax::manage_tax';
/**
- * @var \Magento\Framework\Registry
+ * @var Registry
*/
protected $_coreRegistry;
/**
- * @var \Magento\Tax\Model\Calculation\Rate\Converter
+ * @var Converter
*/
protected $_taxRateConverter;
/**
- * @var \Magento\Tax\Api\TaxRateRepositoryInterface
+ * @var TaxRateRepositoryInterface
*/
protected $_taxRateRepository;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\Registry $coreRegistry
- * @param \Magento\Tax\Model\Calculation\Rate\Converter $taxRateConverter
- * @param \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository
+ * @param Context $context
+ * @param Registry $coreRegistry
+ * @param Converter $taxRateConverter
+ * @param TaxRateRepositoryInterface $taxRateRepository
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\Registry $coreRegistry,
- \Magento\Tax\Model\Calculation\Rate\Converter $taxRateConverter,
- \Magento\Tax\Api\TaxRateRepositoryInterface $taxRateRepository
+ Context $context,
+ Registry $coreRegistry,
+ Converter $taxRateConverter,
+ TaxRateRepositoryInterface $taxRateRepository
) {
$this->_coreRegistry = $coreRegistry;
$this->_taxRateConverter = $taxRateConverter;
@@ -77,7 +83,7 @@ protected function _processRateData($rateData)
/**
* Initialize action
*
- * @return \Magento\Backend\Model\View\Result\Page
+ * @return ResultPage
*/
protected function initResultPage()
{
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Add.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Add.php
index 7e70d5ef50daf..ffaca0d5ed272 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Add.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Add.php
@@ -6,27 +6,32 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Magento\Backend\Model\Session;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
+use Magento\Tax\Block\Adminhtml\Rate\Form;
+use Magento\Tax\Block\Adminhtml\Rate\Toolbar\Save as ToolbarSave;
+use Magento\Tax\Controller\Adminhtml\Rate;
use Magento\Tax\Controller\RegistryConstants;
-class Add extends \Magento\Tax\Controller\Adminhtml\Rate
+class Add extends Rate
{
/**
* Show Add Form
*
- * @return \Magento\Backend\Model\View\Result\Page
+ * @return ResultPage
*/
public function execute()
{
$this->_coreRegistry->register(
RegistryConstants::CURRENT_TAX_RATE_FORM_DATA,
- $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getFormData(true)
+ $this->_objectManager->get(Session::class)->getFormData(true)
);
$resultPage = $this->initResultPage();
$layout = $resultPage->getLayout();
- $toolbarSaveBlock = $layout->createBlock(\Magento\Tax\Block\Adminhtml\Rate\Toolbar\Save::class)
+ $toolbarSaveBlock = $layout->createBlock(ToolbarSave::class)
->assign('header', __('Add New Tax Rate'))
- ->assign('form', $layout->createBlock(\Magento\Tax\Block\Adminhtml\Rate\Form::class, 'tax_rate_form'));
+ ->assign('form', $layout->createBlock(Form::class, 'tax_rate_form'));
$resultPage->addBreadcrumb(__('Manage Tax Rates'), __('Manage Tax Rates'), $this->getUrl('tax/rate'))
->addBreadcrumb(__('New Tax Rate'), __('New Tax Rate'))
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxDelete.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxDelete.php
index fa58389bdd72d..ddc6dc7646b8c 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxDelete.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxDelete.php
@@ -6,14 +6,18 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Exception;
+use Magento\Framework\Controller\Result\Json as ResultJson;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Tax\Controller\Adminhtml\Rate;
-class AjaxDelete extends \Magento\Tax\Controller\Adminhtml\Rate
+class AjaxDelete extends Rate
{
/**
* Delete Tax Rate via AJAX
*
- * @return \Magento\Framework\Controller\Result\Json
+ * @return ResultJson
*/
public function execute()
{
@@ -21,16 +25,16 @@ public function execute()
try {
$this->_taxRateRepository->deleteById($rateId);
$responseContent = ['success' => true, 'error_message' => ''];
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$responseContent = ['success' => false, 'error_message' => $e->getMessage()];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$responseContent = [
'success' => false,
'error_message' => __('We can\'t delete this tax rate right now.')
];
}
- /** @var \Magento\Framework\Controller\Result\Json $resultJson */
+ /** @var ResultJson $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseContent);
return $resultJson;
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxLoad.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxLoad.php
index ff610a8f0da2e..b3f4414a2aa5d 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxLoad.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxLoad.php
@@ -7,24 +7,29 @@
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Exception;
+use InvalidArgumentException;
+use Magento\Framework\Controller\Result\Json as ResultJson;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Tax\Api\Data\TaxRateInterface;
+use Magento\Tax\Controller\Adminhtml\Rate;
-class AjaxLoad extends \Magento\Tax\Controller\Adminhtml\Rate
+class AjaxLoad extends Rate
{
/**
* Json needed for the Ajax Edit Form
*
- * @return \Magento\Framework\Controller\Result\Json
- * @throws \InvalidArgumentException
+ * @return ResultJson
+ * @throws InvalidArgumentException
*/
public function execute()
{
$rateId = (int)$this->getRequest()->getParam('id');
try {
- /* @var \Magento\Tax\Api\Data\TaxRateInterface */
+ /* @var TaxRateInterface $taxRateDataObject */
$taxRateDataObject = $this->_taxRateRepository->get($rateId);
- /* @var array */
+ /* @var array $resultArray */
$resultArray = $this->_taxRateConverter->createArrayFromServiceObject($taxRateDataObject, true);
$responseContent = [
@@ -37,14 +42,14 @@ public function execute()
'success' => false,
'error_message' => $e->getMessage(),
];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$responseContent = [
'success' => false,
'error_message' => __('An error occurred while loading this tax rate.'),
];
}
- /** @var \Magento\Framework\Controller\Result\Json $resultJson */
+ /** @var ResultJson $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseContent);
return $resultJson;
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxSave.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxSave.php
index 572eaa55abbb5..2158865a68dc3 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxSave.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/AjaxSave.php
@@ -6,9 +6,15 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Exception;
+use InvalidArgumentException;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Backend\App\Action\Context;
+use Magento\Framework\Controller\Result\Json as ResultJson;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
+use Magento\Tax\Api\Data\TaxRateInterface;
+use Magento\Tax\Controller\Adminhtml\Rate;
use Magento\Tax\Model\Calculation\Rate\Converter;
use Magento\Tax\Api\TaxRateRepositoryInterface;
use Magento\Framework\Escaper;
@@ -17,13 +23,8 @@
/**
* Tax Rate AjaxSave Controller
*/
-class AjaxSave extends \Magento\Tax\Controller\Adminhtml\Rate implements HttpPostActionInterface
+class AjaxSave extends Rate implements HttpPostActionInterface
{
- /**
- * @var Escaper
- */
- private $escaper;
-
/**
* @param Context $context
* @param Registry $coreRegistry
@@ -36,23 +37,22 @@ public function __construct(
Registry $coreRegistry,
Converter $taxRateConverter,
TaxRateRepositoryInterface $taxRateRepository,
- Escaper $escaper
+ private readonly Escaper $escaper
) {
- $this->escaper = $escaper;
parent::__construct($context, $coreRegistry, $taxRateConverter, $taxRateRepository);
}
/**
* Save Tax Rate via AJAX
*
- * @return \Magento\Framework\Controller\Result\Json
- * @throws \InvalidArgumentException
+ * @return ResultJson
+ * @throws InvalidArgumentException
*/
public function execute()
{
try {
$rateData = $this->_processRateData($this->getRequest()->getPostValue());
- /** @var \Magento\Tax\Api\Data\TaxRateInterface $taxRate */
+ /** @var TaxRateInterface $taxRate */
$taxRate = $this->_taxRateConverter->populateTaxRateData($rateData);
$this->_taxRateRepository->save($taxRate);
$responseContent = [
@@ -61,14 +61,14 @@ public function execute()
'tax_calculation_rate_id' => $taxRate->getId(),
'code' => $this->escaper->escapeHtml($taxRate->getCode()),
];
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$responseContent = [
'success' => false,
'error_message' => $e->getMessage(),
'tax_calculation_rate_id' => '',
'code' => '',
];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$responseContent = [
'success' => false,
'error_message' => __('We can\'t save this rate right now.'),
@@ -77,7 +77,7 @@ public function execute()
];
}
- /** @var \Magento\Framework\Controller\Result\Json $resultJson */
+ /** @var ResultJson $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseContent);
return $resultJson;
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Delete.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Delete.php
index a77216cd3b46a..261b5da27ecd0 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Delete.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Delete.php
@@ -6,21 +6,25 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Exception;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\App\Action\HttpPostActionInterface;
+use Magento\Tax\Controller\Adminhtml\Rate;
-class Delete extends \Magento\Tax\Controller\Adminhtml\Rate implements HttpPostActionInterface
+class Delete extends Rate implements HttpPostActionInterface
{
/**
* Delete Rate and Data
*
- * @return \Magento\Backend\Model\View\Result\Redirect|void
+ * @return ResultRedirect|void
*/
public function execute()
{
if ($rateId = $this->getRequest()->getParam('rate')) {
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var ResultRedirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try {
$this->_taxRateRepository->deleteById($rateId);
@@ -32,9 +36,9 @@ public function execute()
__('We can\'t delete this rate because of an incorrect rate ID.')
);
return $resultRedirect->setPath("tax/*/");
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->messageManager->addError(__('Something went wrong deleting this rate.'));
}
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Edit.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Edit.php
index f215ef7b9d261..690c9e640f204 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Edit.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Edit.php
@@ -6,16 +6,21 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Tax\Block\Adminhtml\Rate\Form;
+use Magento\Tax\Block\Adminhtml\Rate\Toolbar\Save as ToolbarSave;
+use Magento\Tax\Controller\Adminhtml\Rate;
use Magento\Tax\Controller\RegistryConstants;
use Magento\Framework\Controller\ResultFactory;
-class Edit extends \Magento\Tax\Controller\Adminhtml\Rate
+class Edit extends Rate
{
/**
* Show Edit Form
*
- * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
+ * @return ResultPage|ResultRedirect
*/
public function execute()
{
@@ -24,7 +29,7 @@ public function execute()
try {
$taxRateDataObject = $this->_taxRateRepository->get($rateId);
} catch (NoSuchEntityException $e) {
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var ResultRedirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath("*/*/");
}
@@ -32,12 +37,12 @@ public function execute()
$resultPage = $this->initResultPage();
$layout = $resultPage->getLayout();
- $toolbarSaveBlock = $layout->createBlock(\Magento\Tax\Block\Adminhtml\Rate\Toolbar\Save::class)
+ $toolbarSaveBlock = $layout->createBlock(ToolbarSave::class)
->assign('header', __('Edit Tax Rate'))
->assign(
'form',
$layout->createBlock(
- \Magento\Tax\Block\Adminhtml\Rate\Form::class,
+ Form::class,
'tax_rate_form'
)->setShowLegend(true)
);
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php
index 565af0e0bf93b..d5730b3e04c3c 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php
@@ -6,14 +6,16 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+use Magento\Tax\Controller\Adminhtml\Rate;
-class Index extends \Magento\Tax\Controller\Adminhtml\Rate implements HttpGetActionInterface
+class Index extends Rate implements HttpGetActionInterface
{
/**
* Show Main Grid
*
- * @return \Magento\Backend\Model\View\Result\Page
+ * @return ResultPage
*/
public function execute()
{
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Save.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Save.php
index fa86fbd740446..fb9b3a29b76d8 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Save.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Save.php
@@ -6,19 +6,24 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
+use Exception;
+use Magento\Backend\Model\Session;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Tax\Controller\Adminhtml\Rate;
-class Save extends \Magento\Tax\Controller\Adminhtml\Rate
+class Save extends Rate
{
/**
* Save Rate and Data
*
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return ResultRedirect
*/
public function execute()
{
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var ResultRedirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$ratePost = $this->getRequest()->getPostValue();
if ($ratePost) {
@@ -37,10 +42,10 @@ public function execute()
$this->messageManager->addSuccess(__('You saved the tax rate.'));
return $resultRedirect->setPath('*/*/');
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
- $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData($ratePost);
+ } catch (LocalizedException $e) {
+ $this->_objectManager->get(Session::class)->setFormData($ratePost);
$this->messageManager->addError($e->getMessage());
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->messageManager->addError($e->getMessage());
}
return $resultRedirect->setUrl($this->_redirect->getRedirectUrl($this->getUrl('*')));
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule.php
index 8bb652107814a..036772e9243b6 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule.php
@@ -12,9 +12,15 @@
namespace Magento\Tax\Controller\Adminhtml;
use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Registry;
+use Magento\Tax\Api\Data\TaxRuleInterface;
+use Magento\Tax\Api\Data\TaxRuleInterfaceFactory;
+use Magento\Tax\Api\TaxRuleRepositoryInterface;
-abstract class Rule extends \Magento\Backend\App\Action
+abstract class Rule extends Action
{
/**
* Authorization level of a basic admin session
@@ -26,42 +32,30 @@ abstract class Rule extends \Magento\Backend\App\Action
/**
* Core registry
*
- * @var \Magento\Framework\Registry
+ * @var Registry
*/
protected $_coreRegistry = null;
/**
- * @var \Magento\Tax\Api\TaxRuleRepositoryInterface
- */
- protected $ruleService;
-
- /**
- * @var \Magento\Tax\Api\Data\TaxRuleInterfaceFactory
- */
- protected $taxRuleDataObjectFactory;
-
- /**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Framework\Registry $coreRegistry
- * @param \Magento\Tax\Api\TaxRuleRepositoryInterface $ruleService
- * @param \Magento\Tax\Api\Data\TaxRuleInterfaceFactory $taxRuleDataObjectFactory
+ * @param Context $context
+ * @param Registry $coreRegistry
+ * @param TaxRuleRepositoryInterface $ruleService
+ * @param TaxRuleInterfaceFactory $taxRuleDataObjectFactory
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Framework\Registry $coreRegistry,
- \Magento\Tax\Api\TaxRuleRepositoryInterface $ruleService,
- \Magento\Tax\Api\Data\TaxRuleInterfaceFactory $taxRuleDataObjectFactory
+ Context $context,
+ Registry $coreRegistry,
+ protected readonly TaxRuleRepositoryInterface $ruleService,
+ protected readonly TaxRuleInterfaceFactory $taxRuleDataObjectFactory
) {
$this->_coreRegistry = $coreRegistry;
- $this->ruleService = $ruleService;
- $this->taxRuleDataObjectFactory = $taxRuleDataObjectFactory;
parent::__construct($context);
}
/**
* Initialize action
*
- * @return \Magento\Backend\Model\View\Result\Page
+ * @return ResultPage
*/
protected function initResultPage()
{
@@ -76,7 +70,7 @@ protected function initResultPage()
* Initialize tax rule service object with form data.
*
* @param array $postData
- * @return \Magento\Tax\Api\Data\TaxRuleInterface
+ * @return TaxRuleInterface
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function populateTaxRule($postData)
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/AjaxLoadRates.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/AjaxLoadRates.php
index b93b12be40270..2a9e4c81a4e70 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/AjaxLoadRates.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/AjaxLoadRates.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Exception;
+use InvalidArgumentException;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\HttpGetActionInterface;
@@ -20,16 +22,6 @@
*/
class AjaxLoadRates extends Action implements HttpGetActionInterface
{
- /**
- * @var RatesProvider
- */
- private $ratesProvider;
-
- /**
- * @var SearchCriteriaBuilder
- */
- private $searchCriteriaBuilder;
-
/**
* @param Context $context
* @param SearchCriteriaBuilder $searchCriteriaBuilder
@@ -37,19 +29,17 @@ class AjaxLoadRates extends Action implements HttpGetActionInterface
*/
public function __construct(
Context $context,
- SearchCriteriaBuilder $searchCriteriaBuilder,
- RatesProvider $ratesProvider
+ private readonly SearchCriteriaBuilder $searchCriteriaBuilder,
+ private readonly RatesProvider $ratesProvider
) {
parent::__construct($context);
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
- $this->ratesProvider = $ratesProvider;
}
/**
* Get rates page via AJAX
*
* @return Json
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
public function execute()
{
@@ -77,7 +67,7 @@ public function execute()
'errorMessage' => '',
'result'=> $options,
];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$response = [
'success' => false,
'errorMessage' => __('An error occurred while loading tax rates.')
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php
index 1e46f0ea3d24a..0bbd1bda6fbd7 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php
@@ -6,29 +6,34 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Exception;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Tax\Controller\Adminhtml\Rule;
-class Delete extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpPostActionInterface
+class Delete extends Rule implements HttpPostActionInterface
{
/**
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return ResultRedirect
*/
public function execute()
{
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var ResultRedirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$ruleId = (int)$this->getRequest()->getParam('rule');
try {
$this->ruleService->deleteById($ruleId);
$this->messageManager->addSuccess(__('The tax rule has been deleted.'));
return $resultRedirect->setPath('tax/*/');
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ } catch (NoSuchEntityException $e) {
$this->messageManager->addError(__('This rule no longer exists.'));
return $resultRedirect->setPath('tax/*/');
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->messageManager->addError(__('Something went wrong deleting this tax rule.'));
}
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php
index 740d7e8afe62c..7f32a74393736 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php
@@ -6,28 +6,33 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Magento\Backend\Model\Session;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Tax\Controller\Adminhtml\Rule;
-class Edit extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpGetActionInterface
+class Edit extends Rule implements HttpGetActionInterface
{
/**
- * @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
+ * @return ResultPage|ResultRedirect
*/
public function execute()
{
$taxRuleId = $this->getRequest()->getParam('rule');
$this->_coreRegistry->register('tax_rule_id', $taxRuleId);
- /** @var \Magento\Backend\Model\Session $backendSession */
- $backendSession = $this->_objectManager->get(\Magento\Backend\Model\Session::class);
+ /** @var Session $backendSession */
+ $backendSession = $this->_objectManager->get(Session::class);
if ($taxRuleId) {
try {
$taxRule = $this->ruleService->get($taxRuleId);
$pageTitle = sprintf("%s", $taxRule->getCode());
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ } catch (NoSuchEntityException $e) {
$backendSession->unsRuleData();
$this->messageManager->addError(__('This rule no longer exists.'));
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var ResultRedirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath('tax/*/');
}
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php
index fd774777e3ef4..844e1d610b1a3 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php
@@ -6,12 +6,14 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Magento\Backend\Model\View\Result\Page as ResultPage;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+use Magento\Tax\Controller\Adminhtml\Rule;
-class Index extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpGetActionInterface
+class Index extends Rule implements HttpGetActionInterface
{
/**
- * @return \Magento\Backend\Model\View\Result\Page
+ * @return ResultPage
*/
public function execute()
{
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/NewAction.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/NewAction.php
index 16331069ae798..542856838ece8 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/NewAction.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/NewAction.php
@@ -6,16 +6,18 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Magento\Backend\Model\View\Result\Forward;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Tax\Controller\Adminhtml\Rule;
-class NewAction extends \Magento\Tax\Controller\Adminhtml\Rule
+class NewAction extends Rule
{
/**
- * @return \Magento\Backend\Model\View\Result\Forward
+ * @return Forward
*/
public function execute()
{
- /** @var \Magento\Backend\Model\View\Result\Forward $resultForward */
+ /** @var Forward $resultForward */
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
return $resultForward->forward('edit');
}
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Save.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Save.php
index 5557fb98f71a2..fe86b39f2ffae 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Save.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Save.php
@@ -6,16 +6,21 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Exception;
+use Magento\Backend\Model\Session;
+use Magento\Backend\Model\View\Result\Redirect;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Tax\Controller\Adminhtml\Rule;
-class Save extends \Magento\Tax\Controller\Adminhtml\Rule
+class Save extends Rule
{
/**
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return Redirect
*/
public function execute()
{
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$postData = $this->getRequest()->getPostValue();
if ($postData) {
@@ -30,13 +35,13 @@ public function execute()
return $resultRedirect->setPath('tax/*/edit', ['rule' => $taxRule->getId()]);
}
return $resultRedirect->setPath('tax/*/');
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->messageManager->addError(__('We can\'t save this tax rule right now.'));
}
- $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setRuleData($postData);
+ $this->_objectManager->get(Session::class)->setRuleData($postData);
return $resultRedirect->setUrl($this->_redirect->getRedirectUrl($this->getUrl('*')));
}
return $resultRedirect->setPath('tax/rule');
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
index b184004b99dda..eecf7215cd80e 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
@@ -6,14 +6,18 @@
namespace Magento\Tax\Controller\Adminhtml;
+use Magento\Backend\App\Action;
+use Magento\Backend\App\Action\Context;
use Magento\Framework\Exception\InputException;
+use Magento\Tax\Api\Data\TaxClassInterfaceFactory;
+use Magento\Tax\Api\TaxClassRepositoryInterface;
/**
* Adminhtml common tax class controller
*
* @author Magento Core Team
*/
-abstract class Tax extends \Magento\Backend\App\Action
+abstract class Tax extends Action
{
/**
* Authorization level of a basic admin session
@@ -23,27 +27,21 @@ abstract class Tax extends \Magento\Backend\App\Action
const ADMIN_RESOURCE = 'Magento_Tax::manage_tax';
/**
- * @var \Magento\Tax\Api\TaxClassRepositoryInterface
+ * @var TaxClassRepositoryInterface
*/
protected $taxClassRepository;
/**
- * @var \Magento\Tax\Api\Data\TaxClassInterfaceFactory
- */
- protected $taxClassDataObjectFactory;
-
- /**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService
- * @param \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory
+ * @param Context $context
+ * @param TaxClassRepositoryInterface $taxClassService
+ * @param TaxClassInterfaceFactory $taxClassDataObjectFactory
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService,
- \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory
+ Context $context,
+ TaxClassRepositoryInterface $taxClassService,
+ protected readonly TaxClassInterfaceFactory $taxClassDataObjectFactory
) {
$this->taxClassRepository = $taxClassService;
- $this->taxClassDataObjectFactory = $taxClassDataObjectFactory;
parent::__construct($context);
}
@@ -52,7 +50,7 @@ public function __construct(
*
* @param string $className
* @return string processed class name
- * @throws \Magento\Framework\Exception\InputException
+ * @throws InputException
*/
protected function _processClassName($className)
{
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxDelete.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxDelete.php
index 2f32e76cd3c75..bcd206f308788 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxDelete.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxDelete.php
@@ -6,15 +6,20 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Tax;
+use Exception;
+use InvalidArgumentException;
+use Magento\Framework\Controller\Result\Json as ResultJson;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Tax\Controller\Adminhtml\Tax;
-class AjaxDelete extends \Magento\Tax\Controller\Adminhtml\Tax
+class AjaxDelete extends Tax
{
/**
* Delete Tax Class via AJAX
*
- * @return \Magento\Framework\Controller\Result\Json
- * @throws \InvalidArgumentException
+ * @return ResultJson
+ * @throws InvalidArgumentException
*/
public function execute()
{
@@ -22,16 +27,16 @@ public function execute()
try {
$this->taxClassRepository->deleteById($classId);
$responseContent = ['success' => true, 'error_message' => ''];
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$responseContent = ['success' => false, 'error_message' => $e->getMessage()];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$responseContent = [
'success' => false,
'error_message' => __('We can\'t delete this tax class right now.')
];
}
- /** @var \Magento\Framework\Controller\Result\Json $resultJson */
+ /** @var ResultJson $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseContent);
return $resultJson;
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxSave.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxSave.php
index 1206d68e614d1..90b2b9671f168 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxSave.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax/AjaxSave.php
@@ -6,15 +6,20 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Tax;
+use Exception;
+use InvalidArgumentException;
+use Magento\Framework\Controller\Result\Json as ResultJson;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Tax\Controller\Adminhtml\Tax;
-class AjaxSave extends \Magento\Tax\Controller\Adminhtml\Tax
+class AjaxSave extends Tax
{
/**
* Save Tax Class via AJAX
*
- * @return \Magento\Framework\Controller\Result\Json
- * @throws \InvalidArgumentException
+ * @return ResultJson
+ * @throws InvalidArgumentException
*/
public function execute()
{
@@ -33,14 +38,14 @@ public function execute()
'class_id' => $taxClassId,
'class_name' => $taxClass->getClassName(),
];
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$responseContent = [
'success' => false,
'error_message' => $e->getMessage(),
'class_id' => '',
'class_name' => ''
];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$responseContent = [
'success' => false,
'error_message' => __('We can\'t save this tax class right now.'),
@@ -49,7 +54,7 @@ public function execute()
];
}
- /** @var \Magento\Framework\Controller\Result\Json $resultJson */
+ /** @var ResultJson $resultJson */
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($responseContent);
return $resultJson;
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php
index b623b6c6868e7..966f659ac059d 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax/IgnoreTaxNotification.php
@@ -6,27 +6,35 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Tax;
+use Exception;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Redirect as ResultRedirect;
+use Magento\Config\Model\ResourceModel\Config;
+use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Tax\Api\Data\TaxClassInterfaceFactory;
+use Magento\Tax\Api\TaxClassRepositoryInterface;
+use Magento\Tax\Controller\Adminhtml\Tax;
-class IgnoreTaxNotification extends \Magento\Tax\Controller\Adminhtml\Tax
+class IgnoreTaxNotification extends Tax
{
/**
- * @var \Magento\Framework\App\Cache\TypeListInterface
+ * @var TypeListInterface
*/
protected $_cacheTypeList;
/**
- * @param \Magento\Backend\App\Action\Context $context
- * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService
- * @param \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory
- * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
+ * @param Context $context
+ * @param TaxClassRepositoryInterface $taxClassService
+ * @param TaxClassInterfaceFactory $taxClassDataObjectFactory
+ * @param TypeListInterface $cacheTypeList
*/
public function __construct(
- \Magento\Backend\App\Action\Context $context,
- \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassService,
- \Magento\Tax\Api\Data\TaxClassInterfaceFactory $taxClassDataObjectFactory,
- \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
+ Context $context,
+ TaxClassRepositoryInterface $taxClassService,
+ TaxClassInterfaceFactory $taxClassDataObjectFactory,
+ TypeListInterface $cacheTypeList
) {
$this->_cacheTypeList = $cacheTypeList;
parent::__construct($context, $taxClassService, $taxClassDataObjectFactory);
@@ -35,7 +43,7 @@ public function __construct(
/**
* Set tax ignore notification flag and redirect back
*
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return ResultRedirect
*/
public function execute()
{
@@ -43,9 +51,9 @@ public function execute()
if ($section) {
try {
$path = 'tax/notification/ignore_' . $section;
- $this->_objectManager->get(\Magento\Config\Model\ResourceModel\Config::class)
+ $this->_objectManager->get(Config::class)
->saveConfig($path, 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->messageManager->addError($e->getMessage());
}
}
@@ -54,7 +62,7 @@ public function execute()
$this->_cacheTypeList->cleanType('config');
$this->_eventManager->dispatch('adminhtml_cache_refresh_type', ['type' => 'config']);
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var ResultRedirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setRefererUrl();
}
diff --git a/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php b/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php
index a5b22dad53ae9..49a7d185cdb4c 100644
--- a/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php
+++ b/app/code/Magento/Tax/CustomerData/CheckoutTotalsJsLayoutDataProvider.php
@@ -7,6 +7,7 @@
namespace Magento\Tax\CustomerData;
use Magento\Customer\CustomerData\JsLayoutDataProviderInterface;
+use Magento\Tax\Model\Config;
/**
* Checkout totals js layout data provider
@@ -14,17 +15,11 @@
class CheckoutTotalsJsLayoutDataProvider implements JsLayoutDataProviderInterface
{
/**
- * @var \Magento\Tax\Model\Config
- */
- protected $taxConfig;
-
- /**
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param Config $taxConfig
*/
public function __construct(
- \Magento\Tax\Model\Config $taxConfig
+ protected readonly Config $taxConfig
) {
- $this->taxConfig = $taxConfig;
}
/**
diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php
index 0e950460a26d4..e9e4d2fe37f8f 100644
--- a/app/code/Magento/Tax/Helper/Data.php
+++ b/app/code/Magento/Tax/Helper/Data.php
@@ -5,9 +5,22 @@
*/
namespace Magento\Tax\Helper;
+use Magento\Catalog\Helper\Data as CatalogHelper;
+use Magento\Framework\App\Helper\AbstractHelper;
+use Magento\Framework\App\Helper\Context;
+use Magento\Framework\DataObject;
+use Magento\Framework\Json\Helper\Data as JsonHelper;
+use Magento\Framework\Locale\FormatInterface;
+use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Quote\Model\Quote\Address as QuoteAddress;
+use Magento\Sales\Model\Order;
+use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem;
+use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem;
+use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
use Magento\Customer\Model\Address;
+use Magento\Store\Model\StoreManagerInterface;
use Magento\Tax\Model\Config;
use Magento\Tax\Api\OrderTaxManagementInterface;
use Magento\Sales\Model\Order\Invoice;
@@ -16,6 +29,7 @@
use Magento\Sales\Model\EntityInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\App\ObjectManager;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory;
/**
* Tax helper
@@ -25,7 +39,7 @@
* @api
* @since 100.0.2
*/
-class Data extends \Magento\Framework\App\Helper\AbstractHelper
+class Data extends AbstractHelper
{
/**
* Default tax class for customers
@@ -52,91 +66,60 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
protected $_postCodeSubStringLength = 10;
/**
- * Json Helper
- *
- * @var \Magento\Framework\Json\Helper\Data
- */
- protected $jsonHelper;
-
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $_storeManager;
/**
- * @var \Magento\Framework\Locale\FormatInterface
+ * @var FormatInterface
*/
protected $_localeFormat;
/**
- * @var \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory
+ * @var CollectionFactory
*/
protected $_orderTaxCollectionFactory;
/**
- * @var \Magento\Framework\Locale\ResolverInterface
+ * @var ResolverInterface
*/
protected $_localeResolver;
- /**
- * @var \Magento\Catalog\Helper\Data
- */
- protected $catalogHelper;
-
- /**
- * @var OrderTaxManagementInterface
- */
- protected $orderTaxManagement;
-
- /**
- * @var PriceCurrencyInterface
- */
- protected $priceCurrency;
-
- /**
- * @var Json
- */
- private $serializer;
-
/**
* Constructor
*
- * @param \Magento\Framework\App\Helper\Context $context
- * @param \Magento\Framework\Json\Helper\Data $jsonHelper
+ * @param Context $context
+ * @param JsonHelper $jsonHelper Json Helper
* @param Config $taxConfig
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Magento\Framework\Locale\FormatInterface $localeFormat
- * @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $orderTaxCollectionFactory
- * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
- * @param \Magento\Catalog\Helper\Data $catalogHelper
+ * @param StoreManagerInterface $storeManager
+ * @param FormatInterface $localeFormat
+ * @param CollectionFactory $orderTaxCollectionFactory
+ * @param ResolverInterface $localeResolver
+ * @param CatalogHelper $catalogHelper
* @param OrderTaxManagementInterface $orderTaxManagement
* @param PriceCurrencyInterface $priceCurrency
* @param Json $serializer
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\App\Helper\Context $context,
- \Magento\Framework\Json\Helper\Data $jsonHelper,
+ Context $context,
+ protected readonly JsonHelper $jsonHelper,
Config $taxConfig,
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\Locale\FormatInterface $localeFormat,
- \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $orderTaxCollectionFactory,
- \Magento\Framework\Locale\ResolverInterface $localeResolver,
- \Magento\Catalog\Helper\Data $catalogHelper,
- OrderTaxManagementInterface $orderTaxManagement,
- PriceCurrencyInterface $priceCurrency,
- Json $serializer = null
+ StoreManagerInterface $storeManager,
+ FormatInterface $localeFormat,
+ CollectionFactory $orderTaxCollectionFactory,
+ ResolverInterface $localeResolver,
+ protected readonly CatalogHelper $catalogHelper,
+ protected readonly OrderTaxManagementInterface $orderTaxManagement,
+ protected readonly PriceCurrencyInterface $priceCurrency,
+ private ?Json $serializer = null
) {
parent::__construct($context);
- $this->priceCurrency = $priceCurrency;
$this->_config = $taxConfig;
- $this->jsonHelper = $jsonHelper;
$this->_storeManager = $storeManager;
$this->_localeFormat = $localeFormat;
$this->_orderTaxCollectionFactory = $orderTaxCollectionFactory;
$this->_localeResolver = $localeResolver;
- $this->catalogHelper = $catalogHelper;
- $this->orderTaxManagement = $orderTaxManagement;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
}
@@ -168,7 +151,7 @@ public function getConfig()
/**
* Check if product prices inputed include tax
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function priceIncludesTax($store = null)
@@ -179,7 +162,7 @@ public function priceIncludesTax($store = null)
/**
* Check what taxes should be applied after discount
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function applyTaxAfterDiscount($store = null)
@@ -193,7 +176,7 @@ public function applyTaxAfterDiscount($store = null)
* 2 - Including tax
* 3 - Both
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return int
*/
public function getPriceDisplayType($store = null)
@@ -205,7 +188,7 @@ public function getPriceDisplayType($store = null)
* Check if necessary do product price conversion
* If it necessary will be returned conversion type (minus or plus)
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function needPriceConversion($store = null)
@@ -216,7 +199,7 @@ public function needPriceConversion($store = null)
/**
* Check if need display full tax summary information in totals block
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displayFullSummary($store = null)
@@ -227,7 +210,7 @@ public function displayFullSummary($store = null)
/**
* Check if need display zero tax in subtotal
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displayZeroTax($store = null)
@@ -238,7 +221,7 @@ public function displayZeroTax($store = null)
/**
* Check if need display cart prices included tax
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displayCartPriceInclTax($store = null)
@@ -249,7 +232,7 @@ public function displayCartPriceInclTax($store = null)
/**
* Check if need display cart prices excluding price
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displayCartPriceExclTax($store = null)
@@ -260,7 +243,7 @@ public function displayCartPriceExclTax($store = null)
/**
* Check if need display cart prices excluding and including tax
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displayCartBothPrices($store = null)
@@ -271,7 +254,7 @@ public function displayCartBothPrices($store = null)
/**
* Check if need display order prices included tax
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displaySalesPriceInclTax($store = null)
@@ -282,7 +265,7 @@ public function displaySalesPriceInclTax($store = null)
/**
* Check if need display order prices excluding price
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displaySalesPriceExclTax($store = null)
@@ -293,7 +276,7 @@ public function displaySalesPriceExclTax($store = null)
/**
* Check if need display order prices excluding and including tax
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displaySalesBothPrices($store = null)
@@ -304,7 +287,7 @@ public function displaySalesBothPrices($store = null)
/**
* Check if we need display price include and exclude tax for order/invoice subtotal
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displaySalesSubtotalBoth($store = null)
@@ -315,7 +298,7 @@ public function displaySalesSubtotalBoth($store = null)
/**
* Check if we need display price include tax for order/invoice subtotal
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displaySalesSubtotalInclTax($store = null)
@@ -326,7 +309,7 @@ public function displaySalesSubtotalInclTax($store = null)
/**
* Check if we need display price exclude tax for order/invoice subtotal
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displaySalesSubtotalExclTax($store = null)
@@ -337,7 +320,7 @@ public function displaySalesSubtotalExclTax($store = null)
/**
* Get prices javascript format json
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return string
*/
public function getPriceFormat($store = null)
@@ -375,7 +358,7 @@ public function displayPriceExcludingTax()
/**
* Check if we have display in catalog prices including and excluding tax
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function displayBothPrices($store = null)
@@ -386,7 +369,7 @@ public function displayBothPrices($store = null)
/**
* Check if shipping prices include tax
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return bool
*/
public function shippingPriceIncludesTax($store = null)
@@ -397,7 +380,7 @@ public function shippingPriceIncludesTax($store = null)
/**
* Get shipping price display type
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return int
*/
public function getShippingPriceDisplayType($store = null)
@@ -438,7 +421,7 @@ public function displayShippingBothPrices()
/**
* Get tax class id specified for shipping tax estimation
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return int
*/
public function getShippingTaxClass($store)
@@ -449,16 +432,16 @@ public function getShippingTaxClass($store)
/**
* Get shipping price
*
- * @param float $price
- * @param bool|null $includingTax
- * @param Address|null $shippingAddress
- * @param int|null $ctc
- * @param null|string|bool|int|Store $store
+ * @param float $price
+ * @param bool|null $includingTax
+ * @param Address|null $shippingAddress
+ * @param int|null $ctc
+ * @param null|string|bool|int|Store $store
* @return float
*/
public function getShippingPrice($price, $includingTax = null, $shippingAddress = null, $ctc = null, $store = null)
{
- $pseudoProduct = new \Magento\Framework\DataObject();
+ $pseudoProduct = new DataObject();
$pseudoProduct->setTaxClassId($this->getShippingTaxClass($store));
$billingAddress = false;
@@ -483,7 +466,7 @@ public function getShippingPrice($price, $includingTax = null, $shippingAddress
/**
* Get configuration setting "Apply Discount On Prices Including Tax" value
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return bool
*/
public function discountTax($store = null)
@@ -494,14 +477,14 @@ public function discountTax($store = null)
/**
* Get value of "Apply Tax On" custom/original price configuration settings
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return string|null
*/
public function getTaxBasedOn($store = null)
{
return $this->scopeConfig->getValue(
Config::CONFIG_XML_PATH_BASED_ON,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -509,14 +492,14 @@ public function getTaxBasedOn($store = null)
/**
* Check if tax can be applied to custom price
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return bool
*/
public function applyTaxOnCustomPrice($store = null)
{
return (int) $this->scopeConfig->getValue(
Config::CONFIG_XML_PATH_APPLY_ON,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == 0;
}
@@ -524,14 +507,14 @@ public function applyTaxOnCustomPrice($store = null)
/**
* Check if tax should be applied just to original price
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return bool
*/
public function applyTaxOnOriginalPrice($store = null)
{
return (int) $this->scopeConfig->getValue(
Config::CONFIG_XML_PATH_APPLY_ON,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == 1;
}
@@ -542,7 +525,7 @@ public function applyTaxOnOriginalPrice($store = null)
* This sequence depends on "Catalog price include tax", "Apply Tax After Discount"
* and "Apply Discount On Prices Including Tax" configuration options.
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return string
*/
public function getCalculationSequence($store = null)
@@ -553,7 +536,7 @@ public function getCalculationSequence($store = null)
/**
* Get tax calculation algorithm code
*
- * @param null|string|bool|int|Store $store
+ * @param null|string|bool|int|Store $store
* @return string
*/
public function getCalculationAlgorithm($store = null)
@@ -574,8 +557,7 @@ public function getCalculationAlgorithm($store = null)
* )
* )
*
- * @param \Magento\Sales\Model\Order|\Magento\Sales\Model\Order\Invoice
- * |\Magento\Sales\Model\Order\Creditmemo $source
+ * @param Order|Invoice|Creditmemo $source
* @return array
*/
public function getCalculatedTaxes($source)
@@ -615,9 +597,9 @@ public function getCalculatedTaxes($source)
* )
* )
*
- * @param array $taxClassAmount
- * @param OrderTaxDetailsItemInterface $itemTaxDetail
- * @param float $ratio
+ * @param array $taxClassAmount
+ * @param OrderTaxDetailsItemInterface $itemTaxDetail
+ * @param float $ratio
* @return array
*/
private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $itemTaxDetail, $ratio)
@@ -648,7 +630,7 @@ private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $
/**
* Returns the array of tax rates for the order
*
- * @param \Magento\Sales\Model\Order $order
+ * @param Order $order
* @return array
*/
protected function _getTaxRateSubtotals($order)
@@ -665,7 +647,7 @@ public function getDefaultCustomerTaxClass()
{
return $this->scopeConfig->getValue(
self::CONFIG_DEFAULT_CUSTOMER_TAX_CLASS,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ ScopeInterface::SCOPE_STORE
);
}
@@ -678,14 +660,14 @@ public function getDefaultProductTaxClass()
{
return $this->scopeConfig->getValue(
self::CONFIG_DEFAULT_PRODUCT_TAX_CLASS,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ ScopeInterface::SCOPE_STORE
);
}
/**
* Return whether cross border trade is enabled or not
*
- * @param null|int|string|Store $store
+ * @param null|int|string|Store $store
* @return bool
*/
public function isCrossBorderTradeEnabled($store = null)
@@ -694,7 +676,7 @@ public function isCrossBorderTradeEnabled($store = null)
}
/**
- * @param EntityInterface $current
+ * @param EntityInterface $current
* @return array
*/
protected function calculateTaxForOrder(EntityInterface $current)
@@ -715,8 +697,8 @@ protected function calculateTaxForOrder(EntityInterface $current)
}
/**
- * @param EntityInterface $order
- * @param EntityInterface $salesItem
+ * @param EntityInterface $order
+ * @param EntityInterface $salesItem
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
@@ -727,7 +709,7 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
$orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getId());
// Apply any taxes for the items
- /** @var $item \Magento\Sales\Model\Order\Invoice\Item|\Magento\Sales\Model\Order\Creditmemo\Item */
+ /** @var InvoiceItem|CreditmemoItem $item */
foreach ($salesItem->getItems() as $item) {
$orderItem = $item->getOrderItem();
$orderItemId = $orderItem->getId();
@@ -768,7 +750,7 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
$itemTaxDetails = $orderTaxDetails->getItems();
foreach ($itemTaxDetails as $itemTaxDetail) {
//Aggregate taxable items associated with shipping
- if ($itemTaxDetail->getType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING) {
+ if ($itemTaxDetail->getType() == QuoteAddress::TYPE_SHIPPING) {
$taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
}
}
diff --git a/app/code/Magento/Tax/Model/AggregateSalesReportTaxData.php b/app/code/Magento/Tax/Model/AggregateSalesReportTaxData.php
index a56c0063b647a..648f9c6fa2232 100644
--- a/app/code/Magento/Tax/Model/AggregateSalesReportTaxData.php
+++ b/app/code/Magento/Tax/Model/AggregateSalesReportTaxData.php
@@ -6,36 +6,23 @@
namespace Magento\Tax\Model;
+use Magento\Framework\Locale\ResolverInterface;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Tax\Model\ResourceModel\Report\Tax as ResourceReportTax;
+use Magento\Tax\Model\ResourceModel\Report\TaxFactory;
+
class AggregateSalesReportTaxData
{
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
- */
- protected $localeDate;
-
- /**
- * @var \Magento\Tax\Model\ResourceModel\Report\TaxFactory
- */
- protected $reportTaxFactory;
-
- /**
- * @var \Magento\Framework\Locale\ResolverInterface
- */
- protected $localeResolver;
-
- /**
- * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
- * @param \Magento\Tax\Model\ResourceModel\Report\TaxFactory $reportTaxFactory
- * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
+ * @param TimezoneInterface $localeDate
+ * @param TaxFactory $reportTaxFactory
+ * @param ResolverInterface $localeResolver
*/
public function __construct(
- \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
- \Magento\Tax\Model\ResourceModel\Report\TaxFactory $reportTaxFactory,
- \Magento\Framework\Locale\ResolverInterface $localeResolver
+ protected readonly TimezoneInterface $localeDate,
+ protected readonly TaxFactory $reportTaxFactory,
+ protected readonly ResolverInterface $localeResolver
) {
- $this->localeDate = $localeDate;
- $this->reportTaxFactory = $reportTaxFactory;
- $this->localeResolver = $localeResolver;
}
/**
@@ -48,7 +35,7 @@ public function invoke()
$this->localeResolver->emulate(0);
$currentDate = $this->localeDate->date();
$date = $currentDate->modify('-25 hours');
- /** @var $reportTax \Magento\Tax\Model\ResourceModel\Report\Tax */
+ /** @var ResourceReportTax $reportTax */
$reportTax = $this->reportTaxFactory->create();
$reportTax->aggregate($date);
$this->localeResolver->revert();
diff --git a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CalculationData.php b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CalculationData.php
index 7ba5f62da73b8..d25e8aa080b2b 100644
--- a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CalculationData.php
+++ b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CalculationData.php
@@ -7,6 +7,8 @@
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\JoinProcessor\CustomJoinInterface;
use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\Db\Select;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection as CalculationRuleCollection;
/**
* Class CalculationData
@@ -18,14 +20,14 @@ class CalculationData implements CustomJoinInterface
const CALCULATION_DATA_ALIAS = "cd";
/**
- * @param \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection $collection
+ * @param CalculationRuleCollection $collection
* @return bool
*/
public function apply(AbstractDb $collection)
{
$isNotApplied = !array_key_exists(
self::CALCULATION_DATA_ALIAS,
- $collection->getSelect()->getPart(\Magento\Framework\Db\Select::FROM)
+ $collection->getSelect()->getPart(Select::FROM)
);
if ($isNotApplied) {
$collection->joinCalculationData(self::CALCULATION_DATA_ALIAS);
diff --git a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CustomerTaxClass.php b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CustomerTaxClass.php
index 41e92fd7e3868..b1c5feb6642ea 100644
--- a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CustomerTaxClass.php
+++ b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/CustomerTaxClass.php
@@ -7,6 +7,7 @@
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\JoinProcessor\CustomJoinInterface;
use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection as CalculationRuleCollection;
/**
* Class CustomerTaxClass
@@ -15,7 +16,7 @@
class CustomerTaxClass implements CustomJoinInterface
{
/**
- * @param \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection $collection
+ * @param CalculationRuleCollection $collection
* @return true
*/
public function apply(AbstractDb $collection)
diff --git a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/ProductTaxClass.php b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/ProductTaxClass.php
index a8aa6a2a046c3..424498f9173ae 100644
--- a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/ProductTaxClass.php
+++ b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/ProductTaxClass.php
@@ -7,6 +7,7 @@
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\JoinProcessor\CustomJoinInterface;
use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection as CalculationRuleCollection;
/**
* Class ProductTaxClass
@@ -15,7 +16,7 @@
class ProductTaxClass implements CustomJoinInterface
{
/**
- * @param \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection $collection
+ * @param CalculationRuleCollection $collection
* @return true
*/
public function apply(AbstractDb $collection)
diff --git a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/Rate.php b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/Rate.php
index 6f106cf1bdf39..895fe89a79694 100644
--- a/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/Rate.php
+++ b/app/code/Magento/Tax/Model/Api/SearchCriteria/JoinProcessor/Rate.php
@@ -7,6 +7,7 @@
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\JoinProcessor\CustomJoinInterface;
use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection as CalculationRuleCollection;
/**
* Class Rate
@@ -15,7 +16,7 @@
class Rate implements CustomJoinInterface
{
/**
- * @param \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection $collection
+ * @param CalculationRuleCollection $collection
* @return true
*/
public function apply(AbstractDb $collection)
diff --git a/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php b/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php
index d768e2f6092a0..02b2ed20ead8a 100644
--- a/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php
+++ b/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php
@@ -19,62 +19,28 @@
*/
class ContextPlugin
{
- /**
- * @var Session
- */
- protected $customerSession;
-
- /**
- * @var HttpContext
- */
- protected $httpContext;
-
- /**
- * @var TaxHelper
- */
- protected $taxHelper;
-
/**
* @var Calculation
*/
protected $taxCalculation;
- /**
- * Module manager
- *
- * @var ModuleManager
- */
- private $moduleManager;
-
- /**
- * Cache config
- *
- * @var PageCacheConfig
- */
- private $cacheConfig;
-
/**
* @param Session $customerSession
* @param HttpContext $httpContext
* @param Calculation $calculation
* @param TaxHelper $taxHelper
- * @param ModuleManager $moduleManager
- * @param PageCacheConfig $cacheConfig
+ * @param ModuleManager $moduleManager Module manager
+ * @param PageCacheConfig $cacheConfig Cache config
*/
public function __construct(
- Session $customerSession,
- HttpContext $httpContext,
+ protected readonly Session $customerSession,
+ protected readonly HttpContext $httpContext,
Calculation $calculation, //phpcs:ignore Magento2.Classes.DiscouragedDependencies
- TaxHelper $taxHelper,
- ModuleManager $moduleManager,
- PageCacheConfig $cacheConfig
+ protected readonly TaxHelper $taxHelper,
+ private readonly ModuleManager $moduleManager,
+ private readonly PageCacheConfig $cacheConfig
) {
- $this->customerSession = $customerSession;
- $this->httpContext = $httpContext;
$this->taxCalculation = $calculation;
- $this->taxHelper = $taxHelper;
- $this->moduleManager = $moduleManager;
- $this->cacheConfig = $cacheConfig;
}
/**
diff --git a/app/code/Magento/Tax/Model/Calculation.php b/app/code/Magento/Tax/Model/Calculation.php
index 030b2974ce978..eab93e931d0da 100644
--- a/app/code/Magento/Tax/Model/Calculation.php
+++ b/app/code/Magento/Tax/Model/Calculation.php
@@ -12,19 +12,34 @@
use Magento\Customer\Api\Data\RegionInterface as AddressRegion;
use Magento\Customer\Api\GroupManagementInterface as CustomerGroupManagement;
use Magento\Customer\Api\GroupRepositoryInterface as CustomerGroupRepository;
+use Magento\Customer\Model\CustomerFactory;
+use Magento\Customer\Model\Session;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\DataObject;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Model\AbstractModel;
+use Magento\Framework\Model\Context;
use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Registry;
+use Magento\Shipping\Model\Config as ShippingConfig;
+use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Tax\Api\TaxClassManagementInterface;
use Magento\Tax\Api\TaxClassRepositoryInterface;
+use Magento\Tax\Model\Config as TaxConfig;
+use Magento\Tax\Model\ResourceModel\Calculation as ResourceCalculation;
+use Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory;
/**
* Tax Calculation Model
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Calculation extends \Magento\Framework\Model\AbstractModel
+class Calculation extends AbstractModel
{
/**
* Identifier constant for Tax calculation before discount excluding TAX
@@ -111,27 +126,27 @@ class Calculation extends \Magento\Framework\Model\AbstractModel
/**
* Core store config
*
- * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ * @var ScopeConfigInterface
*/
protected $_scopeConfig;
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $_storeManager;
/**
- * @var \Magento\Customer\Model\Session
+ * @var Session
*/
protected $_customerSession;
/**
- * @var \Magento\Customer\Model\CustomerFactory
+ * @var CustomerFactory
*/
protected $_customerFactory;
/**
- * @var \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory
+ * @var CollectionFactory
*/
protected $_classesFactory;
@@ -143,92 +158,46 @@ class Calculation extends \Magento\Framework\Model\AbstractModel
protected $_config;
/**
- * @var CustomerAccountManagement
- */
- protected $customerAccountManagement;
-
- /**
- * @var CustomerGroupManagement
- */
- protected $customerGroupManagement;
-
- /**
- * @var CustomerGroupRepository
- */
- protected $customerGroupRepository;
-
- /**
- * @var CustomerRepository
- */
- protected $customerRepository;
-
- /**
- * @var PriceCurrencyInterface
- */
- protected $priceCurrency;
-
- /**
- * Filter Builder
- *
- * @var FilterBuilder
- */
- protected $filterBuilder;
-
- /**
- * Search Criteria Builder
- *
- * @var SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
- /**
- * Tax Class Repository
- *
- * @var TaxClassRepositoryInterface
- */
- protected $taxClassRepository;
-
- /**
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
+ * @param Context $context
+ * @param Registry $registry
+ * @param ScopeConfigInterface $scopeConfig
* @param Config $taxConfig
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Magento\Customer\Model\Session $customerSession
- * @param \Magento\Customer\Model\CustomerFactory $customerFactory
- * @param \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory $classesFactory
- * @param \Magento\Tax\Model\ResourceModel\Calculation $resource
+ * @param StoreManagerInterface $storeManager
+ * @param Session $customerSession
+ * @param CustomerFactory $customerFactory
+ * @param CollectionFactory $classesFactory
+ * @param ResourceCalculation $resource
* @param CustomerAccountManagement $customerAccountManagement
* @param CustomerGroupManagement $customerGroupManagement
* @param CustomerGroupRepository $customerGroupRepository
* @param CustomerRepository $customerRepository
* @param PriceCurrencyInterface $priceCurrency
- * @param SearchCriteriaBuilder $searchCriteriaBuilder
- * @param FilterBuilder $filterBuilder
- * @param TaxClassRepositoryInterface $taxClassRepository
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder Search Criteria Builder
+ * @param FilterBuilder $filterBuilder Filter Builder
+ * @param TaxClassRepositoryInterface $taxClassRepository Tax Class Repository
+ * @param AbstractDb $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
+ Context $context,
+ Registry $registry,
+ ScopeConfigInterface $scopeConfig,
Config $taxConfig,
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Customer\Model\Session $customerSession,
- \Magento\Customer\Model\CustomerFactory $customerFactory,
- \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory $classesFactory,
- \Magento\Tax\Model\ResourceModel\Calculation $resource,
- CustomerAccountManagement $customerAccountManagement,
- CustomerGroupManagement $customerGroupManagement,
- CustomerGroupRepository $customerGroupRepository,
- CustomerRepository $customerRepository,
- PriceCurrencyInterface $priceCurrency,
- SearchCriteriaBuilder $searchCriteriaBuilder,
- FilterBuilder $filterBuilder,
- TaxClassRepositoryInterface $taxClassRepository,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ StoreManagerInterface $storeManager,
+ Session $customerSession,
+ CustomerFactory $customerFactory,
+ CollectionFactory $classesFactory,
+ ResourceCalculation $resource,
+ protected readonly CustomerAccountManagement $customerAccountManagement,
+ protected readonly CustomerGroupManagement $customerGroupManagement,
+ protected readonly CustomerGroupRepository $customerGroupRepository,
+ protected readonly CustomerRepository $customerRepository,
+ protected readonly PriceCurrencyInterface $priceCurrency,
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder,
+ protected readonly FilterBuilder $filterBuilder,
+ protected readonly TaxClassRepositoryInterface $taxClassRepository,
+ AbstractDb $resourceCollection = null,
array $data = []
) {
$this->_scopeConfig = $scopeConfig;
@@ -237,14 +206,6 @@ public function __construct(
$this->_customerSession = $customerSession;
$this->_customerFactory = $customerFactory;
$this->_classesFactory = $classesFactory;
- $this->customerAccountManagement = $customerAccountManagement;
- $this->customerGroupManagement = $customerGroupManagement;
- $this->customerGroupRepository = $customerGroupRepository;
- $this->customerRepository = $customerRepository;
- $this->priceCurrency = $priceCurrency;
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
- $this->filterBuilder = $filterBuilder;
- $this->taxClassRepository = $taxClassRepository;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
@@ -253,7 +214,7 @@ public function __construct(
*/
protected function _construct()
{
- $this->_init(\Magento\Tax\Model\ResourceModel\Calculation::class);
+ $this->_init(ResourceCalculation::class);
}
/**
@@ -275,8 +236,8 @@ public function getDefaultCustomerTaxClass($store = null)
/**
* Delete calculation settings by rule id
*
- * @param int $ruleId
- * @return $this
+ * @param int $ruleId
+ * @return $this
*/
public function deleteByRuleId($ruleId)
{
@@ -287,8 +248,8 @@ public function deleteByRuleId($ruleId)
/**
* Get calculation rates by rule id
*
- * @param int $ruleId
- * @return array
+ * @param int $ruleId
+ * @return array
*/
public function getRates($ruleId)
{
@@ -301,8 +262,8 @@ public function getRates($ruleId)
/**
* Get allowed customer tax classes by rule id
*
- * @param int $ruleId
- * @return array
+ * @param int $ruleId
+ * @return array
*/
public function getCustomerTaxClasses($ruleId)
{
@@ -315,8 +276,8 @@ public function getCustomerTaxClasses($ruleId)
/**
* Get allowed product tax classes by rule id
*
- * @param int $ruleId
- * @return array
+ * @param int $ruleId
+ * @return array
*/
public function getProductTaxClasses($ruleId)
{
@@ -350,8 +311,8 @@ protected function _formCalculationProcess()
/**
* Get calculation tax rate by specific request
*
- * @param \Magento\Framework\DataObject $request
- * @return float
+ * @param DataObject $request
+ * @return float
*/
public function getRate($request)
{
@@ -381,14 +342,14 @@ public function getRate($request)
/**
* Get cache key value for specific tax rate request
*
- * @param \Magento\Framework\DataObject $request
- * @return string
+ * @param DataObject $request
+ * @return string
*/
protected function _getRequestCacheKey($request)
{
$store = $request->getStore();
$key = '';
- if ($store instanceof \Magento\Store\Model\Store) {
+ if ($store instanceof Store) {
$key = $store->getId() . '|';
} elseif (is_numeric($store)) {
$key = $store . '|';
@@ -406,7 +367,7 @@ protected function _getRequestCacheKey($request)
* This rate can be used for conversion store price including tax to
* store price excluding tax
*
- * @param \Magento\Framework\DataObject $request
+ * @param DataObject $request
* @param null|string|bool|int|Store $store
* @return float
*/
@@ -419,28 +380,28 @@ public function getStoreRate($request, $store = null)
/**
* Get request object for getting tax rate based on store shipping original address
*
- * @param null|string|bool|int|Store $store
- * @return \Magento\Framework\DataObject
+ * @param null|string|bool|int|Store $store
+ * @return DataObject
*/
protected function getRateOriginRequest($store = null)
{
- $request = new \Magento\Framework\DataObject();
+ $request = new DataObject();
$request->setCountryId(
$this->_scopeConfig->getValue(
- \Magento\Shipping\Model\Config::XML_PATH_ORIGIN_COUNTRY_ID,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ShippingConfig::XML_PATH_ORIGIN_COUNTRY_ID,
+ ScopeInterface::SCOPE_STORE,
$store
)
)->setRegionId(
$this->_scopeConfig->getValue(
- \Magento\Shipping\Model\Config::XML_PATH_ORIGIN_REGION_ID,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ShippingConfig::XML_PATH_ORIGIN_REGION_ID,
+ ScopeInterface::SCOPE_STORE,
$store
)
)->setPostcode(
$this->_scopeConfig->getValue(
- \Magento\Shipping\Model\Config::XML_PATH_ORIGIN_POSTCODE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ShippingConfig::XML_PATH_ORIGIN_POSTCODE,
+ ScopeInterface::SCOPE_STORE,
$store
)
)->setCustomerClassId(
@@ -456,7 +417,7 @@ protected function getRateOriginRequest($store = null)
*
* @param null|int|string|Store $store
* @param int $customerId
- * @return \Magento\Framework\DataObject
+ * @return DataObject
*/
public function getDefaultRateRequest($store = null, $customerId = null)
{
@@ -471,8 +432,8 @@ public function getDefaultRateRequest($store = null, $customerId = null)
/**
* Return whether cross border trade is enabled or not
*
- * @param null|int|string|Store $store
- * @return bool
+ * @param null|int|string|Store $store
+ * @return bool
*/
protected function _isCrossBorderTradeEnabled($store = null)
{
@@ -489,12 +450,12 @@ protected function _isCrossBorderTradeEnabled($store = null)
* customer_class_id (->getCustomerClassId())
* store (->getStore())
*
- * @param null|bool|\Magento\Framework\DataObject|CustomerAddress $shippingAddress
- * @param null|bool|\Magento\Framework\DataObject|CustomerAddress $billingAddress
+ * @param null|bool|DataObject|CustomerAddress $shippingAddress
+ * @param null|bool|DataObject|CustomerAddress $billingAddress
* @param null|int $customerTaxClass
- * @param null|int|\Magento\Store\Model\Store $store
+ * @param null|int|Store $store
* @param int $customerId
- * @return \Magento\Framework\DataObject
+ * @return DataObject
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -509,10 +470,10 @@ public function getRateRequest(
if ($shippingAddress === false && $billingAddress === false && $customerTaxClass === false) {
return $this->getRateOriginRequest($store);
}
- $address = new \Magento\Framework\DataObject();
+ $address = new DataObject();
$basedOn = $this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_BASED_ON,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ TaxConfig::CONFIG_XML_PATH_BASED_ON,
+ ScopeInterface::SCOPE_STORE,
$store
);
@@ -570,20 +531,20 @@ public function getRateRequest(
case 'default':
$address->setCountryId(
$this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_COUNTRY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ TaxConfig::CONFIG_XML_PATH_DEFAULT_COUNTRY,
+ ScopeInterface::SCOPE_STORE,
$store
)
)->setRegionId(
$this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_REGION,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ TaxConfig::CONFIG_XML_PATH_DEFAULT_REGION,
+ ScopeInterface::SCOPE_STORE,
$store
)
)->setPostcode(
$this->_scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_POSTCODE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ TaxConfig::CONFIG_XML_PATH_DEFAULT_POSTCODE,
+ ScopeInterface::SCOPE_STORE,
$store
)
);
@@ -603,7 +564,7 @@ public function getRateRequest(
}
}
- $request = new \Magento\Framework\DataObject();
+ $request = new DataObject();
//TODO: Address is not completely refactored to use Data objects
if ($address->getRegion() instanceof AddressRegion) {
$regionId = $address->getRegion()->getRegionId();
@@ -621,8 +582,8 @@ public function getRateRequest(
/**
* Get information about tax rates applied to request
*
- * @param \Magento\Framework\DataObject $request
- * @return array
+ * @param DataObject $request
+ * @return array
*/
public function getAppliedRates($request)
{
@@ -652,11 +613,11 @@ public function reproduceProcess($rates)
* Calculate rated tax amount based on price and tax rate.
* If you are using price including tax $priceIncludeTax should be true.
*
- * @param float $price
- * @param float $taxRate
- * @param boolean $priceIncludeTax
- * @param boolean $round
- * @return float
+ * @param float $price
+ * @param float $taxRate
+ * @param boolean $priceIncludeTax
+ * @param boolean $round
+ * @return float
*/
public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round = true)
{
@@ -678,8 +639,8 @@ public function calcTaxAmount($price, $taxRate, $priceIncludeTax = false, $round
/**
* Round tax amount
*
- * @param float $price
- * @return float
+ * @param float $price
+ * @return float
*/
public function round($price)
{
@@ -697,16 +658,16 @@ public function getTaxRates($billingAddress, $shippingAddress, $customerTaxClass
$billingAddressObj = null;
$shippingAddressObj = null;
if (!empty($billingAddress)) {
- $billingAddressObj = new \Magento\Framework\DataObject($billingAddress);
+ $billingAddressObj = new DataObject($billingAddress);
}
if (!empty($shippingAddress)) {
- $shippingAddressObj = new \Magento\Framework\DataObject($shippingAddress);
+ $shippingAddressObj = new DataObject($shippingAddress);
}
$rateRequest = $this->getRateRequest($shippingAddressObj, $billingAddressObj, $customerTaxClassId);
$searchCriteria = $this->searchCriteriaBuilder->addFilters(
[$this->filterBuilder->setField(ClassModel::KEY_TYPE)
- ->setValue(\Magento\Tax\Api\TaxClassManagementInterface::TYPE_PRODUCT)
+ ->setValue(TaxClassManagementInterface::TYPE_PRODUCT)
->create()]
)->create();
$ids = $this->taxClassRepository->getList($searchCriteria)->getItems();
diff --git a/app/code/Magento/Tax/Model/Calculation/AbstractAggregateCalculator.php b/app/code/Magento/Tax/Model/Calculation/AbstractAggregateCalculator.php
index 612573ff493ad..1eb2d235fdf63 100644
--- a/app/code/Magento/Tax/Model/Calculation/AbstractAggregateCalculator.php
+++ b/app/code/Magento/Tax/Model/Calculation/AbstractAggregateCalculator.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Tax\Model\Calculation;
+use Magento\Tax\Api\Data\AppliedTaxInterface;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
/**
@@ -70,7 +71,7 @@ protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $qua
}
// Calculate applied taxes
- /** @var \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes */
+ /** @var AppliedTaxInterface[] $appliedTaxes */
$appliedRates = $this->calculationTool->getAppliedRates($taxRateRequest);
$appliedTaxes = $this->getAppliedTaxes($rowTax, $rate, $appliedRates);
diff --git a/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php b/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
index 8cfe3079424d4..2491d3496507b 100644
--- a/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
+++ b/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
@@ -6,13 +6,17 @@
namespace Magento\Tax\Model\Calculation;
use Magento\Customer\Api\Data\AddressInterface as CustomerAddress;
+use Magento\Framework\DataObject;
+use Magento\Tax\Api\Data\AppliedTaxInterface;
use Magento\Tax\Api\Data\AppliedTaxInterfaceFactory;
+use Magento\Tax\Api\Data\AppliedTaxRateInterface;
use Magento\Tax\Api\Data\AppliedTaxRateInterfaceFactory;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
use Magento\Tax\Api\Data\TaxDetailsItemInterface;
use Magento\Tax\Api\Data\TaxDetailsItemInterfaceFactory;
use Magento\Tax\Api\TaxClassManagementInterface;
use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -29,23 +33,6 @@ abstract class AbstractCalculator
const KEY_TAX_BEFORE_DISCOUNT_DELTA_ROUNDING = 'tax_before_discount';
/**#@-*/
- /**#@-*/
- protected $taxDetailsItemDataObjectFactory;
-
- /**
- * Tax calculation tool
- *
- * @var Calculation
- */
- protected $calculationTool;
-
- /**
- * Store id
- *
- * @var int
- */
- protected $storeId;
-
/**
* Customer tax class id
*
@@ -74,13 +61,6 @@ abstract class AbstractCalculator
*/
protected $billingAddress;
- /**
- * Tax configuration object
- *
- * @var \Magento\Tax\Model\Config
- */
- protected $config;
-
/**
* Address rate request
*
@@ -91,7 +71,7 @@ abstract class AbstractCalculator
* customer_class_id (->getCustomerClassId())
* store (->getStore())
*
- * @var \Magento\Framework\DataObject
+ * @var DataObject
*/
private $addressRateRequest = null;
@@ -115,16 +95,6 @@ abstract class AbstractCalculator
*/
protected $taxClassManagement;
- /**
- * @var AppliedTaxInterfaceFactory
- */
- protected $appliedTaxDataObjectFactory;
-
- /**
- * @var AppliedTaxRateInterfaceFactory
- */
- protected $appliedTaxRateDataObjectFactory;
-
/**
* Constructor
*
@@ -132,28 +102,22 @@ abstract class AbstractCalculator
* @param TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory
* @param AppliedTaxInterfaceFactory $appliedTaxDataObjectFactory
* @param AppliedTaxRateInterfaceFactory $appliedTaxRateDataObjectFactory
- * @param Calculation $calculationTool
- * @param \Magento\Tax\Model\Config $config
- * @param int $storeId
- * @param \Magento\Framework\DataObject $addressRateRequest
+ * @param Calculation $calculationTool Tax calculation tool
+ * @param TaxConfig $config Tax configuration object
+ * @param int $storeId Store id
+ * @param null|DataObject $addressRateRequest
*/
public function __construct(
TaxClassManagementInterface $taxClassService,
- TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory,
- AppliedTaxInterfaceFactory $appliedTaxDataObjectFactory,
- AppliedTaxRateInterfaceFactory $appliedTaxRateDataObjectFactory,
- Calculation $calculationTool,
- \Magento\Tax\Model\Config $config,
- $storeId,
- \Magento\Framework\DataObject $addressRateRequest = null
+ protected readonly TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory,
+ protected readonly AppliedTaxInterfaceFactory $appliedTaxDataObjectFactory,
+ protected readonly AppliedTaxRateInterfaceFactory $appliedTaxRateDataObjectFactory,
+ protected readonly Calculation $calculationTool,
+ protected readonly TaxConfig $config,
+ protected $storeId,
+ ?DataObject $addressRateRequest = null
) {
$this->taxClassManagement = $taxClassService;
- $this->taxDetailsItemDataObjectFactory = $taxDetailsItemDataObjectFactory;
- $this->appliedTaxDataObjectFactory = $appliedTaxDataObjectFactory;
- $this->appliedTaxRateDataObjectFactory = $appliedTaxRateDataObjectFactory;
- $this->calculationTool = $calculationTool;
- $this->config = $config;
- $this->storeId = $storeId;
$this->addressRateRequest = $addressRateRequest;
}
@@ -251,7 +215,7 @@ abstract protected function calculateWithTaxNotInPrice(QuoteDetailsItemInterface
* customer_class_id (->getCustomerClassId())
* store (->getStore())
*
- * @return \Magento\Framework\DataObject
+ * @return DataObject
*/
protected function getAddressRateRequest()
{
@@ -298,7 +262,7 @@ protected function isSameRateAsStore($rate, $storeRate)
* 'percent' => 5.3,
* ],
* ]
- * @return \Magento\Tax\Api\Data\AppliedTaxInterface
+ * @return AppliedTaxInterface
*/
protected function getAppliedTax($rowTax, $appliedRate)
{
@@ -307,7 +271,7 @@ protected function getAppliedTax($rowTax, $appliedRate)
$appliedTaxDataObject->setPercent($appliedRate['percent']);
$appliedTaxDataObject->setTaxRateKey($appliedRate['id']);
- /** @var \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $rateDataObjects */
+ /** @var AppliedTaxRateInterface[] $rateDataObjects */
$rateDataObjects = [];
foreach ($appliedRate['rates'] as $rate) {
//Skipped position, priority and rule_id
@@ -347,11 +311,11 @@ protected function getAppliedTax($rowTax, $appliedRate)
* ],
* ],
* ]
- * @return \Magento\Tax\Api\Data\AppliedTaxInterface[]
+ * @return AppliedTaxInterface[]
*/
protected function getAppliedTaxes($rowTax, $totalTaxRate, $appliedRates)
{
- /** @var \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes */
+ /** @var AppliedTaxInterface[] $appliedTaxes */
$appliedTaxes = [];
$totalAppliedAmount = 0;
foreach ($appliedRates as $appliedRate) {
@@ -377,7 +341,7 @@ protected function getAppliedTaxes($rowTax, $totalTaxRate, $appliedRates)
$appliedTaxDataObject->setPercent($appliedRate['percent']);
$appliedTaxDataObject->setTaxRateKey($appliedRate['id']);
- /** @var \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $rateDataObjects */
+ /** @var AppliedTaxRateInterface[] $rateDataObjects */
$rateDataObjects = [];
foreach ($appliedRate['rates'] as $rate) {
//Skipped position, priority and rule_id
diff --git a/app/code/Magento/Tax/Model/Calculation/CalculatorFactory.php b/app/code/Magento/Tax/Model/Calculation/CalculatorFactory.php
index 04e3873924385..dcd02d0040f8f 100644
--- a/app/code/Magento/Tax/Model/Calculation/CalculatorFactory.php
+++ b/app/code/Magento/Tax/Model/Calculation/CalculatorFactory.php
@@ -6,7 +6,9 @@
namespace Magento\Tax\Model\Calculation;
+use InvalidArgumentException;
use Magento\Customer\Api\Data\AddressInterface as CustomerAddress;
+use Magento\Framework\ObjectManagerInterface;
class CalculatorFactory
{
@@ -25,19 +27,14 @@ class CalculatorFactory
*/
const CALC_TOTAL_BASE = 'TOTAL_BASE_CALCULATION';
- /**
- * @var \Magento\Framework\ObjectManagerInterface
- */
- protected $objectManager;
-
/**
* Constructor
*
- * @param \Magento\Framework\ObjectManagerInterface $objectManager
+ * @param ObjectManagerInterface $objectManager
*/
- public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
- {
- $this->objectManager = $objectManager;
+ public function __construct(
+ protected readonly ObjectManagerInterface $objectManager
+ ) {
}
/**
@@ -49,8 +46,8 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
* @param CustomerAddress $shippingAddress
* @param null|int $customerTaxClassId
* @param null|int $customerId
- * @return \Magento\Tax\Model\Calculation\AbstractCalculator
- * @throws \InvalidArgumentException
+ * @return AbstractCalculator
+ * @throws InvalidArgumentException
*/
public function create(
$type,
@@ -62,18 +59,18 @@ public function create(
) {
switch ($type) {
case self::CALC_UNIT_BASE:
- $className = \Magento\Tax\Model\Calculation\UnitBaseCalculator::class;
+ $className = UnitBaseCalculator::class;
break;
case self::CALC_ROW_BASE:
- $className = \Magento\Tax\Model\Calculation\RowBaseCalculator::class;
+ $className = RowBaseCalculator::class;
break;
case self::CALC_TOTAL_BASE:
- $className = \Magento\Tax\Model\Calculation\TotalBaseCalculator::class;
+ $className = TotalBaseCalculator::class;
break;
default:
- throw new \InvalidArgumentException('Unknown calculation type: ' . $type);
+ throw new InvalidArgumentException('Unknown calculation type: ' . $type);
}
- /** @var \Magento\Tax\Model\Calculation\AbstractCalculator $calculator */
+ /** @var AbstractCalculator $calculator */
$calculator = $this->objectManager->create($className, ['storeId' => $storeId]);
if (null != $shippingAddress) {
$calculator->setShippingAddress($shippingAddress);
diff --git a/app/code/Magento/Tax/Model/Calculation/Rate.php b/app/code/Magento/Tax/Model/Calculation/Rate.php
index c53cb8f509b8a..39b52386207f9 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rate.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rate.php
@@ -7,17 +7,30 @@
namespace Magento\Tax\Model\Calculation;
use Magento\Directory\Model\Region;
+use Magento\Directory\Model\RegionFactory;
use Magento\Framework\Api\AttributeValueFactory;
+use Magento\Framework\Api\ExtensionAttributesFactory;
+use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Exception\CouldNotDeleteException;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+use Magento\Tax\Api\Data\TaxRateExtensionInterface;
use Magento\Tax\Api\Data\TaxRateInterface;
use Magento\Tax\Api\Data\TaxRateTitleInterface;
+use Magento\Tax\Model\Calculation\Rate as ModelCalculationRate;
+use Magento\Tax\Model\Calculation\Rate\Title as ModelCalculationRateTitle;
+use Magento\Tax\Model\Calculation\Rate\TitleFactory;
+use Magento\Tax\Model\ResourceModel\Calculation\Rate as ResourceCalculationRate;
/**
* Tax Rate Model
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements TaxRateInterface
+class Rate extends AbstractExtensibleModel implements TaxRateInterface
{
/**#@+
* Constants defined for keys of array, makes typos less likely
@@ -41,53 +54,47 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements T
protected $_titles = null;
/**
- * @var \Magento\Tax\Model\Calculation\Rate\Title
+ * @var ModelCalculationRateTitle
*/
protected $_titleModel = null;
/**
- * @var \Magento\Directory\Model\RegionFactory
+ * @var RegionFactory
*/
protected $_regionFactory;
/**
- * @var \Magento\Tax\Model\Calculation\Rate\TitleFactory
+ * @var TitleFactory
*/
protected $_titleFactory;
/**
- * @var Region
- */
- protected $directoryRegion;
-
- /**
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
+ * @param Context $context
+ * @param Registry $registry
+ * @param ExtensionAttributesFactory $extensionFactory
* @param AttributeValueFactory $customAttributeFactory
- * @param \Magento\Directory\Model\RegionFactory $regionFactory
- * @param Rate\TitleFactory $taxTitleFactory
+ * @param RegionFactory $regionFactory
+ * @param TitleFactory $taxTitleFactory
* @param Region $directoryRegion
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
+ * @param AbstractResource|null $resource
+ * @param AbstractDb|null $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
+ Context $context,
+ Registry $registry,
+ ExtensionAttributesFactory $extensionFactory,
AttributeValueFactory $customAttributeFactory,
- \Magento\Directory\Model\RegionFactory $regionFactory,
- \Magento\Tax\Model\Calculation\Rate\TitleFactory $taxTitleFactory,
- Region $directoryRegion,
- \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ RegionFactory $regionFactory,
+ TitleFactory $taxTitleFactory,
+ protected readonly Region $directoryRegion,
+ AbstractResource $resource = null,
+ AbstractDb $resourceCollection = null,
array $data = []
) {
$this->_regionFactory = $regionFactory;
$this->_titleFactory = $taxTitleFactory;
- $this->directoryRegion = $directoryRegion;
parent::__construct(
$context,
$registry,
@@ -106,14 +113,14 @@ public function __construct(
*/
protected function _construct()
{
- $this->_init(\Magento\Tax\Model\ResourceModel\Calculation\Rate::class);
+ $this->_init(ResourceCalculationRate::class);
}
/**
* Prepare location settings and tax postcode before save rate
*
- * @return \Magento\Tax\Model\Calculation\Rate
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @return ModelCalculationRate
+ * @throws LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
@@ -127,13 +134,13 @@ public function beforeSave()
($this->getTaxPostcode() === '' && !$this->getZipIsRange());
if ($isEmptyValues || $isWrongRange) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('The required information is invalid. Verify the information and try again.')
);
}
if (!is_numeric($this->getRate()) || $this->getRate() < 0) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('The Rate Percent is invalid. Enter a positive number and try again.')
);
}
@@ -143,7 +150,7 @@ public function beforeSave()
$zipTo = $this->getZipTo();
if (($zipFrom && strlen($zipFrom) > 9) || ($zipTo && strlen($zipTo) > 9)) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__(
'The ZIP Code length is invalid. '
. 'Verify that the length is nine characters or fewer and try again.'
@@ -152,13 +159,13 @@ public function beforeSave()
}
if (!is_numeric($zipFrom) || !is_numeric($zipTo) || $zipFrom < 0 || $zipTo < 0) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('The ZIP Code is invalid. Use numbers only.')
);
}
if ($zipFrom > $zipTo) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('Range To should be equal or greater than Range From.')
);
}
@@ -177,7 +184,7 @@ public function beforeSave()
parent::beforeSave();
$country = $this->getTaxCountryId();
$region = $this->getTaxRegionId();
- /** @var $regionModel \Magento\Directory\Model\Region */
+ /** @var Region $regionModel */
$regionModel = $this->_regionFactory->create();
$regionModel->load($region);
if ($regionModel->getCountryId() != $country) {
@@ -189,7 +196,7 @@ public function beforeSave()
/**
* Save rate titles
*
- * @return \Magento\Tax\Model\Calculation\Rate
+ * @return ModelCalculationRate
*/
public function afterSave()
{
@@ -201,8 +208,8 @@ public function afterSave()
/**
* Processing object before delete data
*
- * @return \Magento\Tax\Model\Calculation\Rate
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @return ModelCalculationRate
+ * @throws LocalizedException
*/
public function beforeDelete()
{
@@ -219,7 +226,7 @@ public function beforeDelete()
*
* Redeclared for dispatch tax_settings_change_after event
*
- * @return \Magento\Tax\Model\Calculation\Rate
+ * @return ModelCalculationRate
*/
public function afterDelete()
{
@@ -260,7 +267,7 @@ public function saveTitles($titles = null)
/**
* Returns a tax title
*
- * @return \Magento\Tax\Model\Calculation\Rate\Title
+ * @return ModelCalculationRateTitle
*/
public function getTitleModel()
{
@@ -287,7 +294,7 @@ public function getTitles()
/**
* Deletes all tax rates
*
- * @return \Magento\Tax\Model\Calculation\Rate
+ * @return ModelCalculationRate
*/
public function deleteAllRates()
{
@@ -299,8 +306,8 @@ public function deleteAllRates()
/**
* Load rate model by code
*
- * @param string $code
- * @return \Magento\Tax\Model\Calculation\Rate
+ * @param string $code
+ * @return ModelCalculationRate
*/
public function loadByCode($code)
{
@@ -518,7 +525,7 @@ public function setTitles(array $titles = null)
/**
* @inheritdoc
*
- * @return \Magento\Tax\Api\Data\TaxRateExtensionInterface|null
+ * @return TaxRateExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -528,10 +535,10 @@ public function getExtensionAttributes()
/**
* @inheritdoc
*
- * @param \Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes
+ * @param TaxRateExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxRateExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php b/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php
index 9aa9da66aa830..a049f3485af33 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rate/Converter.php
@@ -7,6 +7,9 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Locale\FormatInterface;
+use Magento\Tax\Api\Data\TaxRateInterface;
+use Magento\Tax\Api\Data\TaxRateInterfaceFactory;
+use Magento\Tax\Api\Data\TaxRateTitleInterfaceFactory;
/**
* Tax Rate Model converter.
@@ -16,42 +19,25 @@
class Converter
{
/**
- * @var \Magento\Tax\Api\Data\TaxRateInterfaceFactory
- */
- protected $taxRateDataObjectFactory;
-
- /**
- * @var \Magento\Tax\Api\Data\TaxRateTitleInterfaceFactory
- */
- protected $taxRateTitleDataObjectFactory;
-
- /**
- * @var FormatInterface|null
- */
- private $format;
-
- /**
- * @param \Magento\Tax\Api\Data\TaxRateInterfaceFactory $taxRateDataObjectFactory
- * @param \Magento\Tax\Api\Data\TaxRateTitleInterfaceFactory $taxRateTitleDataObjectFactory
+ * @param TaxRateInterfaceFactory $taxRateDataObjectFactory
+ * @param TaxRateTitleInterfaceFactory $taxRateTitleDataObjectFactory
* @param FormatInterface|null $format
*/
public function __construct(
- \Magento\Tax\Api\Data\TaxRateInterfaceFactory $taxRateDataObjectFactory,
- \Magento\Tax\Api\Data\TaxRateTitleInterfaceFactory $taxRateTitleDataObjectFactory,
- FormatInterface $format = null
+ protected readonly TaxRateInterfaceFactory $taxRateDataObjectFactory,
+ protected readonly TaxRateTitleInterfaceFactory $taxRateTitleDataObjectFactory,
+ private ?FormatInterface $format = null
) {
- $this->taxRateDataObjectFactory = $taxRateDataObjectFactory;
- $this->taxRateTitleDataObjectFactory = $taxRateTitleDataObjectFactory;
$this->format = $format ?: ObjectManager::getInstance()->get(FormatInterface::class);
}
/**
* Convert a tax rate data object to an array of associated titles
*
- * @param \Magento\Tax\Api\Data\TaxRateInterface $taxRate
+ * @param TaxRateInterface $taxRate
* @return array
*/
- public function createTitleArrayFromServiceObject(\Magento\Tax\Api\Data\TaxRateInterface $taxRate)
+ public function createTitleArrayFromServiceObject(TaxRateInterface $taxRate)
{
$titles = $taxRate->getTitles();
$titleData = [];
@@ -66,14 +52,14 @@ public function createTitleArrayFromServiceObject(\Magento\Tax\Api\Data\TaxRateI
/**
* Extract tax rate data in a format which is
*
- * @param \Magento\Tax\Api\Data\TaxRateInterface $taxRate
+ * @param TaxRateInterface $taxRate
* @param Boolean $returnNumericLogic
* @return array
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function createArrayFromServiceObject(
- \Magento\Tax\Api\Data\TaxRateInterface $taxRate,
+ TaxRateInterface $taxRate,
$returnNumericLogic = false
) {
$taxRateFormData = [
@@ -125,7 +111,7 @@ public function createArrayFromServiceObject(
* Convert an array to a tax rate data object
*
* @param array $formData
- * @return \Magento\Tax\Api\Data\TaxRateInterface
+ * @return TaxRateInterface
*/
public function populateTaxRateData($formData)
{
diff --git a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php
index b99f2776adf60..8e8bd08f89798 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php
@@ -13,9 +13,12 @@
*/
namespace Magento\Tax\Model\Calculation\Rate;
+use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\TaxRateTitleExtensionInterface;
use Magento\Tax\Api\Data\TaxRateTitleInterface;
+use Magento\Tax\Model\ResourceModel\Calculation\Rate\Title as ResourceCalculationRateTitle;
-class Title extends \Magento\Framework\Model\AbstractExtensibleModel implements TaxRateTitleInterface
+class Title extends AbstractExtensibleModel implements TaxRateTitleInterface
{
/**#@+
*
@@ -30,7 +33,7 @@ class Title extends \Magento\Framework\Model\AbstractExtensibleModel implements
*/
protected function _construct()
{
- $this->_init(\Magento\Tax\Model\ResourceModel\Calculation\Rate\Title::class);
+ $this->_init(ResourceCalculationRateTitle::class);
}
/**
@@ -87,7 +90,7 @@ public function setValue($value)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\TaxRateTitleExtensionInterface|null
+ * @return TaxRateTitleExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -97,10 +100,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\TaxRateTitleExtensionInterface $extensionAttributes
+ * @param TaxRateTitleExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRateTitleExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxRateTitleExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Calculation/RateFactory.php b/app/code/Magento/Tax/Model/Calculation/RateFactory.php
index 164509fbc7f85..c81f2f7630c88 100644
--- a/app/code/Magento/Tax/Model/Calculation/RateFactory.php
+++ b/app/code/Magento/Tax/Model/Calculation/RateFactory.php
@@ -11,17 +11,20 @@
*/
namespace Magento\Tax\Model\Calculation;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Tax\Model\Calculation\Rate as ModelCalculationRate;
+
class RateFactory
{
/**
- * @var \Magento\Framework\ObjectManagerInterface
+ * @var ObjectManagerInterface
*/
protected $_objectManager;
/**
- * @param \Magento\Framework\ObjectManagerInterface $objectManager
+ * @param ObjectManagerInterface $objectManager
*/
- public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
+ public function __construct(ObjectManagerInterface $objectManager)
{
$this->_objectManager = $objectManager;
}
@@ -30,10 +33,10 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
* Create new tax rate model
*
* @param array $arguments
- * @return \Magento\Tax\Model\Calculation\Rate
+ * @return ModelCalculationRate
*/
public function create(array $arguments = [])
{
- return $this->_objectManager->create(\Magento\Tax\Model\Calculation\Rate::class, $arguments);
+ return $this->_objectManager->create(ModelCalculationRate::class, $arguments);
}
}
diff --git a/app/code/Magento/Tax/Model/Calculation/RateRegistry.php b/app/code/Magento/Tax/Model/Calculation/RateRegistry.php
index 413db870d57d7..0ebb954c87ea5 100644
--- a/app/code/Magento/Tax/Model/Calculation/RateRegistry.php
+++ b/app/code/Magento/Tax/Model/Calculation/RateRegistry.php
@@ -12,13 +12,6 @@
class RateRegistry
{
- /**
- * Tax rate model factory
- *
- * @var TaxRateModelFactory
- */
- private $taxRateModelFactory;
-
/**
* Tax rate models
*
@@ -29,12 +22,11 @@ class RateRegistry
/**
* Constructor
*
- * @param TaxRateModelFactory $taxModelRateFactory
+ * @param TaxRateModelFactory $taxModelRateFactory Tax rate model factory
*/
public function __construct(
- TaxRateModelFactory $taxModelRateFactory
+ private readonly TaxRateModelFactory $taxModelRateFactory
) {
- $this->taxRateModelFactory = $taxModelRateFactory;
}
/**
diff --git a/app/code/Magento/Tax/Model/Calculation/RateRepository.php b/app/code/Magento/Tax/Model/Calculation/RateRepository.php
index 5b64ba333e5f7..c107612cc79a7 100644
--- a/app/code/Magento/Tax/Model/Calculation/RateRepository.php
+++ b/app/code/Magento/Tax/Model/Calculation/RateRepository.php
@@ -23,8 +23,11 @@
use Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory;
use Magento\Tax\Api\TaxRateRepositoryInterface;
use Magento\Tax\Model\Api\SearchCriteria\TaxRateCollectionProcessor;
+use Magento\Tax\Model\Calculation\Rate as ModelCalculationRate;
use Magento\Tax\Model\Calculation\Rate\Converter;
+use Magento\Tax\Model\ResourceModel\Calculation\Rate as ResourceCalculationRate;
use Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection;
+use Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection as CalculationRateCollection;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -34,84 +37,33 @@ class RateRepository implements TaxRateRepositoryInterface
public const MESSAGE_TAX_RATE_ID_IS_NOT_ALLOWED = 'id is not expected for this request.';
/**
- * Tax rate model and tax rate data object converter
- *
- * @var Converter
- */
- protected $converter;
-
- /**
- * Tax rate registry
- *
- * @var RateRegistry
- */
- protected $rateRegistry;
-
- /**
- * @var TaxRuleSearchResultsInterfaceFactory
- */
- private $taxRateSearchResultsFactory;
-
- /**
- * @var RateFactory
- */
- private $rateFactory;
-
- /**
- * @var \Magento\Directory\Model\CountryFactory
- */
- protected $countryFactory;
-
- /**
- * @var \Magento\Directory\Model\RegionFactory
- */
- protected $regionFactory;
-
- /**
- * @var \Magento\Tax\Model\ResourceModel\Calculation\Rate
+ * @var ResourceCalculationRate
*/
protected $resourceModel;
/**
- * @var JoinProcessorInterface
- */
- protected $joinProcessor;
-
- /**
- * @var \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface
- */
- private $collectionProcessor;
-
- /**
- * @param Converter $converter
- * @param RateRegistry $rateRegistry
+ * @param Converter $converter Tax rate model and tax rate data object converter
+ * @param RateRegistry $rateRegistry Tax rate registry
* @param TaxRuleSearchResultsInterfaceFactory $taxRateSearchResultsFactory
* @param RateFactory $rateFactory
* @param CountryFactory $countryFactory
* @param RegionFactory $regionFactory
- * @param \Magento\Tax\Model\ResourceModel\Calculation\Rate $rateResource
+ * @param ResourceCalculationRate $rateResource
* @param JoinProcessorInterface $joinProcessor
* @param CollectionProcessorInterface|null $collectionProcessor
*/
public function __construct(
- Converter $converter,
- RateRegistry $rateRegistry,
- TaxRuleSearchResultsInterfaceFactory $taxRateSearchResultsFactory,
- RateFactory $rateFactory,
- CountryFactory $countryFactory,
- RegionFactory $regionFactory,
- \Magento\Tax\Model\ResourceModel\Calculation\Rate $rateResource,
- JoinProcessorInterface $joinProcessor,
- CollectionProcessorInterface $collectionProcessor = null
+ protected readonly Converter $converter,
+ protected readonly RateRegistry $rateRegistry,
+ private readonly TaxRuleSearchResultsInterfaceFactory $taxRateSearchResultsFactory,
+ private readonly RateFactory $rateFactory,
+ protected readonly CountryFactory $countryFactory,
+ protected readonly RegionFactory $regionFactory,
+ ResourceCalculationRate $rateResource,
+ protected readonly JoinProcessorInterface $joinProcessor,
+ private ?CollectionProcessorInterface $collectionProcessor = null
) {
- $this->converter = $converter;
- $this->rateRegistry = $rateRegistry;
- $this->taxRateSearchResultsFactory = $taxRateSearchResultsFactory;
- $this->rateFactory = $rateFactory;
- $this->countryFactory = $countryFactory;
- $this->regionFactory = $regionFactory;
$this->resourceModel = $rateResource;
- $this->joinProcessor = $joinProcessor;
$this->collectionProcessor = $collectionProcessor
?? ObjectManager::getInstance()->get(
// phpcs:ignore Magento2.PHP.LiteralNamespaces
@@ -171,7 +123,7 @@ public function deleteById($rateId)
*/
public function getList(SearchCriteriaInterface $searchCriteria)
{
- /** @var \Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection $collection */
+ /** @var CalculationRateCollection $collection */
$collection = $this->rateFactory->create()->getCollection();
$this->joinProcessor->process($collection);
$collection->joinRegionTable();
@@ -179,7 +131,7 @@ public function getList(SearchCriteriaInterface $searchCriteria)
$this->collectionProcessor->process($searchCriteria, $collection);
$taxRate = [];
- /** @var \Magento\Tax\Model\Calculation\Rate $taxRateModel */
+ /** @var ModelCalculationRate $taxRateModel */
foreach ($collection as $taxRateModel) {
$taxRate[] = $taxRateModel;
}
diff --git a/app/code/Magento/Tax/Model/Calculation/Rule.php b/app/code/Magento/Tax/Model/Calculation/Rule.php
index d8060590e849b..a9b9571f63a57 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rule.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rule.php
@@ -7,12 +7,22 @@
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\ExtensionAttributesFactory;
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+use Magento\Tax\Api\Data\TaxRuleExtensionInterface;
use Magento\Tax\Api\Data\TaxRuleInterface;
+use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Calculation\Rule\Validator;
+use Magento\Tax\Model\ClassModel;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule as ResourceCalculationRule;
/**
* Tax Rule Model
*/
-class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements TaxRuleInterface
+class Rule extends AbstractExtensibleModel implements TaxRuleInterface
{
/**#@+
*
@@ -34,20 +44,15 @@ class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements T
/**
* Tax Model Class
*
- * @var \Magento\Tax\Model\ClassModel
+ * @var ClassModel
*/
protected $_taxClass;
/**
- * @var \Magento\Tax\Model\Calculation
+ * @var Calculation
*/
protected $_calculation;
- /**
- * @var \Magento\Tax\Model\Calculation\Rule\Validator
- */
- protected $validator;
-
/**
* Name of object id field
*
@@ -56,32 +61,31 @@ class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements T
protected $_idFieldName = 'tax_calculation_rule_id';
/**
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
+ * @param Context $context
+ * @param Registry $registry
* @param ExtensionAttributesFactory $extensionFactory
* @param AttributeValueFactory $customAttributeFactory
- * @param \Magento\Tax\Model\ClassModel $taxClass
- * @param \Magento\Tax\Model\Calculation $calculation
- * @param Rule\Validator $validator
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
+ * @param ClassModel $taxClass
+ * @param Calculation $calculation
+ * @param Validator $validator
+ * @param AbstractResource $resource
+ * @param AbstractDb $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
+ Context $context,
+ Registry $registry,
ExtensionAttributesFactory $extensionFactory,
AttributeValueFactory $customAttributeFactory,
- \Magento\Tax\Model\ClassModel $taxClass,
- \Magento\Tax\Model\Calculation $calculation,
- \Magento\Tax\Model\Calculation\Rule\Validator $validator,
- \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ ClassModel $taxClass,
+ Calculation $calculation,
+ protected readonly Validator $validator,
+ AbstractResource $resource = null,
+ AbstractDb $resourceCollection = null,
array $data = []
) {
$this->_calculation = $calculation;
- $this->validator = $validator;
parent::__construct(
$context,
$registry,
@@ -91,7 +95,7 @@ public function __construct(
$resourceCollection,
$data
);
- $this->_init(\Magento\Tax\Model\ResourceModel\Calculation\Rule::class);
+ $this->_init(ResourceCalculationRule::class);
$this->_taxClass = $taxClass;
}
@@ -147,7 +151,7 @@ public function saveCalculationData()
}
/**
- * @return \Magento\Tax\Model\Calculation
+ * @return Calculation
*/
public function getCalculationModel()
{
@@ -368,7 +372,7 @@ public function setCalculateSubtotal($calculateSubtotal)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\TaxRuleExtensionInterface|null
+ * @return TaxRuleExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -378,10 +382,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\TaxRuleExtensionInterface $extensionAttributes
+ * @param TaxRuleExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRuleExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxRuleExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Calculation/Rule/Validator.php b/app/code/Magento/Tax/Model/Calculation/Rule/Validator.php
index d9ad5c16fd762..b2681508bae6a 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rule/Validator.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rule/Validator.php
@@ -12,28 +12,24 @@
use Magento\Framework\Validator\NotEmpty;
use Magento\Framework\Validator\ValidateException;
use Magento\Framework\Validator\ValidatorChain;
+use Magento\Tax\Model\Calculation\Rule as ModelCalculationRule;
use Magento\Tax\Model\ClassModel as TaxClassModel;
use Magento\Tax\Model\ClassModelRegistry;
class Validator extends AbstractValidator
{
- /**
- * @var ClassModelRegistry
- */
- protected $classModelRegistry;
-
/**
* @param ClassModelRegistry $classModelRegistry
*/
- public function __construct(ClassModelRegistry $classModelRegistry)
- {
- $this->classModelRegistry = $classModelRegistry;
+ public function __construct(
+ protected readonly ClassModelRegistry $classModelRegistry
+ ) {
}
/**
* Validate rule model
*
- * @param \Magento\Tax\Model\Calculation\Rule $value
+ * @param ModelCalculationRule $value
* @return boolean
* @throws ValidateException If validation of $value is impossible
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
diff --git a/app/code/Magento/Tax/Model/Calculation/TaxRuleRegistry.php b/app/code/Magento/Tax/Model/Calculation/TaxRuleRegistry.php
index 1d8d22c7ffe0c..ba1cf31b8a028 100644
--- a/app/code/Magento/Tax/Model/Calculation/TaxRuleRegistry.php
+++ b/app/code/Magento/Tax/Model/Calculation/TaxRuleRegistry.php
@@ -12,11 +12,6 @@
class TaxRuleRegistry
{
- /**
- * @var \Magento\Tax\Model\Calculation\RuleFactory
- */
- private $taxRuleModelFactory;
-
/**
* @var array taxRuleId => TaxRuleModel
*/
@@ -28,9 +23,8 @@ class TaxRuleRegistry
* @param TaxRuleModelFactory $taxRuleModelFactory
*/
public function __construct(
- TaxRuleModelFactory $taxRuleModelFactory
+ private readonly TaxRuleModelFactory $taxRuleModelFactory
) {
- $this->taxRuleModelFactory = $taxRuleModelFactory;
}
/**
diff --git a/app/code/Magento/Tax/Model/Calculation/UnitBaseCalculator.php b/app/code/Magento/Tax/Model/Calculation/UnitBaseCalculator.php
index 655fcc9749cb3..85489cfbef1ac 100644
--- a/app/code/Magento/Tax/Model/Calculation/UnitBaseCalculator.php
+++ b/app/code/Magento/Tax/Model/Calculation/UnitBaseCalculator.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\Calculation;
+use Magento\Tax\Api\Data\AppliedTaxInterface;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
+use Magento\Tax\Api\Data\TaxDetailsItemInterface;
class UnitBaseCalculator extends AbstractCalculator
{
@@ -44,7 +46,7 @@ protected function roundAmount(
* @param QuoteDetailsItemInterface $item
* @param int $quantity
* @param bool $round
- * @return \Magento\Tax\Api\Data\TaxDetailsItemInterface
+ * @return TaxDetailsItemInterface
*/
protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true)
{
@@ -98,7 +100,7 @@ protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $qua
$rowTax = $uniTax * $quantity;
// Calculate applied taxes
- /** @var \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes */
+ /** @var AppliedTaxInterface[] $appliedTaxes */
$appliedRates = $this->calculationTool->getAppliedRates($taxRateRequest);
$appliedTaxes = $this->getAppliedTaxes($rowTax, $rate, $appliedRates);
@@ -122,7 +124,7 @@ protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $qua
* @param QuoteDetailsItemInterface $item
* @param int $quantity
* @param bool $round
- * @return \Magento\Tax\Api\Data\TaxDetailsItemInterface
+ * @return TaxDetailsItemInterface
*/
protected function calculateWithTaxNotInPrice(QuoteDetailsItemInterface $item, $quantity, $round = true)
{
diff --git a/app/code/Magento/Tax/Model/ClassModel.php b/app/code/Magento/Tax/Model/ClassModel.php
index 04a1557b7984d..f5558607633e7 100644
--- a/app/code/Magento/Tax/Model/ClassModel.php
+++ b/app/code/Magento/Tax/Model/ClassModel.php
@@ -7,13 +7,23 @@
namespace Magento\Tax\Model;
use Magento\Framework\Api\AttributeValueFactory;
+use Magento\Framework\Api\ExtensionAttributesFactory;
+use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Exception\CouldNotDeleteException;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+use Magento\Tax\Api\Data\TaxClassExtensionInterface;
+use Magento\Tax\Api\Data\TaxClassInterface;
+use Magento\Tax\Model\ResourceModel\TaxClass as ResourceTaxClass;
+use Magento\Tax\Model\TaxClass\Factory;
/**
* Tax class model
*/
-class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implements
- \Magento\Tax\Api\Data\TaxClassInterface
+class ClassModel extends AbstractExtensibleModel implements TaxClassInterface
{
/**#@+
* Constants defined for keys of array, makes typos less likely
@@ -34,28 +44,28 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem
const TAX_CLASS_TYPE_PRODUCT = 'PRODUCT';
/**
- * @var \Magento\Tax\Model\TaxClass\Factory
+ * @var Factory
*/
protected $_classFactory;
/**
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
+ * @param Context $context
+ * @param Registry $registry
+ * @param ExtensionAttributesFactory $extensionFactory
* @param AttributeValueFactory $customAttributeFactory
* @param TaxClass\Factory $classFactory
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
+ * @param AbstractResource $resource
+ * @param AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
+ Context $context,
+ Registry $registry,
+ ExtensionAttributesFactory $extensionFactory,
AttributeValueFactory $customAttributeFactory,
- \Magento\Tax\Model\TaxClass\Factory $classFactory,
- \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ Factory $classFactory,
+ AbstractResource $resource = null,
+ AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct(
@@ -75,7 +85,7 @@ public function __construct(
*/
public function _construct()
{
- $this->_init(\Magento\Tax\Model\ResourceModel\TaxClass::class);
+ $this->_init(ResourceTaxClass::class);
}
/**
@@ -117,7 +127,7 @@ protected function checkClassCanBeDeleted()
* Validate tax class can be deleted
*
* @return $this
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function beforeDelete()
{
@@ -188,7 +198,7 @@ public function setClassType($classType)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\TaxClassExtensionInterface|null
+ * @return TaxClassExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -198,10 +208,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\TaxClassExtensionInterface $extensionAttributes
+ * @param TaxClassExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxClassExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxClassExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/ClassModelRegistry.php b/app/code/Magento/Tax/Model/ClassModelRegistry.php
index 668d104f3ccfb..d97c3ecac514e 100644
--- a/app/code/Magento/Tax/Model/ClassModelRegistry.php
+++ b/app/code/Magento/Tax/Model/ClassModelRegistry.php
@@ -15,13 +15,6 @@
*/
class ClassModelRegistry
{
- /**
- * Tax class model factory
- *
- * @var TaxClassModelFactory
- */
- private $taxClassModelFactory;
-
/**
* Tax class models
*
@@ -32,11 +25,11 @@ class ClassModelRegistry
/**
* Initialize dependencies
*
- * @param TaxClassModelFactory $taxClassModelFactory
+ * @param TaxClassModelFactory $taxClassModelFactory Tax class model factory
*/
- public function __construct(TaxClassModelFactory $taxClassModelFactory)
- {
- $this->taxClassModelFactory = $taxClassModelFactory;
+ public function __construct(
+ private readonly TaxClassModelFactory $taxClassModelFactory
+ ) {
}
/**
diff --git a/app/code/Magento/Tax/Model/Config.php b/app/code/Magento/Tax/Model/Config.php
index 646da1441f225..e28b81fd7ca3d 100644
--- a/app/code/Magento/Tax/Model/Config.php
+++ b/app/code/Magento/Tax/Model/Config.php
@@ -11,6 +11,8 @@
*/
namespace Magento\Tax\Model;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
/**
@@ -149,23 +151,24 @@ class Config
/**
* Core store config
*
- * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ * @var ScopeConfigInterface
*/
protected $_scopeConfig;
/**
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
+ * @param ScopeConfigInterface $scopeConfig
*/
- public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
- {
+ public function __construct(
+ ScopeConfigInterface $scopeConfig
+ ) {
$this->_scopeConfig = $scopeConfig;
}
/**
* Check if prices of product in catalog include tax
*
- * @param null|string|bool|int|Store $store
- * @return bool
+ * @param null|string|bool|int|Store $store
+ * @return bool
*/
public function priceIncludesTax($store = null)
{
@@ -174,7 +177,7 @@ public function priceIncludesTax($store = null)
}
return (bool)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_PRICE_INCLUDES_TAX,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -198,14 +201,14 @@ public function setPriceIncludesTax($value)
/**
* Check what taxes should be applied after discount
*
- * @param null|string|bool|int|Store $store
- * @return bool
+ * @param null|string|bool|int|Store $store
+ * @return bool
*/
public function applyTaxAfterDiscount($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -216,14 +219,14 @@ public function applyTaxAfterDiscount($store = null)
* 2 - Including tax
* 3 - Both
*
- * @param null|string|bool|int|Store $store
- * @return int
+ * @param null|string|bool|int|Store $store
+ * @return int
*/
public function getPriceDisplayType($store = null)
{
return (int)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -231,14 +234,14 @@ public function getPriceDisplayType($store = null)
/**
* Get configuration setting "Apply Discount On Prices Including Tax" value
*
- * @param null|string|bool|int|Store $store
- * @return bool
+ * @param null|string|bool|int|Store $store
+ * @return bool
*/
public function discountTax($store = null)
{
return (int)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_DISCOUNT_TAX,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == 1;
}
@@ -248,22 +251,22 @@ public function discountTax($store = null)
*
* This sequence depends on "Apply Customer Tax" and "Apply Discount On Prices" configuration options.
*
- * @param null|int|string|Store $store
- * @return string
+ * @param null|int|string|Store $store
+ * @return string
*/
public function getCalculationSequence($store = null)
{
if ($this->applyTaxAfterDiscount($store)) {
if ($this->discountTax($store)) {
- $seq = \Magento\Tax\Model\Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL;
+ $seq = Calculation::CALC_TAX_AFTER_DISCOUNT_ON_INCL;
} else {
- $seq = \Magento\Tax\Model\Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL;
+ $seq = Calculation::CALC_TAX_AFTER_DISCOUNT_ON_EXCL;
}
} else {
if ($this->discountTax($store)) {
- $seq = \Magento\Tax\Model\Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL;
+ $seq = Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_INCL;
} else {
- $seq = \Magento\Tax\Model\Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL;
+ $seq = Calculation::CALC_TAX_BEFORE_DISCOUNT_ON_EXCL;
}
}
return $seq;
@@ -272,8 +275,8 @@ public function getCalculationSequence($store = null)
/**
* Specify flag what we need use shipping price exclude tax
*
- * @param bool $flag
- * @return \Magento\Tax\Model\Config
+ * @param bool $flag
+ * @return Config
*/
public function setNeedUseShippingExcludeTax($flag)
{
@@ -295,14 +298,14 @@ public function getNeedUseShippingExcludeTax()
/**
* Get defined tax calculation algorithm
*
- * @param null|string|bool|int|Store $store
- * @return string
+ * @param null|string|bool|int|Store $store
+ * @return string
*/
public function getAlgorithm($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_ALGORITHM,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -310,14 +313,14 @@ public function getAlgorithm($store = null)
/**
* Get tax class id specified for shipping tax estimation
*
- * @param null|string|bool|int|Store $store
- * @return int
+ * @param null|string|bool|int|Store $store
+ * @return int
*/
public function getShippingTaxClass($store = null)
{
return (int)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_SHIPPING_TAX_CLASS,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -325,14 +328,14 @@ public function getShippingTaxClass($store = null)
/**
* Get shipping methods prices display type
*
- * @param null|string|bool|int|Store $store
- * @return int
+ * @param null|string|bool|int|Store $store
+ * @return int
*/
public function getShippingPriceDisplayType($store = null)
{
return (int)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_DISPLAY_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -340,15 +343,15 @@ public function getShippingPriceDisplayType($store = null)
/**
* Check if shipping prices include tax
*
- * @param null|string|bool|int|Store $store
- * @return bool
+ * @param null|string|bool|int|Store $store
+ * @return bool
*/
public function shippingPriceIncludesTax($store = null)
{
if ($this->_shippingPriceIncludeTax === null) {
$this->_shippingPriceIncludeTax = (bool)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -377,7 +380,7 @@ public function displayCartPricesInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_PRICE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -392,7 +395,7 @@ public function displayCartPricesExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_PRICE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -407,7 +410,7 @@ public function displayCartPricesBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_PRICE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -422,7 +425,7 @@ public function displayCartSubtotalInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_SUBTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -437,7 +440,7 @@ public function displayCartSubtotalExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_SUBTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -452,7 +455,7 @@ public function displayCartSubtotalBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_SUBTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -467,7 +470,7 @@ public function displayCartShippingInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -482,7 +485,7 @@ public function displayCartShippingExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -497,7 +500,7 @@ public function displayCartShippingBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -514,7 +517,7 @@ public function displayCartDiscountInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -531,7 +534,7 @@ public function displayCartDiscountExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -548,7 +551,7 @@ public function displayCartDiscountBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -563,7 +566,7 @@ public function displayCartTaxWithGrandTotal($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_GRANDTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -578,7 +581,7 @@ public function displayCartFullSummary($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_FULL_SUMMARY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -593,7 +596,7 @@ public function displayCartZeroTax($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_CART_ZERO_TAX,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -608,7 +611,7 @@ public function displaySalesPricesInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_PRICE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -623,7 +626,7 @@ public function displaySalesPricesExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_PRICE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -638,7 +641,7 @@ public function displaySalesPricesBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_PRICE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -653,7 +656,7 @@ public function displaySalesSubtotalInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_SUBTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -668,7 +671,7 @@ public function displaySalesSubtotalExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_SUBTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -683,7 +686,7 @@ public function displaySalesSubtotalBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_SUBTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -698,7 +701,7 @@ public function displaySalesShippingInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -713,7 +716,7 @@ public function displaySalesShippingExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -728,7 +731,7 @@ public function displaySalesShippingBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_SHIPPING,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -745,7 +748,7 @@ public function displaySalesDiscountInclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_INCLUDING_TAX;
}
@@ -762,7 +765,7 @@ public function displaySalesDiscountExclTax($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_EXCLUDING_TAX;
}
@@ -779,7 +782,7 @@ public function displaySalesDiscountBoth($store = null)
{
return $this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
) == self::DISPLAY_TYPE_BOTH;
}
@@ -794,7 +797,7 @@ public function displaySalesTaxWithGrandTotal($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_GRANDTOTAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -809,7 +812,7 @@ public function displaySalesFullSummary($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_FULL_SUMMARY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -824,7 +827,7 @@ public function displaySalesZeroTax($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_DISPLAY_SALES_ZERO_TAX,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -839,7 +842,7 @@ public function crossBorderTradeEnabled($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -858,7 +861,7 @@ public function isWrongApplyDiscountSettingIgnored($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_TAX_NOTIFICATION_IGNORE_APPLY_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -873,7 +876,7 @@ public function isWrongDisplaySettingsIgnored($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_TAX_NOTIFICATION_IGNORE_PRICE_DISPLAY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -888,7 +891,7 @@ public function isWrongDiscountSettingsIgnored($store = null)
{
return (bool)$this->_scopeConfig->getValue(
self::XML_PATH_TAX_NOTIFICATION_IGNORE_DISCOUNT,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
@@ -903,7 +906,7 @@ public function getInfoUrl($store = null)
{
return (string)$this->_scopeConfig->getValue(
self::XML_PATH_TAX_NOTIFICATION_INFO_URL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ ScopeInterface::SCOPE_STORE,
$store
);
}
diff --git a/app/code/Magento/Tax/Model/Config/Notification.php b/app/code/Magento/Tax/Model/Config/Notification.php
index 758225e11e510..9c8adb3001096 100644
--- a/app/code/Magento/Tax/Model/Config/Notification.php
+++ b/app/code/Magento/Tax/Model/Config/Notification.php
@@ -5,13 +5,20 @@
*/
namespace Magento\Tax\Model\Config;
+use Magento\Config\Model\ResourceModel\Config as ResourceConfig;
+use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Config\Value;
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
use Magento\Tax\Model\Config;
/**
* Tax Config Notification
*/
-class Notification extends \Magento\Framework\App\Config\Value
+class Notification extends Value
{
/**
* @var string
@@ -19,31 +26,25 @@ class Notification extends \Magento\Framework\App\Config\Value
protected $_eventPrefix = 'tax_config_notification';
/**
- * @var \Magento\Config\Model\ResourceModel\Config
- */
- protected $resourceConfig;
-
- /**
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
- * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
- * @param \Magento\Config\Model\ResourceModel\Config $resourceConfig
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
+ * @param Context $context
+ * @param Registry $registry
+ * @param ScopeConfigInterface $config
+ * @param TypeListInterface $cacheTypeList
+ * @param ResourceConfig $resourceConfig
+ * @param AbstractResource|null $resource
+ * @param AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\App\Config\ScopeConfigInterface $config,
- \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
- \Magento\Config\Model\ResourceModel\Config $resourceConfig,
- \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ Context $context,
+ Registry $registry,
+ ScopeConfigInterface $config,
+ TypeListInterface $cacheTypeList,
+ protected readonly ResourceConfig $resourceConfig,
+ AbstractResource $resource = null,
+ AbstractDb $resourceCollection = null,
array $data = []
) {
- $this->resourceConfig = $resourceConfig;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
@@ -66,7 +67,7 @@ public function afterSave()
* Reset flag for showing tax notifications
*
* @param string $path
- * @return \Magento\Tax\Model\Config\Notification
+ * @return Notification
*/
protected function _resetNotificationFlag($path)
{
diff --git a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
index 06499d67ec0c6..23bb60473800e 100644
--- a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
+++ b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\Config\Price;
-class IncludePrice extends \Magento\Framework\App\Config\Value
+use Magento\Framework\App\Config\Value;
+
+class IncludePrice extends Value
{
/**
* @return $this
diff --git a/app/code/Magento/Tax/Model/Config/Source/Apply/On.php b/app/code/Magento/Tax/Model/Config/Source/Apply/On.php
index 3068574dbc899..8045194fe8d4d 100644
--- a/app/code/Magento/Tax/Model/Config/Source/Apply/On.php
+++ b/app/code/Magento/Tax/Model/Config/Source/Apply/On.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\Config\Source\Apply;
-class On implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+
+class On implements ArrayInterface
{
/**
* @return array
diff --git a/app/code/Magento/Tax/Model/Config/Source/Basedon.php b/app/code/Magento/Tax/Model/Config/Source/Basedon.php
index 0db022775448d..da4340faf0504 100644
--- a/app/code/Magento/Tax/Model/Config/Source/Basedon.php
+++ b/app/code/Magento/Tax/Model/Config/Source/Basedon.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\Config\Source;
-class Basedon implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+
+class Basedon implements ArrayInterface
{
/**
* @return array
diff --git a/app/code/Magento/Tax/Model/Config/Source/Catalog.php b/app/code/Magento/Tax/Model/Config/Source/Catalog.php
index f46089646579b..e8cacb86248af 100644
--- a/app/code/Magento/Tax/Model/Config/Source/Catalog.php
+++ b/app/code/Magento/Tax/Model/Config/Source/Catalog.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\Config\Source;
-class Catalog implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+
+class Catalog implements ArrayInterface
{
/**
* @return array
diff --git a/app/code/Magento/Tax/Model/Config/TaxClass.php b/app/code/Magento/Tax/Model/Config/TaxClass.php
index e389b837eaa26..d5414872d333b 100644
--- a/app/code/Magento/Tax/Model/Config/TaxClass.php
+++ b/app/code/Magento/Tax/Model/Config/TaxClass.php
@@ -5,45 +5,45 @@
*/
namespace Magento\Tax\Model\Config;
+use Magento\Catalog\Model\Product;
+use Magento\Config\Model\ResourceModel\Config;
+use Magento\Eav\Model\Entity\AttributeFactory;
+use Magento\Framework\App\Cache\TypeListInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Config\Value;
+use Magento\Framework\Data\Collection\AbstractDb;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Model\Context;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
+use Magento\Framework\Registry;
+
/**
* TaxClass Config
*/
-class TaxClass extends \Magento\Framework\App\Config\Value
+class TaxClass extends Value
{
/**
- * @var \Magento\Config\Model\ResourceModel\Config
- */
- protected $resourceConfig;
-
- /**
- * @var \Magento\Eav\Model\Entity\AttributeFactory
- */
- protected $attributeFactory;
-
- /**
- * @param \Magento\Framework\Model\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
- * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
- * @param \Magento\Config\Model\ResourceModel\Config $resourceConfig
- * @param \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory
- * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
- * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
+ * @param Context $context
+ * @param Registry $registry
+ * @param ScopeConfigInterface $config
+ * @param TypeListInterface $cacheTypeList
+ * @param Config $resourceConfig
+ * @param AttributeFactory $attributeFactory
+ * @param AbstractResource $resource
+ * @param AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(
- \Magento\Framework\Model\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Framework\App\Config\ScopeConfigInterface $config,
- \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
- \Magento\Config\Model\ResourceModel\Config $resourceConfig,
- \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory,
- \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
- \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ Context $context,
+ Registry $registry,
+ ScopeConfigInterface $config,
+ TypeListInterface $cacheTypeList,
+ protected readonly Config $resourceConfig,
+ protected readonly AttributeFactory $attributeFactory,
+ AbstractResource $resource = null,
+ AbstractDb $resourceCollection = null,
array $data = []
) {
- $this->resourceConfig = $resourceConfig;
- $this->attributeFactory = $attributeFactory;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
@@ -57,9 +57,9 @@ public function afterSave()
$attributeCode = "tax_class_id";
$attribute = $this->attributeFactory->create();
- $attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, $attributeCode);
+ $attribute->loadByCode(Product::ENTITY, $attributeCode);
if (!$attribute->getId()) {
- throw new \Magento\Framework\Exception\LocalizedException(__('Invalid attribute %1', $attributeCode));
+ throw new LocalizedException(__('Invalid attribute %1', $attributeCode));
}
$attribute->setData("default_value", $this->getData('value'));
$attribute->save();
diff --git a/app/code/Magento/Tax/Model/Layout/DepersonalizePlugin.php b/app/code/Magento/Tax/Model/Layout/DepersonalizePlugin.php
index 6959f0a0d7c7c..f2a5c636d7b64 100644
--- a/app/code/Magento/Tax/Model/Layout/DepersonalizePlugin.php
+++ b/app/code/Magento/Tax/Model/Layout/DepersonalizePlugin.php
@@ -17,16 +17,6 @@
*/
class DepersonalizePlugin
{
- /**
- * @var DepersonalizeChecker
- */
- private $depersonalizeChecker;
-
- /**
- * @var CustomerSession
- */
- private $customerSession;
-
/**
* @var array
*/
@@ -47,11 +37,9 @@ class DepersonalizePlugin
* @param CustomerSession $customerSession
*/
public function __construct(
- DepersonalizeChecker $depersonalizeChecker,
- CustomerSession $customerSession
+ private readonly DepersonalizeChecker $depersonalizeChecker,
+ private readonly CustomerSession $customerSession
) {
- $this->depersonalizeChecker = $depersonalizeChecker;
- $this->customerSession = $customerSession;
}
/**
diff --git a/app/code/Magento/Tax/Model/Plugin/OrderSave.php b/app/code/Magento/Tax/Model/Plugin/OrderSave.php
index b46c5b51a9db2..d1d4c2c0f28df 100644
--- a/app/code/Magento/Tax/Model/Plugin/OrderSave.php
+++ b/app/code/Magento/Tax/Model/Plugin/OrderSave.php
@@ -7,43 +7,39 @@
namespace Magento\Tax\Model\Plugin;
+use Magento\Sales\Api\Data\OrderInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Sales\Model\Order\Tax\Item;
+use Magento\Sales\Model\Order\Tax\ItemFactory;
use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtension;
+use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsItemInterface;
+use Magento\Tax\Model\Sales\Order\Tax;
+use Magento\Tax\Model\Sales\Order\TaxFactory;
class OrderSave
{
/**
- * @var \Magento\Tax\Model\Sales\Order\TaxFactory
- */
- protected $orderTaxFactory;
-
- /**
- * @var \Magento\Sales\Model\Order\Tax\ItemFactory
- */
- protected $taxItemFactory;
-
- /**
- * @param \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory
- * @param \Magento\Sales\Model\Order\Tax\ItemFactory $taxItemFactory
+ * @param TaxFactory $orderTaxFactory
+ * @param ItemFactory $taxItemFactory
*/
public function __construct(
- \Magento\Tax\Model\Sales\Order\TaxFactory $orderTaxFactory,
- \Magento\Sales\Model\Order\Tax\ItemFactory $taxItemFactory
+ protected readonly TaxFactory $orderTaxFactory,
+ protected readonly ItemFactory $taxItemFactory
) {
- $this->orderTaxFactory = $orderTaxFactory;
- $this->taxItemFactory = $taxItemFactory;
}
/**
* Save order tax
*
- * @param \Magento\Sales\Api\OrderRepositoryInterface $subject
- * @param \Magento\Sales\Api\Data\OrderInterface $order
- * @return \Magento\Sales\Api\Data\OrderInterface
+ * @param OrderRepositoryInterface $subject
+ * @param OrderInterface $order
+ * @return OrderInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(
- \Magento\Sales\Api\OrderRepositoryInterface $subject,
- \Magento\Sales\Api\Data\OrderInterface $order
+ OrderRepositoryInterface $subject,
+ OrderInterface $order
) {
$this->saveOrderTax($order);
return $order;
@@ -52,14 +48,14 @@ public function afterSave(
/**
* Save order tax
*
- * @param \Magento\Sales\Api\Data\OrderInterface $order
+ * @param OrderInterface $order
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* phpcs:disable Generic.Metrics.NestingLevel.TooHigh
*/
- protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
+ protected function saveOrderTax(OrderInterface $order)
{
$extensionAttribute = $order->getExtensionAttributes();
if (!$extensionAttribute ||
@@ -68,13 +64,13 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
return;
}
- /** @var \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface[]|null $taxes */
+ /** @var OrderTaxDetailsAppliedTaxInterface[]|null $taxes */
$taxes = $extensionAttribute->getAppliedTaxes();
if ($taxes == null) {
$taxes = [];
}
- /** @var \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[]|null $taxesForItems */
+ /** @var OrderTaxDetailsItemInterface[]|null $taxesForItems */
$taxesForItems = $extensionAttribute->getItemAppliedTaxes();
if ($taxesForItems == null) {
$taxesForItems = [];
@@ -161,7 +157,7 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
'base_real_amount' => $baseRealAmount,
];
- /** @var $orderTax \Magento\Tax\Model\Sales\Order\Tax */
+ /** @var Tax $orderTax */
$orderTax = $this->orderTaxFactory->create();
$result = $orderTax->setData($data)->save();
@@ -195,7 +191,7 @@ protected function saveOrderTax(\Magento\Sales\Api\Data\OrderInterface $order)
'real_base_amount' => $quoteItemId['real_base_amount'],
'taxable_item_type' => $quoteItemId['item_type'],
];
- /** @var $taxItem \Magento\Sales\Model\Order\Tax\Item */
+ /** @var Item $taxItem */
$taxItem = $this->taxItemFactory->create();
$taxItem->setData($data)->save();
}
diff --git a/app/code/Magento/Tax/Model/Quote/GrandTotalDetailsPlugin.php b/app/code/Magento/Tax/Model/Quote/GrandTotalDetailsPlugin.php
index 0ba5e8822ed67..7f8e89c44c017 100644
--- a/app/code/Magento/Tax/Model/Quote/GrandTotalDetailsPlugin.php
+++ b/app/code/Magento/Tax/Model/Quote/GrandTotalDetailsPlugin.php
@@ -8,60 +8,36 @@
use Magento\Quote\Api\Data\TotalSegmentExtensionFactory;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\App\ObjectManager;
+use Magento\Quote\Api\Data\TotalSegmentInterface;
+use Magento\Quote\Model\Cart\TotalsConverter;
+use Magento\Quote\Model\Quote\Address\Total as QuoteAddressTotal;
+use Magento\Tax\Api\Data\GrandTotalDetailsInterfaceFactory;
+use Magento\Tax\Api\Data\GrandTotalRatesInterfaceFactory;
+use Magento\Tax\Model\Config as TaxConfig;
class GrandTotalDetailsPlugin
{
- /**
- * @var \Magento\Tax\Api\Data\GrandTotalDetailsInterfaceFactory
- */
- private $detailsFactory;
-
- /**
- * @var \Magento\Tax\Api\Data\GrandTotalRatesInterfaceFactory
- */
- private $ratesFactory;
-
- /**
- * @var TotalSegmentExtensionFactory
- */
- private $totalSegmentExtensionFactory;
-
- /**
- * @var \Magento\Tax\Model\Config
- */
- private $taxConfig;
-
/**
* @var string
*/
private $code;
- /**
- * @var Json
- */
- private $serializer;
-
/**
* Constructor
*
- * @param \Magento\Tax\Api\Data\GrandTotalDetailsInterfaceFactory $detailsFactory
- * @param \Magento\Tax\Api\Data\GrandTotalRatesInterfaceFactory $ratesFactory
+ * @param GrandTotalDetailsInterfaceFactory $detailsFactory
+ * @param GrandTotalRatesInterfaceFactory $ratesFactory
* @param TotalSegmentExtensionFactory $totalSegmentExtensionFactory
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxConfig $taxConfig
* @param Json $serializer
*/
public function __construct(
- \Magento\Tax\Api\Data\GrandTotalDetailsInterfaceFactory $detailsFactory,
- \Magento\Tax\Api\Data\GrandTotalRatesInterfaceFactory $ratesFactory,
- TotalSegmentExtensionFactory $totalSegmentExtensionFactory,
- \Magento\Tax\Model\Config $taxConfig,
- Json $serializer
+ private readonly GrandTotalDetailsInterfaceFactory $detailsFactory,
+ private readonly GrandTotalRatesInterfaceFactory $ratesFactory,
+ private readonly TotalSegmentExtensionFactory $totalSegmentExtensionFactory,
+ private readonly TaxConfig $taxConfig,
+ private readonly Json $serializer
) {
- $this->detailsFactory = $detailsFactory;
- $this->ratesFactory = $ratesFactory;
- $this->totalSegmentExtensionFactory = $totalSegmentExtensionFactory;
- $this->taxConfig = $taxConfig;
- $this->serializer = $serializer;
$this->code = 'tax';
}
@@ -82,15 +58,15 @@ protected function getRatesData($rates)
}
/**
- * @param \Magento\Quote\Model\Cart\TotalsConverter $subject
- * @param \Magento\Quote\Api\Data\TotalSegmentInterface[] $totalSegments
- * @param \Magento\Quote\Model\Quote\Address\Total[] $addressTotals
- * @return \Magento\Quote\Api\Data\TotalSegmentInterface[]
+ * @param TotalsConverter $subject
+ * @param TotalSegmentInterface[] $totalSegments
+ * @param QuoteAddressTotal[] $addressTotals
+ * @return TotalSegmentInterface[]
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function afterProcess(
- \Magento\Quote\Model\Cart\TotalsConverter $subject,
+ TotalsConverter $subject,
array $totalSegments,
array $addressTotals = []
) {
diff --git a/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php b/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php
index 8764748f1bfdd..c2be1f1fe8eee 100644
--- a/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php
+++ b/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php
@@ -5,9 +5,11 @@
*/
namespace Magento\Tax\Model\Quote;
+use Magento\Sales\Api\Data\OrderExtensionFactory;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Quote\Model\Quote\Address\ToOrder as QuoteAddressToOrder;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
+use Magento\Sales\Model\Order;
class ToOrderConverter
{
@@ -17,17 +19,11 @@ class ToOrderConverter
protected $quoteAddress;
/**
- * @var \Magento\Sales\Api\Data\OrderExtensionFactory
- */
- protected $orderExtensionFactory;
-
- /**
- * @param \Magento\Sales\Api\Data\OrderExtensionFactory $orderExtensionFactory
+ * @param OrderExtensionFactory $orderExtensionFactory
*/
public function __construct(
- \Magento\Sales\Api\Data\OrderExtensionFactory $orderExtensionFactory
+ protected readonly OrderExtensionFactory $orderExtensionFactory
) {
- $this->orderExtensionFactory = $orderExtensionFactory;
}
/**
@@ -51,7 +47,7 @@ public function beforeConvert(QuoteAddressToOrder $subject, QuoteAddress $addres
*/
public function afterConvert(QuoteAddressToOrder $subject, OrderInterface $order)
{
- /** @var \Magento\Sales\Model\Order $order */
+ /** @var Order $order */
$taxes = $this->quoteAddress->getAppliedTaxes();
$extensionAttributes = $order->getExtensionAttributes();
if ($extensionAttributes == null) {
diff --git a/app/code/Magento/Tax/Model/Rate/Provider.php b/app/code/Magento/Tax/Model/Rate/Provider.php
index 0edf46c320a9e..39a7156afa102 100644
--- a/app/code/Magento/Tax/Model/Rate/Provider.php
+++ b/app/code/Magento/Tax/Model/Rate/Provider.php
@@ -16,16 +16,6 @@
*/
class Provider
{
- /**
- * @var TaxRateRepositoryInterface
- */
- private $taxRateRepository;
-
- /**
- * @var Converter
- */
- private $converter;
-
/**
* @var int
*/
@@ -38,11 +28,9 @@ class Provider
* @param Converter $converter
*/
public function __construct(
- TaxRateRepositoryInterface $taxRateRepository,
- Converter $converter
+ private readonly TaxRateRepositoryInterface $taxRateRepository,
+ private readonly Converter $converter
) {
- $this->taxRateRepository = $taxRateRepository;
- $this->converter = $converter;
}
/**
diff --git a/app/code/Magento/Tax/Model/Rate/Source.php b/app/code/Magento/Tax/Model/Rate/Source.php
index a7d2ed439b91b..72261a22aeedf 100644
--- a/app/code/Magento/Tax/Model/Rate/Source.php
+++ b/app/code/Magento/Tax/Model/Rate/Source.php
@@ -9,39 +9,20 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Convert\DataObject as Converter;
+use Magento\Framework\Data\OptionSourceInterface;
use Magento\Tax\Api\TaxRateRepositoryInterface;
use Magento\Tax\Model\Rate\Provider as RateProvider;
/**
* Tax rate source model.
*/
-class Source implements \Magento\Framework\Data\OptionSourceInterface
+class Source implements OptionSourceInterface
{
/**
* @var array
*/
protected $options;
- /**
- * @var \Magento\Tax\Api\TaxRateRepositoryInterface
- */
- protected $taxRateRepository;
-
- /**
- * @var \Magento\Framework\Api\SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
- /**
- * @var \Magento\Framework\Convert\DataObject
- */
- protected $converter;
-
- /**
- * @var \Magento\Tax\Model\Rate\Provider
- */
- protected $rateProvider;
-
/**
* Initialize dependencies.
*
@@ -51,14 +32,11 @@ class Source implements \Magento\Framework\Data\OptionSourceInterface
* @param RateProvider $rateProvider
*/
public function __construct(
- TaxRateRepositoryInterface $taxRateRepository,
- SearchCriteriaBuilder $searchCriteriaBuilder,
- Converter $converter,
- RateProvider $rateProvider = null
+ protected readonly TaxRateRepositoryInterface $taxRateRepository,
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder,
+ protected readonly Converter $converter,
+ protected ?RateProvider $rateProvider = null
) {
- $this->taxRateRepository = $taxRateRepository;
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
- $this->converter = $converter;
$this->rateProvider = $rateProvider ?: ObjectManager::getInstance()->get(RateProvider::class);
}
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation.php
index 00de17ff5d3bf..9ff6fc4ad3bf1 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation.php
@@ -9,7 +9,14 @@
*/
namespace Magento\Tax\Model\ResourceModel;
-class Calculation extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
+use Magento\Framework\DataObject;
+use Magento\Framework\DB\Select;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Tax\Helper\Data as TaxHelper;
+
+class Calculation extends AbstractDb
{
/**
* Store ISO 3166-1 alpha-2 USA country code
@@ -24,25 +31,25 @@ class Calculation extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
protected $_ratesCache = [];
/**
- * @var \Magento\Tax\Helper\Data
+ * @var TaxHelper
*/
protected $_taxData;
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StoreManagerInterface
*/
protected $_storeManager;
/**
- * @param \Magento\Framework\Model\ResourceModel\Db\Context $context
- * @param \Magento\Tax\Helper\Data $taxData
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param Context $context
+ * @param TaxHelper $taxData
+ * @param StoreManagerInterface $storeManager
* @param string $connectionName
*/
public function __construct(
- \Magento\Framework\Model\ResourceModel\Db\Context $context,
- \Magento\Tax\Helper\Data $taxData,
- \Magento\Store\Model\StoreManagerInterface $storeManager,
+ Context $context,
+ TaxHelper $taxData,
+ StoreManagerInterface $storeManager,
$connectionName = null
) {
$this->_taxData = $taxData;
@@ -78,8 +85,8 @@ public function deleteByRuleId($ruleId)
/**
* Retrieve distinct calculation
*
- * @param string $field
- * @param int $ruleId
+ * @param string $field
+ * @param int $ruleId
* @return array
*/
public function getCalculationsById($field, $ruleId)
@@ -93,7 +100,7 @@ public function getCalculationsById($field, $ruleId)
/**
* Get tax rate information: calculation process data and tax rate
*
- * @param \Magento\Framework\DataObject $request
+ * @param DataObject $request
* @return array
*/
public function getRateInfo($request)
@@ -108,7 +115,7 @@ public function getRateInfo($request)
/**
* Get tax rate for specific tax rate request
*
- * @param \Magento\Framework\DataObject $request
+ * @param DataObject $request
* @return int
*/
public function getRate($request)
@@ -119,7 +126,7 @@ public function getRate($request)
/**
* Retrieve Calculation Process
*
- * @param \Magento\Framework\DataObject $request
+ * @param DataObject $request
* @param array|null $rates
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
@@ -256,7 +263,7 @@ protected function _createSearchPostCodeTemplates($postcode, $exactPostcode = nu
*
* Notice that productClassId due to optimization can be array of ids.
*
- * @param \Magento\Framework\DataObject $request
+ * @param DataObject $request
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -387,17 +394,17 @@ protected function _getRates($request)
}
$select->order(
- 'priority ' . \Magento\Framework\DB\Select::SQL_ASC
+ 'priority ' . Select::SQL_ASC
)->order(
- 'tax_calculation_rule_id ' . \Magento\Framework\DB\Select::SQL_ASC
+ 'tax_calculation_rule_id ' . Select::SQL_ASC
)->order(
- 'tax_country_id ' . \Magento\Framework\DB\Select::SQL_DESC
+ 'tax_country_id ' . Select::SQL_DESC
)->order(
- 'tax_region_id ' . \Magento\Framework\DB\Select::SQL_DESC
+ 'tax_region_id ' . Select::SQL_DESC
)->order(
- 'tax_postcode ' . \Magento\Framework\DB\Select::SQL_DESC
+ 'tax_postcode ' . Select::SQL_DESC
)->order(
- 'value ' . \Magento\Framework\DB\Select::SQL_DESC
+ 'value ' . Select::SQL_DESC
);
$fetchResult = $this->getConnection()->fetchAll($select);
@@ -454,7 +461,7 @@ protected function _calculateRate($rates)
/**
* Retrieve rate ids
*
- * @param \Magento\Framework\DataObject $request
+ * @param DataObject $request
* @return array
*/
public function getRateIds($request)
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Collection.php
index 1dd699cca311d..d1b0e227980a2 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Collection.php
@@ -5,12 +5,16 @@
*/
namespace Magento\Tax\Model\ResourceModel\Calculation;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Tax\Model\Calculation as ModelCalculation;
+use Magento\Tax\Model\ResourceModel\Calculation as ResourceCalculation;
+
/**
* Tax Calculation Collection
*
* @author Magento Core Team
*/
-class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+class Collection extends AbstractCollection
{
/**
* Resource initialization
@@ -19,6 +23,6 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/
protected function _construct()
{
- $this->_init(\Magento\Tax\Model\Calculation::class, \Magento\Tax\Model\ResourceModel\Calculation::class);
+ $this->_init(ModelCalculation::class, ResourceCalculation::class);
}
}
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate.php
index 2ae4165a82e83..7edcd363ce267 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate.php
@@ -11,7 +11,9 @@
*/
namespace Magento\Tax\Model\ResourceModel\Calculation;
-class Rate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+
+class Rate extends AbstractDb
{
/**
* Resource initialization
@@ -48,7 +50,7 @@ public function deleteAllRates()
/**
* Check if this rate exists in rule
*
- * @param int $rateId
+ * @param int $rateId
* @return array
*/
public function isInRule($rateId)
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Collection.php
index d34e863d56c54..fa3c8954dd32c 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Collection.php
@@ -44,7 +44,7 @@ class Collection extends AbstractCollection
* @param ManagerInterface $eventManager
* @param StoreManagerInterface $storeManager
* @param mixed $connection
- * @param AbstractDb $resource
+ * @param AbstractDb|null $resource
*/
public function __construct(
EntityFactory $entityFactory,
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title.php
index 535336a513c68..b93217c1f993c 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title.php
@@ -5,12 +5,14 @@
*/
namespace Magento\Tax\Model\ResourceModel\Calculation\Rate;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+
/**
* Tax Rate Title Collection
*
* @author Magento Core Team
*/
-class Title extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
+class Title extends AbstractDb
{
/**
* Resource initialization
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title/Collection.php
index 32cc3ae7f491c..c64638671cafc 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rate/Title/Collection.php
@@ -5,12 +5,17 @@
*/
namespace Magento\Tax\Model\ResourceModel\Calculation\Rate\Title;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Tax\Model\Calculation\Rate\Title as ModelCalculationRateTitle;
+use Magento\Tax\Model\ResourceModel\Calculation\Rate\Title as ResourceCalculationRateTitle;
+use Magento\Tax\Model\ResourceModel\Calculation\Rate\Title\Collection as CalculationRateTitleCollection;
+
/**
* Tax Rate Title Collection
*
* @author Magento Core Team
*/
-class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+class Collection extends AbstractCollection
{
/**
* Resource initialization
@@ -20,8 +25,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
protected function _construct()
{
$this->_init(
- \Magento\Tax\Model\Calculation\Rate\Title::class,
- \Magento\Tax\Model\ResourceModel\Calculation\Rate\Title::class
+ ModelCalculationRateTitle::class,
+ ResourceCalculationRateTitle::class
);
}
@@ -29,7 +34,7 @@ protected function _construct()
* Add rate id filter
*
* @param int $rateId
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rate\Title\Collection
+ * @return CalculationRateTitleCollection
*/
public function loadByRateId($rateId)
{
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule.php
index 91fd0f4dcffb3..11d201a983a1d 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule.php
@@ -5,12 +5,14 @@
*/
namespace Magento\Tax\Model\ResourceModel\Calculation;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+
/**
* Tax rule resource model
*
* @author Magento Core Team
*/
-class Rule extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
+class Rule extends AbstractDb
{
/**
* Resource initialization
@@ -25,7 +27,7 @@ protected function _construct()
/**
* Initialize unique fields
*
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule
+ * @return Rule
*/
protected function _initUniqueFields()
{
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule/Collection.php
index 2d355b6cc48c9..e9c7396c3a10f 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Calculation/Rule/Collection.php
@@ -5,12 +5,19 @@
*/
namespace Magento\Tax\Model\ResourceModel\Calculation\Rule;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Tax\Model\Calculation\Rule as ModelCalculationRule;
+use Magento\Tax\Model\ClassModel;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule as ResourceCalculationRule;
+use Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection as CalculationRuleCollection;
+
/**
* Tax rule collection
*
* @author Magento Core Team
*/
-class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+class Collection extends AbstractCollection
{
/**
* Resource initialization
@@ -20,8 +27,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
protected function _construct()
{
$this->_init(
- \Magento\Tax\Model\Calculation\Rule::class,
- \Magento\Tax\Model\ResourceModel\Calculation\Rule::class
+ ModelCalculationRule::class,
+ ResourceCalculationRule::class
);
}
@@ -43,7 +50,7 @@ protected function _afterLoadData()
* Join calculation data to result
*
* @param string $alias table alias
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection
+ * @return CalculationRuleCollection
*/
public function joinCalculationData($alias)
{
@@ -66,7 +73,7 @@ public function joinCalculationData($alias)
* @param string $titleField
* @param string $dataField
* @param string $dataTitleField
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection
+ * @return CalculationRuleCollection
*/
protected function _add(
$itemTable,
@@ -117,7 +124,7 @@ protected function _add(
/**
* Add product tax classes to result
*
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection
+ * @return CalculationRuleCollection
*/
public function addProductTaxClassesToResult()
{
@@ -127,7 +134,7 @@ public function addProductTaxClassesToResult()
/**
* Add customer tax classes to result
*
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection
+ * @return CalculationRuleCollection
*/
public function addCustomerTaxClassesToResult()
{
@@ -137,7 +144,7 @@ public function addCustomerTaxClassesToResult()
/**
* Add rates to result
*
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection
+ * @return CalculationRuleCollection
*/
public function addRatesToResult()
{
@@ -156,20 +163,20 @@ public function addRatesToResult()
*
* @param string $type
* @param int $id
- * @return \Magento\Tax\Model\ResourceModel\Calculation\Rule\Collection
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @return CalculationRuleCollection
+ * @throws LocalizedException
*/
public function setClassTypeFilter($type, $id)
{
switch ($type) {
- case \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT:
+ case ClassModel::TAX_CLASS_TYPE_PRODUCT:
$field = 'cd.product_tax_class_id';
break;
- case \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER:
+ case ClassModel::TAX_CLASS_TYPE_CUSTOMER:
$field = 'cd.customer_tax_class_id';
break;
default:
- throw new \Magento\Framework\Exception\LocalizedException(__('Invalid type supplied'));
+ throw new LocalizedException(__('Invalid type supplied'));
break;
}
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Report/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Report/Collection.php
index 68e35e14bc478..a6bb867d59ea1 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Report/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Report/Collection.php
@@ -11,10 +11,19 @@
*/
namespace Magento\Tax\Model\ResourceModel\Report;
-class Collection extends \Magento\Sales\Model\ResourceModel\Report\Collection\AbstractCollection
+use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
+use Magento\Framework\Data\Collection\EntityFactory;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\Event\ManagerInterface;
+use Magento\Sales\Model\ResourceModel\Report;
+use Magento\Sales\Model\ResourceModel\Report\Collection\AbstractCollection;
+use Psr\Log\LoggerInterface;
+use Zend_Db_Expr;
+
+class Collection extends AbstractCollection
{
/**
- * @var \Zend_Db_Expr
+ * @var Zend_Db_Expr
*/
protected $_periodFormat;
@@ -31,20 +40,20 @@ class Collection extends \Magento\Sales\Model\ResourceModel\Report\Collection\Ab
protected $_selectedColumns = [];
/**
- * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
- * @param \Magento\Framework\Event\ManagerInterface $eventManager
- * @param \Magento\Sales\Model\ResourceModel\Report $resource
+ * @param EntityFactory $entityFactory
+ * @param LoggerInterface $logger
+ * @param FetchStrategyInterface $fetchStrategy
+ * @param ManagerInterface $eventManager
+ * @param Report $resource
* @param mixed $connection
*/
public function __construct(
- \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
- \Magento\Framework\Event\ManagerInterface $eventManager,
- \Magento\Sales\Model\ResourceModel\Report $resource,
- \Magento\Framework\DB\Adapter\AdapterInterface $connection = null
+ EntityFactory $entityFactory,
+ LoggerInterface $logger,
+ FetchStrategyInterface $fetchStrategy,
+ ManagerInterface $eventManager,
+ Report $resource,
+ AdapterInterface $connection = null
) {
$resource->init($this->_aggregationTable);
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $resource, $connection);
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Report/Tax.php b/app/code/Magento/Tax/Model/ResourceModel/Report/Tax.php
index 53f20a869c3fb..189367671c783 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Report/Tax.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Report/Tax.php
@@ -9,38 +9,51 @@
*/
namespace Magento\Tax\Model\ResourceModel\Report;
-class Tax extends \Magento\Reports\Model\ResourceModel\Report\AbstractReport
+use Magento\Framework\Model\ResourceModel\Db\Context;
+use Magento\Framework\Stdlib\DateTime\DateTime as FrameworkDateTime;
+use Magento\Framework\Stdlib\DateTime\Timezone\Validator;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Reports\Model\Flag;
+use Magento\Reports\Model\FlagFactory;
+use Magento\Reports\Model\ResourceModel\Report\AbstractReport;
+use Magento\Tax\Model\ResourceModel\Report\Tax\Createdat;
+use Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory;
+use Magento\Tax\Model\ResourceModel\Report\Tax\Updatedat;
+use Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory;
+use Psr\Log\LoggerInterface;
+
+class Tax extends AbstractReport
{
/**
- * @var \Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory
+ * @var CreatedatFactory
*/
protected $_createdAtFactory;
/**
- * @var \Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory
+ * @var UpdatedatFactory
*/
protected $_updatedAtFactory;
/**
- * @param \Magento\Framework\Model\ResourceModel\Db\Context $context
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
- * @param \Magento\Reports\Model\FlagFactory $reportsFlagFactory
- * @param \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator
- * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
- * @param \Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory $createdAtFactory
- * @param \Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory $updatedAtFactory
+ * @param Context $context
+ * @param LoggerInterface $logger
+ * @param TimezoneInterface $localeDate
+ * @param FlagFactory $reportsFlagFactory
+ * @param Validator $timezoneValidator
+ * @param FrameworkDateTime $dateTime
+ * @param CreatedatFactory $createdAtFactory
+ * @param UpdatedatFactory $updatedAtFactory
* @param string $connectionName
*/
public function __construct(
- \Magento\Framework\Model\ResourceModel\Db\Context $context,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
- \Magento\Reports\Model\FlagFactory $reportsFlagFactory,
- \Magento\Framework\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
- \Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
- \Magento\Tax\Model\ResourceModel\Report\Tax\CreatedatFactory $createdAtFactory,
- \Magento\Tax\Model\ResourceModel\Report\Tax\UpdatedatFactory $updatedAtFactory,
+ Context $context,
+ LoggerInterface $logger,
+ TimezoneInterface $localeDate,
+ FlagFactory $reportsFlagFactory,
+ Validator $timezoneValidator,
+ FrameworkDateTime $dateTime,
+ CreatedatFactory $createdAtFactory,
+ UpdatedatFactory $updatedAtFactory,
$connectionName = null
) {
$this->_createdAtFactory = $createdAtFactory;
@@ -75,14 +88,14 @@ protected function _construct()
*/
public function aggregate($from = null, $to = null)
{
- /** @var $createdAt \Magento\Tax\Model\ResourceModel\Report\Tax\Createdat */
+ /** @var Createdat $createdAt */
$createdAt = $this->_createdAtFactory->create();
- /** @var $updatedAt \Magento\Tax\Model\ResourceModel\Report\Tax\Updatedat */
+ /** @var Updatedat $updatedAt */
$updatedAt = $this->_updatedAtFactory->create();
$createdAt->aggregate($from, $to);
$updatedAt->aggregate($from, $to);
- $this->_setFlagData(\Magento\Reports\Model\Flag::REPORT_TAX_FLAG_CODE);
+ $this->_setFlagData(Flag::REPORT_TAX_FLAG_CODE);
return $this;
}
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Createdat.php b/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Createdat.php
index 60cb6fe2898ae..14ec23d533cfa 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Createdat.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Createdat.php
@@ -11,10 +11,16 @@
*/
namespace Magento\Tax\Model\ResourceModel\Report\Tax;
+use Exception;
+use Magento\Reports\Model\ResourceModel\Report\AbstractReport;
+use Magento\Sales\Model\Order;
+use Magento\Store\Model\Store;
+use Zend_Db_Expr;
+
/**
* Class for tax report resource model with aggregation by created at
*/
-class Createdat extends \Magento\Reports\Model\ResourceModel\Report\AbstractReport
+class Createdat extends AbstractReport
{
/**
* Resource initialization
@@ -45,7 +51,7 @@ public function aggregate($from = null, $to = null)
* @param mixed $from
* @param mixed $to
* @return $this
- * @throws \Exception
+ * @throws Exception
*/
protected function _aggregateByOrder($aggregationField, $from, $to)
{
@@ -99,7 +105,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
[]
)->useStraightJoin()->where(
'e.state NOT IN (?)',
- [\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT, \Magento\Sales\Model\Order::STATE_NEW]
+ [Order::STATE_PENDING_PAYMENT, Order::STATE_NEW]
);
if ($subSelect !== null) {
@@ -116,7 +122,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
$columns = [
'period' => 'period',
- 'store_id' => new \Zend_Db_Expr(\Magento\Store\Model\Store::DEFAULT_STORE_ID),
+ 'store_id' => new Zend_Db_Expr(Store::DEFAULT_STORE_ID),
'code' => 'code',
'order_status' => 'order_status',
'percent' => 'MAX(' . $connection->quoteIdentifier('percent') . ')',
@@ -134,7 +140,7 @@ protected function _aggregateByOrder($aggregationField, $from, $to)
$insertQuery = $connection->insertFromSelect($select, $this->getMainTable(), array_keys($columns));
$connection->query($insertQuery);
$connection->commit();
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$connection->rollBack();
throw $e;
}
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Updatedat.php b/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Updatedat.php
index 65b2494fb847c..1880dbf3adb36 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Updatedat.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Report/Tax/Updatedat.php
@@ -11,7 +11,7 @@
*/
namespace Magento\Tax\Model\ResourceModel\Report\Tax;
-class Updatedat extends \Magento\Tax\Model\ResourceModel\Report\Tax\Createdat
+class Updatedat extends Createdat
{
/**
* Resource initialization
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Report/Updatedat/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Report/Updatedat/Collection.php
index 8fad3427a3c96..8c7bddf230927 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Report/Updatedat/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Report/Updatedat/Collection.php
@@ -11,7 +11,9 @@
*/
namespace Magento\Tax\Model\ResourceModel\Report\Updatedat;
-class Collection extends \Magento\Tax\Model\ResourceModel\Report\Collection
+use Magento\Tax\Model\ResourceModel\Report\Collection as ReportCollection;
+
+class Collection extends ReportCollection
{
/**
* Aggregated Data Table
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax.php b/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax.php
index 71147e29ef590..9dbcb7206f61e 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax.php
@@ -5,12 +5,14 @@
*/
namespace Magento\Tax\Model\ResourceModel\Sales\Order;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+
/**
* Sales order tax resource model
*
* @author Magento Core Team
*/
-class Tax extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
+class Tax extends AbstractDb
{
/**
* Resource initialization
diff --git a/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax/Collection.php
index a65598f5b491d..836835eda0bd8 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax/Collection.php
@@ -5,12 +5,18 @@
*/
namespace Magento\Tax\Model\ResourceModel\Sales\Order\Tax;
+use Magento\Framework\DataObject;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax as ResourceSalesOrderTax;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\Collection as SalesOrderTaxCollection;
+use Magento\Tax\Model\Sales\Order\Tax as ModelSalesOrderTax;
+
/**
* Order Tax Collection
*
* @author Magento Core Team
*/
-class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+class Collection extends AbstractCollection
{
/**
* Resource initialization
@@ -20,16 +26,16 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
protected function _construct()
{
$this->_init(
- \Magento\Tax\Model\Sales\Order\Tax::class,
- \Magento\Tax\Model\ResourceModel\Sales\Order\Tax::class
+ ModelSalesOrderTax::class,
+ ResourceSalesOrderTax::class
);
}
/**
* Retrieve order tax collection by order identifier
*
- * @param \Magento\Framework\DataObject $order
- * @return \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\Collection
+ * @param DataObject $order
+ * @return SalesOrderTaxCollection
*/
public function loadByOrder($order)
{
diff --git a/app/code/Magento/Tax/Model/ResourceModel/TaxClass.php b/app/code/Magento/Tax/Model/ResourceModel/TaxClass.php
index 653f8c473e552..3f32f70dbb2aa 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/TaxClass.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/TaxClass.php
@@ -5,12 +5,14 @@
*/
namespace Magento\Tax\Model\ResourceModel;
+use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
+
/**
* Tax class resource
*
* @author Magento Core Team
*/
-class TaxClass extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
+class TaxClass extends AbstractDb
{
/**
* Resource initialization
diff --git a/app/code/Magento/Tax/Model/ResourceModel/TaxClass/Collection.php b/app/code/Magento/Tax/Model/ResourceModel/TaxClass/Collection.php
index de65b778a3b09..6e14ede4a04a1 100644
--- a/app/code/Magento/Tax/Model/ResourceModel/TaxClass/Collection.php
+++ b/app/code/Magento/Tax/Model/ResourceModel/TaxClass/Collection.php
@@ -11,7 +11,11 @@
*/
namespace Magento\Tax\Model\ResourceModel\TaxClass;
-class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Tax\Model\ClassModel as ModelClassModel;
+use Magento\Tax\Model\ResourceModel\TaxClass as ResourceTaxClass;
+
+class Collection extends AbstractCollection
{
/**
* Resource initialization
@@ -20,7 +24,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
*/
public function _construct()
{
- $this->_init(\Magento\Tax\Model\ClassModel::class, \Magento\Tax\Model\ResourceModel\TaxClass::class);
+ $this->_init(ModelClassModel::class, ResourceTaxClass::class);
}
/**
diff --git a/app/code/Magento/Tax/Model/Sales/Order/Details.php b/app/code/Magento/Tax/Model/Sales/Order/Details.php
index 735ae54ce5a6f..54f6dd1daf270 100644
--- a/app/code/Magento/Tax/Model/Sales/Order/Details.php
+++ b/app/code/Magento/Tax/Model/Sales/Order/Details.php
@@ -7,11 +7,16 @@
namespace Magento\Tax\Model\Sales\Order;
+use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsItemInterface;
+
/**
* @codeCoverageIgnore
*/
-class Details extends \Magento\Framework\Model\AbstractExtensibleModel implements
- \Magento\Tax\Api\Data\OrderTaxDetailsInterface
+class Details extends AbstractExtensibleModel implements OrderTaxDetailsInterface
{
/**#@+
* Constants defined for keys of array, makes typos less likely
@@ -39,7 +44,7 @@ public function getItems()
/**
* Set applied taxes at order level
*
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface[] $appliedTaxes
+ * @param OrderTaxDetailsAppliedTaxInterface[] $appliedTaxes
* @return $this
*/
public function setAppliedTaxes(array $appliedTaxes = null)
@@ -50,7 +55,7 @@ public function setAppliedTaxes(array $appliedTaxes = null)
/**
* Set order item tax details
*
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[] $items
+ * @param OrderTaxDetailsItemInterface[] $items
* @return $this
*/
public function setItems(array $items = null)
@@ -61,7 +66,7 @@ public function setItems(array $items = null)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface|null
+ * @return OrderTaxDetailsExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -71,10 +76,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface $extensionAttributes
+ * @param OrderTaxDetailsExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(OrderTaxDetailsExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Sales/Order/Tax.php b/app/code/Magento/Tax/Model/Sales/Order/Tax.php
index 7430beb65f32b..39bc0aba04e72 100644
--- a/app/code/Magento/Tax/Model/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Model/Sales/Order/Tax.php
@@ -5,21 +5,26 @@
*/
namespace Magento\Tax\Model\Sales\Order;
+use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\AppliedTaxRateInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax as ResourceSalesOrderTax;
+
/**
* @method int getOrderId()
- * @method \Magento\Tax\Model\Sales\Order\Tax setOrderId(int $value)
+ * @method Tax setOrderId(int $value)
* @method int getPriority()
- * @method \Magento\Tax\Model\Sales\Order\Tax setPriority(int $value)
+ * @method Tax setPriority(int $value)
* @method int getPosition()
- * @method \Magento\Tax\Model\Sales\Order\Tax setPosition(int $value)
+ * @method Tax setPosition(int $value)
* @method int getProcess()
- * @method \Magento\Tax\Model\Sales\Order\Tax setProcess(int $value)
+ * @method Tax setProcess(int $value)
* @method float getBaseRealAmount()
- * @method \Magento\Tax\Model\Sales\Order\Tax setBaseRealAmount(float $value)
+ * @method Tax setBaseRealAmount(float $value)
* @codeCoverageIgnore
*/
-class Tax extends \Magento\Framework\Model\AbstractExtensibleModel implements
- \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface
+class Tax extends AbstractExtensibleModel implements OrderTaxDetailsAppliedTaxInterface
{
/**#@+
* Constants defined for keys of array, makes typos less likely
@@ -37,7 +42,7 @@ class Tax extends \Magento\Framework\Model\AbstractExtensibleModel implements
*/
protected function _construct()
{
- $this->_init(\Magento\Tax\Model\ResourceModel\Sales\Order\Tax::class);
+ $this->_init(ResourceSalesOrderTax::class);
}
/**
@@ -137,7 +142,7 @@ public function setBaseAmount($baseAmount)
/**
*
- * @return \Magento\Tax\Api\Data\AppliedTaxRateInterface[]
+ * @return AppliedTaxRateInterface[]
*/
public function getRates()
{
@@ -146,7 +151,7 @@ public function getRates()
/**
*
- * @param \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $rates
+ * @param AppliedTaxRateInterface[] $rates
* @return $this
*/
public function setRates($rates)
@@ -157,7 +162,7 @@ public function setRates($rates)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface|null
+ * @return OrderTaxDetailsAppliedTaxExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -167,11 +172,11 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes
+ * @param OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
- \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes
+ OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes
) {
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php
index 2e6e74a573f99..480117051f53e 100644
--- a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php
+++ b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php
@@ -8,56 +8,32 @@
namespace Magento\Tax\Model\Sales\Order;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Sales\Model\OrderFactory;
+use Magento\Sales\Model\ResourceModel\Order\Tax\ItemFactory;
use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterfaceFactory as TaxDetailsDataObjectFactory;
use Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface as AppliedTax;
use Magento\Sales\Model\Order\Tax\Item;
+use Magento\Tax\Api\Data\OrderTaxDetailsInterfaceFactory;
+use Magento\Tax\Api\Data\OrderTaxDetailsItemInterface;
+use Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory;
+use Magento\Tax\Api\OrderTaxManagementInterface;
-class TaxManagement implements \Magento\Tax\Api\OrderTaxManagementInterface
+class TaxManagement implements OrderTaxManagementInterface
{
/**
- * @var \Magento\Sales\Model\ResourceModel\Order\Tax\ItemFactory
- */
- protected $orderItemTaxFactory;
-
- /**
- * @var \Magento\Sales\Model\OrderFactory
- */
- protected $orderFactory;
-
- /**
- * @var \Magento\Tax\Api\Data\OrderTaxDetailsInterfaceFactory
- */
- protected $orderTaxDetailsDataObjectFactory;
-
- /**
- * @var \Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory
- */
- protected $itemDataObjectFactory;
-
- /**
- * @var TaxDetailsDataObjectFactory
- */
- protected $appliedTaxDataObjectFactory;
-
- /**
- * @param \Magento\Sales\Model\OrderFactory $orderFactory
- * @param \Magento\Sales\Model\ResourceModel\Order\Tax\ItemFactory $orderItemTaxFactory
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsInterfaceFactory $orderTaxDetailsDataObjectFactory
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory $itemDataObjectFactory
+ * @param OrderFactory $orderFactory
+ * @param ItemFactory $orderItemTaxFactory
+ * @param OrderTaxDetailsInterfaceFactory $orderTaxDetailsDataObjectFactory
+ * @param OrderTaxDetailsItemInterfaceFactory $itemDataObjectFactory
* @param TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory
*/
public function __construct(
- \Magento\Sales\Model\OrderFactory $orderFactory,
- \Magento\Sales\Model\ResourceModel\Order\Tax\ItemFactory $orderItemTaxFactory,
- \Magento\Tax\Api\Data\OrderTaxDetailsInterfaceFactory $orderTaxDetailsDataObjectFactory,
- \Magento\Tax\Api\Data\OrderTaxDetailsItemInterfaceFactory $itemDataObjectFactory,
- TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory
+ protected readonly OrderFactory $orderFactory,
+ protected readonly ItemFactory $orderItemTaxFactory,
+ protected readonly OrderTaxDetailsInterfaceFactory $orderTaxDetailsDataObjectFactory,
+ protected readonly OrderTaxDetailsItemInterfaceFactory $itemDataObjectFactory,
+ protected readonly TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory
) {
- $this->orderFactory = $orderFactory;
- $this->orderItemTaxFactory = $orderItemTaxFactory;
- $this->orderTaxDetailsDataObjectFactory = $orderTaxDetailsDataObjectFactory;
- $this->itemDataObjectFactory = $itemDataObjectFactory;
- $this->appliedTaxDataObjectFactory = $appliedTaxDataObjectFactory;
}
/**
@@ -92,7 +68,7 @@ protected function convertToAppliedTaxDataObject(
* Aggregate item applied taxes to get order applied taxes
*
* @param TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory
- * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[] $items
+ * @param OrderTaxDetailsItemInterface[] $items
* @return AppliedTax[]
*/
protected function aggregateAppliedTaxes(TaxDetailsDataObjectFactory $appliedTaxDataObjectFactory, $items)
diff --git a/app/code/Magento/Tax/Model/Sales/Pdf/Grandtotal.php b/app/code/Magento/Tax/Model/Sales/Pdf/Grandtotal.php
index af92212ecbc59..cb2de3db09ebd 100644
--- a/app/code/Magento/Tax/Model/Sales/Pdf/Grandtotal.php
+++ b/app/code/Magento/Tax/Model/Sales/Pdf/Grandtotal.php
@@ -5,25 +5,30 @@
*/
namespace Magento\Tax\Model\Sales\Pdf;
+use Magento\Tax\Helper\Data as TaxHelper;
+use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config as TaxConfig;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory;
+
class Grandtotal extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
{
/**
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_taxConfig;
/**
- * @param \Magento\Tax\Helper\Data $taxHelper
- * @param \Magento\Tax\Model\Calculation $taxCalculation
- * @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxHelper $taxHelper
+ * @param Calculation $taxCalculation
+ * @param CollectionFactory $ordersFactory
+ * @param TaxConfig $taxConfig
* @param array $data
*/
public function __construct(
- \Magento\Tax\Helper\Data $taxHelper,
- \Magento\Tax\Model\Calculation $taxCalculation,
- \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxHelper $taxHelper,
+ Calculation $taxCalculation,
+ CollectionFactory $ordersFactory,
+ TaxConfig $taxConfig,
array $data = []
) {
$this->_taxConfig = $taxConfig;
diff --git a/app/code/Magento/Tax/Model/Sales/Pdf/Shipping.php b/app/code/Magento/Tax/Model/Sales/Pdf/Shipping.php
index 0768e26dfcf81..edf2842b4974d 100644
--- a/app/code/Magento/Tax/Model/Sales/Pdf/Shipping.php
+++ b/app/code/Magento/Tax/Model/Sales/Pdf/Shipping.php
@@ -5,25 +5,31 @@
*/
namespace Magento\Tax\Model\Sales\Pdf;
-class Shipping extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
+use Magento\Sales\Model\Order\Pdf\Total\DefaultTotal;
+use Magento\Tax\Helper\Data as TaxHelper;
+use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory;
+
+class Shipping extends DefaultTotal
{
/**
- * @var \Magento\Tax\Model\Config
+ * @var Config
*/
protected $_taxConfig;
/**
- * @param \Magento\Tax\Helper\Data $taxHelper
- * @param \Magento\Tax\Model\Calculation $taxCalculation
- * @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxHelper $taxHelper
+ * @param Calculation $taxCalculation
+ * @param CollectionFactory $ordersFactory
+ * @param Config $taxConfig
* @param array $data
*/
public function __construct(
- \Magento\Tax\Helper\Data $taxHelper,
- \Magento\Tax\Model\Calculation $taxCalculation,
- \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxHelper $taxHelper,
+ Calculation $taxCalculation,
+ CollectionFactory $ordersFactory,
+ Config $taxConfig,
array $data = []
) {
$this->_taxConfig = $taxConfig;
diff --git a/app/code/Magento/Tax/Model/Sales/Pdf/Subtotal.php b/app/code/Magento/Tax/Model/Sales/Pdf/Subtotal.php
index 8ed160fb4e334..e9287cf4cfbeb 100644
--- a/app/code/Magento/Tax/Model/Sales/Pdf/Subtotal.php
+++ b/app/code/Magento/Tax/Model/Sales/Pdf/Subtotal.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\Sales\Pdf;
-class Subtotal extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
+use Magento\Sales\Model\Order\Pdf\Total\DefaultTotal;
+
+class Subtotal extends DefaultTotal
{
/**
* Get array of arrays with totals information for display in PDF
diff --git a/app/code/Magento/Tax/Model/Sales/Pdf/Tax.php b/app/code/Magento/Tax/Model/Sales/Pdf/Tax.php
index d773b81d39a6e..204b769692273 100644
--- a/app/code/Magento/Tax/Model/Sales/Pdf/Tax.php
+++ b/app/code/Magento/Tax/Model/Sales/Pdf/Tax.php
@@ -5,25 +5,31 @@
*/
namespace Magento\Tax\Model\Sales\Pdf;
-class Tax extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
+use Magento\Sales\Model\Order\Pdf\Total\DefaultTotal;
+use Magento\Tax\Helper\Data as TaxHelper;
+use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config;
+use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory;
+
+class Tax extends DefaultTotal
{
/**
- * @var \Magento\Tax\Model\Config
+ * @var Config
*/
protected $_taxConfig;
/**
- * @param \Magento\Tax\Helper\Data $taxHelper
- * @param \Magento\Tax\Model\Calculation $taxCalculation
- * @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param TaxHelper $taxHelper
+ * @param Calculation $taxCalculation
+ * @param CollectionFactory $ordersFactory
+ * @param Config $taxConfig
* @param array $data
*/
public function __construct(
- \Magento\Tax\Helper\Data $taxHelper,
- \Magento\Tax\Model\Calculation $taxCalculation,
- \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory,
- \Magento\Tax\Model\Config $taxConfig,
+ TaxHelper $taxHelper,
+ Calculation $taxCalculation,
+ CollectionFactory $ordersFactory,
+ Config $taxConfig,
array $data = []
) {
$this->_taxConfig = $taxConfig;
diff --git a/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php b/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php
index a03c3879554cb..bdc789b2c2ce6 100644
--- a/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php
+++ b/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php
@@ -6,7 +6,9 @@
namespace Magento\Tax\Model\Sales\Quote;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
+use Magento\Tax\Api\Data\TaxClassKeyInterface;
/**
* @codeCoverageIgnore
@@ -142,10 +144,10 @@ public function setType($type)
/**
* Set tax class key
*
- * @param \Magento\Tax\Api\Data\TaxClassKeyInterface $taxClassKey
+ * @param TaxClassKeyInterface $taxClassKey
* @return $this
*/
- public function setTaxClassKey(\Magento\Tax\Api\Data\TaxClassKeyInterface $taxClassKey = null)
+ public function setTaxClassKey(TaxClassKeyInterface $taxClassKey = null)
{
return $this->setData(self::KEY_TAX_CLASS_KEY, $taxClassKey);
}
@@ -241,7 +243,7 @@ public function setTaxClassId($taxClassId)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface|null
+ * @return QuoteDetailsItemExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -251,11 +253,11 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes
+ * @param QuoteDetailsItemExtensionInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
- \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes
+ QuoteDetailsItemExtensionInterface $extensionAttributes
) {
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php b/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php
index 12b6131aad4f1..70a7722b5f9f4 100644
--- a/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php
+++ b/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php
@@ -5,8 +5,12 @@
*/
namespace Magento\Tax\Model\Sales\Quote;
+use Magento\Customer\Api\Data\AddressInterface;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\QuoteDetailsExtensionInterface;
use Magento\Tax\Api\Data\QuoteDetailsInterface;
+use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
+use Magento\Tax\Api\Data\TaxClassKeyInterface;
/**
* @codeCoverageIgnore
@@ -75,10 +79,10 @@ public function getCustomerTaxClassId()
/**
* Set customer billing address
*
- * @param \Magento\Customer\Api\Data\AddressInterface $billingAddress
+ * @param AddressInterface $billingAddress
* @return $this
*/
- public function setBillingAddress(\Magento\Customer\Api\Data\AddressInterface $billingAddress = null)
+ public function setBillingAddress(AddressInterface $billingAddress = null)
{
return $this->setData(self::KEY_BILLING_ADDRESS, $billingAddress);
}
@@ -86,10 +90,10 @@ public function setBillingAddress(\Magento\Customer\Api\Data\AddressInterface $b
/**
* Set customer shipping address
*
- * @param \Magento\Customer\Api\Data\AddressInterface $shippingAddress
+ * @param AddressInterface $shippingAddress
* @return $this
*/
- public function setShippingAddress(\Magento\Customer\Api\Data\AddressInterface $shippingAddress = null)
+ public function setShippingAddress(AddressInterface $shippingAddress = null)
{
return $this->setData(self::KEY_SHIPPING_ADDRESS, $shippingAddress);
}
@@ -97,10 +101,10 @@ public function setShippingAddress(\Magento\Customer\Api\Data\AddressInterface $
/**
* Set customer tax class key
*
- * @param \Magento\Tax\Api\Data\TaxClassKeyInterface $customerTaxClassKey
+ * @param TaxClassKeyInterface $customerTaxClassKey
* @return $this
*/
- public function setCustomerTaxClassKey(\Magento\Tax\Api\Data\TaxClassKeyInterface $customerTaxClassKey = null)
+ public function setCustomerTaxClassKey(TaxClassKeyInterface $customerTaxClassKey = null)
{
return $this->setData(self::KEY_CUSTOMER_TAX_CLASS_KEY, $customerTaxClassKey);
}
@@ -119,7 +123,7 @@ public function setCustomerId($customerId)
/**
* Set customer data
*
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterface[] $items
+ * @param QuoteDetailsItemInterface[] $items
* @return $this
*/
public function setItems(array $items = null)
@@ -141,7 +145,7 @@ public function setCustomerTaxClassId($customerTaxClassId)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\QuoteDetailsExtensionInterface|null
+ * @return QuoteDetailsExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -151,10 +155,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\QuoteDetailsExtensionInterface $extensionAttributes
+ * @param QuoteDetailsExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\QuoteDetailsExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(QuoteDetailsExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
index 318e35792e51a..7a45a144ff7d5 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
@@ -12,21 +12,26 @@
use Magento\Customer\Api\Data\RegionInterfaceFactory as CustomerAddressRegionFactory;
use Magento\Framework\DataObject;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
+use Magento\Quote\Model\Quote\Address\Total as QuoteAddressTotal;
use Magento\Quote\Model\Quote\Address\Total\AbstractTotal;
use Magento\Quote\Model\Quote\Item\AbstractItem;
use Magento\Store\Model\Store;
+use Magento\Tax\Api\Data\AppliedTaxInterface;
use Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory;
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
+use Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory;
use Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
use Magento\Tax\Api\Data\TaxDetailsInterface;
use Magento\Tax\Api\Data\TaxDetailsItemInterface;
use Magento\Tax\Api\Data\QuoteDetailsInterface;
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
+use Magento\Tax\Api\TaxCalculationInterface;
use Magento\Tax\Helper\Data as TaxHelper;
use Magento\Framework\App\ObjectManager;
use Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface;
use Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterfaceFactory;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Tax totals calculation model
@@ -92,7 +97,7 @@ class CommonTaxCollector extends AbstractTotal
/**#@-*/
/**
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_config;
@@ -106,14 +111,14 @@ class CommonTaxCollector extends AbstractTotal
/**
* Tax calculation service, the collector will call the service which performs the actual calculation
*
- * @var \Magento\Tax\Api\TaxCalculationInterface
+ * @var TaxCalculationInterface
*/
protected $taxCalculationService;
/**
* Factory to create QuoteDetails as input to tax calculation service
*
- * @var \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory
+ * @var QuoteDetailsInterfaceFactory
*/
protected $quoteDetailsDataObjectFactory;
@@ -128,12 +133,12 @@ class CommonTaxCollector extends AbstractTotal
protected $customerAddressRegionFactory;
/**
- * @var \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory
+ * @var TaxClassKeyInterfaceFactory
*/
protected $taxClassKeyDataObjectFactory;
/**
- * @var \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory
+ * @var QuoteDetailsItemInterfaceFactory
*/
protected $quoteDetailsItemDataObjectFactory;
@@ -155,11 +160,11 @@ class CommonTaxCollector extends AbstractTotal
/**
* Class constructor
*
- * @param \Magento\Tax\Model\Config $taxConfig
- * @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService
+ * @param TaxConfig $taxConfig
+ * @param TaxCalculationInterface $taxCalculationService
* @param QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
- * @param \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
+ * @param QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
+ * @param TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
* @param CustomerAddressFactory $customerAddressFactory
* @param CustomerAddressRegionFactory $customerAddressRegionFactory
* @param TaxHelper|null $taxHelper
@@ -168,11 +173,11 @@ class CommonTaxCollector extends AbstractTotal
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- \Magento\Tax\Model\Config $taxConfig,
- \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService,
- \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory,
- \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory,
- \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
+ TaxConfig $taxConfig,
+ TaxCalculationInterface $taxCalculationService,
+ QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory,
+ QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory,
+ TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
CustomerAddressFactory $customerAddressFactory,
CustomerAddressRegionFactory $customerAddressRegionFactory,
TaxHelper $taxHelper = null,
@@ -216,7 +221,7 @@ public function mapAddress(QuoteAddress $address)
/**
* Map an item to item data object
*
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
+ * @param QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
* @param AbstractItem $item
* @param bool $priceIncludesTax
* @param bool $useBaseCurrency
@@ -224,7 +229,7 @@ public function mapAddress(QuoteAddress $address)
* @return QuoteDetailsItemInterface
*/
public function mapItem(
- \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
+ QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
AbstractItem $item,
$priceIncludesTax,
$useBaseCurrency,
@@ -301,14 +306,14 @@ private function setPriceForTaxCalculation(QuoteDetailsItemInterface $quoteDetai
/**
* Map item extra taxables
*
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
+ * @param QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
* @param AbstractItem $item
* @param bool $priceIncludesTax
* @param bool $useBaseCurrency
* @return QuoteDetailsItemInterface[]
*/
public function mapItemExtraTaxables(
- \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
+ QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
AbstractItem $item,
$priceIncludesTax,
$useBaseCurrency
@@ -449,13 +454,13 @@ public function populateAddressData(QuoteDetailsInterface $quoteDetails, QuoteAd
* Get shipping data object.
*
* @param ShippingAssignmentInterface $shippingAssignment
- * @param QuoteAddress\Total $total
+ * @param QuoteAddressTotal $total
* @param bool $useBaseCurrency
* @return QuoteDetailsItemInterface
*/
public function getShippingDataObject(
ShippingAssignmentInterface $shippingAssignment,
- QuoteAddress\Total $total,
+ QuoteAddressTotal $total,
$useBaseCurrency
) {
$store = $shippingAssignment->getShipping()->getAddress()->getQuote()->getStore();
@@ -502,7 +507,7 @@ public function getShippingDataObject(
*
* @param ShippingAssignmentInterface $shippingAssignment
* @param QuoteDetailsItemInterface[] $itemDataObjects
- * @return \Magento\Tax\Api\Data\QuoteDetailsInterface
+ * @return QuoteDetailsInterface
*/
protected function prepareQuoteDetails(ShippingAssignmentInterface $shippingAssignment, $itemDataObjects)
{
@@ -538,12 +543,12 @@ protected function organizeItemTaxDetailsByType(
TaxDetailsInterface $taxDetails,
TaxDetailsInterface $baseTaxDetails
) {
- /** @var \Magento\Tax\Api\Data\TaxDetailsItemInterface[] $keyedItems */
+ /** @var TaxDetailsItemInterface[] $keyedItems */
$keyedItems = [];
foreach ($taxDetails->getItems() as $item) {
$keyedItems[$item->getCode()] = $item;
}
- /** @var \Magento\Tax\Api\Data\TaxDetailsItemInterface[] $baseKeyedItems */
+ /** @var TaxDetailsItemInterface[] $baseKeyedItems */
$baseKeyedItems = [];
foreach ($baseTaxDetails->getItems() as $item) {
$baseKeyedItems[$item->getCode()] = $item;
@@ -566,13 +571,13 @@ protected function organizeItemTaxDetailsByType(
*
* @param ShippingAssignmentInterface $shippingAssignment
* @param array $itemTaxDetails
- * @param QuoteAddress\Total $total
+ * @param QuoteAddressTotal $total
* @return $this
*/
protected function processProductItems(
ShippingAssignmentInterface $shippingAssignment,
array $itemTaxDetails,
- QuoteAddress\Total $total
+ QuoteAddressTotal $total
) {
$store = $shippingAssignment->getShipping()->getAddress()->getQuote()->getStore();
@@ -637,13 +642,13 @@ protected function processProductItems(
/**
* Process applied taxes for items and quote
*
- * @param QuoteAddress\Total $total
+ * @param QuoteAddressTotal $total
* @param ShippingAssignmentInterface $shippingAssignment
* @param array $itemsByType
* @return $this
*/
protected function processAppliedTaxes(
- QuoteAddress\Total $total,
+ QuoteAddressTotal $total,
ShippingAssignmentInterface $shippingAssignment,
array $itemsByType
) {
@@ -761,14 +766,14 @@ public function updateItemTaxInfo($quoteItem, $itemTaxDetails, $baseItemTaxDetai
* Update tax related fields for shipping
*
* @param ShippingAssignmentInterface $shippingAssignment
- * @param QuoteAddress\Total $total
+ * @param QuoteAddressTotal $total
* @param TaxDetailsItemInterface $shippingTaxDetails
* @param TaxDetailsItemInterface $baseShippingTaxDetails
* @return $this
*/
protected function processShippingTaxInfo(
ShippingAssignmentInterface $shippingAssignment,
- QuoteAddress\Total $total,
+ QuoteAddressTotal $total,
$shippingTaxDetails,
$baseShippingTaxDetails
) {
@@ -803,8 +808,8 @@ protected function processShippingTaxInfo(
/**
* Convert appliedTax data object from tax calculation service to internal array format
*
- * @param \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes
- * @param \Magento\Tax\Api\Data\AppliedTaxInterface[] $baseAppliedTaxes
+ * @param AppliedTaxInterface[] $appliedTaxes
+ * @param AppliedTaxInterface[] $baseAppliedTaxes
* @param array $extraInfo
* @return array
*/
@@ -850,7 +855,7 @@ public function convertAppliedTaxes($appliedTaxes, $baseAppliedTaxes, $extraInfo
/**
* Collect applied tax rates information on address level
*
- * @param QuoteAddress\Total $total
+ * @param QuoteAddressTotal $total
* @param array $applied
* @param float $amount
* @param float $baseAmount
@@ -860,7 +865,7 @@ public function convertAppliedTaxes($appliedTaxes, $baseAppliedTaxes, $extraInfo
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _saveAppliedTaxes(
- QuoteAddress\Total $total,
+ QuoteAddressTotal $total,
$applied,
$amount,
$baseAmount,
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php
index ddfb6f9fd5073..36891f2476848 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Shipping.php
@@ -7,23 +7,25 @@
namespace Magento\Tax\Model\Sales\Total\Quote;
+use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address;
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
+use Magento\Quote\Model\Quote\Address\Total as QuoteAddressTotal;
class Shipping extends CommonTaxCollector
{
/**
* Collect tax totals for shipping. The result can be used to calculate discount on shipping
*
- * @param \Magento\Quote\Model\Quote $quote
+ * @param Quote $quote
* @param ShippingAssignmentInterface $shippingAssignment
- * @param Address\Total $total
+ * @param QuoteAddressTotal $total
* @return $this
*/
public function collect(
- \Magento\Quote\Model\Quote $quote,
- \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
- \Magento\Quote\Model\Quote\Address\Total $total
+ Quote $quote,
+ ShippingAssignmentInterface $shippingAssignment,
+ QuoteAddressTotal $total
) {
$storeId = $quote->getStoreId();
$items = $shippingAssignment->getItems();
@@ -64,13 +66,13 @@ public function collect(
}
/**
- * @param \Magento\Quote\Model\Quote $quote
- * @param Address\Total $total
+ * @param Quote $quote
+ * @param QuoteAddressTotal $total
* @return array|null
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
+ public function fetch(Quote $quote, QuoteAddressTotal $total)
{
if ($total->getShippingInclTax()) {
return [
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php
index e60926b96fe49..83c726df26a43 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Subtotal.php
@@ -9,8 +9,10 @@
*/
namespace Magento\Tax\Model\Sales\Total\Quote;
+use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address;
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
+use Magento\Quote\Model\Quote\Address\Total as QuoteAddressTotal;
class Subtotal extends CommonTaxCollector
{
@@ -18,15 +20,15 @@ class Subtotal extends CommonTaxCollector
* Calculate tax on product items. The result will be used to determine shipping
* and discount later.
*
- * @param \Magento\Quote\Model\Quote $quote
+ * @param Quote $quote
* @param ShippingAssignmentInterface $shippingAssignment
- * @param Address\Total $total
+ * @param QuoteAddressTotal $total
* @return $this
*/
public function collect(
- \Magento\Quote\Model\Quote $quote,
- \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
- \Magento\Quote\Model\Quote\Address\Total $total
+ Quote $quote,
+ ShippingAssignmentInterface $shippingAssignment,
+ QuoteAddressTotal $total
) {
$items = $shippingAssignment->getItems();
if (!$items) {
@@ -57,12 +59,12 @@ public function collect(
}
/**
- * @param \Magento\Quote\Model\Quote $quote
- * @param Address\Total $total
+ * @param Quote $quote
+ * @param QuoteAddressTotal $total
* @return null
* @codeCoverageIgnore
*/
- public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
+ public function fetch(Quote $quote, QuoteAddressTotal $total)
{
return null;
}
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php
index bdc61d62be5b1..9259ac9855297 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php
@@ -8,11 +8,22 @@
use Magento\Customer\Api\Data\AddressInterfaceFactory as CustomerAddressFactory;
use Magento\Customer\Api\Data\RegionInterfaceFactory as CustomerAddressRegionFactory;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Phrase;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Quote\Api\Data\ShippingAssignmentInterface;
+use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Address;
+use Magento\Quote\Model\Quote\Address\Total as QuoteAddressTotal;
+use Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory;
+use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
+use Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
+use Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory;
+use Magento\Tax\Api\Data\TaxDetailsInterface;
+use Magento\Tax\Api\TaxCalculationInterface;
+use Magento\Tax\Helper\Data as TaxHelper;
use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Tax totals calculation model
@@ -30,14 +41,14 @@ class Tax extends CommonTaxCollector
/**
* Tax module helper
*
- * @var \Magento\Tax\Helper\Data
+ * @var TaxHelper
*/
protected $_taxData;
/**
* Tax configuration object
*
- * @var \Magento\Tax\Model\Config
+ * @var TaxConfig
*/
protected $_config;
@@ -48,34 +59,29 @@ class Tax extends CommonTaxCollector
*/
protected $_discountTaxCompensationes = [];
- /**
- * @var Json
- */
- private $serializer;
-
/**
* Class constructor
*
- * @param \Magento\Tax\Model\Config $taxConfig
- * @param \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService
- * @param \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
- * @param \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
+ * @param TaxConfig $taxConfig
+ * @param TaxCalculationInterface $taxCalculationService
+ * @param QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory
+ * @param QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory
+ * @param TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory
* @param CustomerAddressFactory $customerAddressFactory
* @param CustomerAddressRegionFactory $customerAddressRegionFactory
- * @param \Magento\Tax\Helper\Data $taxData
+ * @param TaxHelper $taxData
* @param Json $serializer
*/
public function __construct(
- \Magento\Tax\Model\Config $taxConfig,
- \Magento\Tax\Api\TaxCalculationInterface $taxCalculationService,
- \Magento\Tax\Api\Data\QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory,
- \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory,
- \Magento\Tax\Api\Data\TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
+ TaxConfig $taxConfig,
+ TaxCalculationInterface $taxCalculationService,
+ QuoteDetailsInterfaceFactory $quoteDetailsDataObjectFactory,
+ QuoteDetailsItemInterfaceFactory $quoteDetailsItemDataObjectFactory,
+ TaxClassKeyInterfaceFactory $taxClassKeyDataObjectFactory,
CustomerAddressFactory $customerAddressFactory,
CustomerAddressRegionFactory $customerAddressRegionFactory,
- \Magento\Tax\Helper\Data $taxData,
- Json $serializer = null
+ TaxHelper $taxData,
+ private ?Json $serializer = null
) {
$this->setCode('tax');
$this->_taxData = $taxData;
@@ -94,16 +100,16 @@ public function __construct(
/**
* Collect tax totals for quote address
*
- * @param \Magento\Quote\Model\Quote $quote
+ * @param Quote $quote
* @param ShippingAssignmentInterface $shippingAssignment
- * @param Address\Total $total
+ * @param QuoteAddressTotal $total
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function collect(
- \Magento\Quote\Model\Quote $quote,
- \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
- \Magento\Quote\Model\Quote\Address\Total $total
+ Quote $quote,
+ ShippingAssignmentInterface $shippingAssignment,
+ QuoteAddressTotal $total
) {
$this->clearValues($total);
if (!$shippingAssignment->getItems()) {
@@ -143,10 +149,10 @@ public function collect(
/**
* Clear tax related total values in address
*
- * @param Address\Total $total
+ * @param QuoteAddressTotal $total
* @return void
*/
- protected function clearValues(Address\Total $total)
+ protected function clearValues(QuoteAddressTotal $total)
{
$total->setTotalAmount('subtotal', 0);
$total->setBaseTotalAmount('subtotal', 0);
@@ -175,9 +181,9 @@ protected function clearValues(Address\Total $total)
* Call tax calculation service to get tax details on the quote and items
*
* @param ShippingAssignmentInterface $shippingAssignment
- * @param Address\Total $total
+ * @param QuoteAddressTotal $total
* @param bool $useBaseCurrency
- * @return \Magento\Tax\Api\Data\TaxDetailsInterface
+ * @return TaxDetailsInterface
*/
protected function getQuoteTaxDetails($shippingAssignment, $total, $useBaseCurrency)
{
@@ -214,13 +220,13 @@ protected function getQuoteTaxDetails($shippingAssignment, $total, $useBaseCurre
/**
* Map extra taxables associated with quote
*
- * @param \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
+ * @param QuoteDetailsItemInterfaceFactory $itemDataObjectFactory
* @param Address $address
* @param bool $useBaseCurrency
- * @return \Magento\Tax\Api\Data\QuoteDetailsItemInterface[]
+ * @return QuoteDetailsItemInterface[]
*/
public function mapQuoteExtraTaxables(
- \Magento\Tax\Api\Data\QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
+ QuoteDetailsItemInterfaceFactory $itemDataObjectFactory,
Address $address,
$useBaseCurrency
) {
@@ -256,20 +262,20 @@ public function mapQuoteExtraTaxables(
/**
* Process everything other than product or shipping, save the result in quote
*
- * @param Address\Total $total
+ * @param QuoteAddressTotal $total
* @param array $itemsByType
* @return $this
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
- protected function processExtraTaxables(Address\Total $total, array $itemsByType)
+ protected function processExtraTaxables(QuoteAddressTotal $total, array $itemsByType)
{
$extraTaxableDetails = [];
foreach ($itemsByType as $itemType => $itemTaxDetails) {
if ($itemType != self::ITEM_TYPE_PRODUCT && $itemType != self::ITEM_TYPE_SHIPPING) {
foreach ($itemTaxDetails as $itemCode => $itemTaxDetail) {
- /** @var \Magento\Tax\Api\Data\TaxDetailsInterface $taxDetails */
+ /** @var TaxDetailsInterface $taxDetails */
$taxDetails = $itemTaxDetail[self::KEY_ITEM];
- /** @var \Magento\Tax\Api\Data\TaxDetailsInterface $baseTaxDetails */
+ /** @var TaxDetailsInterface $baseTaxDetails */
$baseTaxDetails = $itemTaxDetail[self::KEY_BASE_ITEM];
$appliedTaxes = $taxDetails->getAppliedTaxes();
@@ -309,13 +315,13 @@ protected function processExtraTaxables(Address\Total $total, array $itemsByType
/**
* Add tax totals information to address object
*
- * @param \Magento\Quote\Model\Quote $quote
- * @param Address\Total $total
+ * @param Quote $quote
+ * @param QuoteAddressTotal $total
* @return array|null
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
- public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
+ public function fetch(Quote $quote, QuoteAddressTotal $total)
{
$totals = [];
$store = $quote->getStore();
@@ -371,13 +377,13 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
/**
* Adds minimal tax information to the "total" data structure
*
- * @param \Magento\Quote\Model\Quote $quote
- * @param Address\Total $total
+ * @param Quote $quote
+ * @param QuoteAddressTotal $total
* @return null
*/
protected function enhanceTotalData(
- \Magento\Quote\Model\Quote $quote,
- \Magento\Quote\Model\Quote\Address\Total $total
+ Quote $quote,
+ QuoteAddressTotal $total
) {
$taxAmount = 0;
$shippingTaxAmount = 0;
@@ -389,7 +395,7 @@ protected function enhanceTotalData(
$computeSubtotalInclTax = false;
}
- /** @var \Magento\Quote\Model\Quote\Address $address */
+ /** @var Address $address */
foreach ($quote->getAllAddresses() as $address) {
$taxAmount += $address->getTaxAmount();
$shippingTaxAmount += $address->getShippingTaxAmount();
@@ -410,9 +416,9 @@ protected function enhanceTotalData(
*
* This method can be used for changing totals collect sort order
*
- * @param array $config
- * @param store $store
- * @return array
+ * @param array $config
+ * @param store $store
+ * @return array
*/
public function processConfigArray($config, $store)
{
@@ -431,7 +437,7 @@ public function processConfigArray($config, $store)
/**
* Get Tax label
*
- * @return \Magento\Framework\Phrase
+ * @return Phrase
*/
public function getLabel()
{
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php b/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php
index 550823588a86b..84d9bdc161ff4 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Algorithm.php
@@ -5,7 +5,10 @@
*/
namespace Magento\Tax\Model\System\Config\Source;
-class Algorithm implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+use Magento\Tax\Model\Calculation;
+
+class Algorithm implements ArrayInterface
{
/**
* @var array
@@ -18,9 +21,9 @@ class Algorithm implements \Magento\Framework\Option\ArrayInterface
public function __construct()
{
$this->_options = [
- ['value' => \Magento\Tax\Model\Calculation::CALC_UNIT_BASE, 'label' => __('Unit Price')],
- ['value' => \Magento\Tax\Model\Calculation::CALC_ROW_BASE, 'label' => __('Row Total')],
- ['value' => \Magento\Tax\Model\Calculation::CALC_TOTAL_BASE, 'label' => __('Total')],
+ ['value' => Calculation::CALC_UNIT_BASE, 'label' => __('Unit Price')],
+ ['value' => Calculation::CALC_ROW_BASE, 'label' => __('Row Total')],
+ ['value' => Calculation::CALC_TOTAL_BASE, 'label' => __('Total')],
];
}
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Apply.php b/app/code/Magento/Tax/Model/System/Config/Source/Apply.php
index a82637a9da419..2043031a3f3a9 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Apply.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Apply.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\System\Config\Source;
-class Apply implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+
+class Apply implements ArrayInterface
{
/**
* @var array
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php b/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php
index 480a6d0a94e9b..927f343dcab4c 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/PriceType.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\System\Config\Source;
-class PriceType implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+
+class PriceType implements ArrayInterface
{
/**
* @var array
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
index 9707f3ae6e353..6b98c51310104 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Tax\Model\System\Config\Source\Tax;
-class Country extends \Magento\Directory\Model\Config\Source\Country
+use Magento\Directory\Model\Config\Source\Country as ConfigSourceCountry;
+
+class Country extends ConfigSourceCountry
{
/**
* @var array
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php
index 6897a7d9e75e3..98a0f00c87c49 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Display/Type.php
@@ -11,7 +11,10 @@
*/
namespace Magento\Tax\Model\System\Config\Source\Tax\Display;
-class Type implements \Magento\Framework\Option\ArrayInterface
+use Magento\Framework\Option\ArrayInterface;
+use Magento\Tax\Model\Config;
+
+class Type implements ArrayInterface
{
/**
* @var array
@@ -26,15 +29,15 @@ public function toOptionArray()
if (!$this->_options) {
$this->_options = [];
$this->_options[] = [
- 'value' => \Magento\Tax\Model\Config::DISPLAY_TYPE_EXCLUDING_TAX,
+ 'value' => Config::DISPLAY_TYPE_EXCLUDING_TAX,
'label' => __('Excluding Tax'),
];
$this->_options[] = [
- 'value' => \Magento\Tax\Model\Config::DISPLAY_TYPE_INCLUDING_TAX,
+ 'value' => Config::DISPLAY_TYPE_INCLUDING_TAX,
'label' => __('Including Tax'),
];
$this->_options[] = [
- 'value' => \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH,
+ 'value' => Config::DISPLAY_TYPE_BOTH,
'label' => __('Including and Excluding Tax'),
];
}
diff --git a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php
index a3e105788cb31..2231de1de1d52 100644
--- a/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php
+++ b/app/code/Magento/Tax/Model/System/Config/Source/Tax/Region.php
@@ -5,18 +5,23 @@
*/
namespace Magento\Tax\Model\System\Config\Source\Tax;
-class Region implements \Magento\Framework\Option\ArrayInterface
+use Magento\Directory\Model\ResourceModel\Region\Collection as RegionCollection;
+use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
+use Magento\Framework\Option\ArrayInterface;
+
+class Region implements ArrayInterface
{
/**
- * @var \Magento\Directory\Model\ResourceModel\Region\CollectionFactory
+ * @var CollectionFactory
*/
protected $_regionsFactory;
/**
- * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionsFactory
+ * @param CollectionFactory $regionsFactory
*/
- public function __construct(\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionsFactory)
- {
+ public function __construct(
+ CollectionFactory $regionsFactory
+ ) {
$this->_regionsFactory = $regionsFactory;
}
@@ -29,7 +34,7 @@ public function __construct(\Magento\Directory\Model\ResourceModel\Region\Collec
*/
public function toOptionArray($noEmpty = false, $country = null)
{
- /** @var $region \Magento\Directory\Model\ResourceModel\Region\Collection */
+ /** @var RegionCollection $region */
$regionCollection = $this->_regionsFactory->create();
$options = $regionCollection->addCountryFilter($country)->toOptionArray();
diff --git a/app/code/Magento/Tax/Model/System/Message/Notification/ApplyDiscountOnPrices.php b/app/code/Magento/Tax/Model/System/Message/Notification/ApplyDiscountOnPrices.php
index ab1a6d40115b4..b0647f029e556 100644
--- a/app/code/Magento/Tax/Model/System/Message/Notification/ApplyDiscountOnPrices.php
+++ b/app/code/Magento/Tax/Model/System/Message/Notification/ApplyDiscountOnPrices.php
@@ -5,7 +5,11 @@
*/
namespace Magento\Tax\Model\System\Message\Notification;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
use Magento\Tax\Model\Config;
+use Magento\Tax\Model\System\Message\NotificationInterface;
/**
* Class allows to show admin notification about possible issues related to "Apply Discount On Prices" setting.
@@ -14,23 +18,8 @@
* AND "Apply Discount On Prices" = "Including Tax"
* AND "Apply Customer Tax" = "After Discount"
*/
-class ApplyDiscountOnPrices implements \Magento\Tax\Model\System\Message\NotificationInterface
+class ApplyDiscountOnPrices implements NotificationInterface
{
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- private $storeManager;
-
- /**
- * @var \Magento\Framework\UrlInterface
- */
- private $urlBuilder;
-
- /**
- * @var Config
- */
- private $taxConfig;
-
/**
* Stores with invalid display settings
*
@@ -39,18 +28,15 @@ class ApplyDiscountOnPrices implements \Magento\Tax\Model\System\Message\Notific
private $storesWithInvalidSettings;
/**
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Magento\Framework\UrlInterface $urlBuilder
+ * @param StoreManagerInterface $storeManager
+ * @param UrlInterface $urlBuilder
* @param Config $taxConfig
*/
public function __construct(
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\UrlInterface $urlBuilder,
- Config $taxConfig
+ private readonly StoreManagerInterface $storeManager,
+ private readonly UrlInterface $urlBuilder,
+ private readonly Config $taxConfig
) {
- $this->storeManager = $storeManager;
- $this->urlBuilder = $urlBuilder;
- $this->taxConfig = $taxConfig;
}
/**
@@ -131,7 +117,7 @@ private function getStoresWithWrongSettings()
/**
* Check if settings are valid.
*
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
+ * @param null|int|bool|string|Store $store $store
* @return bool false if settings are incorrect
*/
private function checkSettings($store = null)
diff --git a/app/code/Magento/Tax/Model/System/Message/Notification/DiscountErrors.php b/app/code/Magento/Tax/Model/System/Message/Notification/DiscountErrors.php
index ff16e350580a0..0ede4e685b177 100644
--- a/app/code/Magento/Tax/Model/System/Message/Notification/DiscountErrors.php
+++ b/app/code/Magento/Tax/Model/System/Message/Notification/DiscountErrors.php
@@ -5,28 +5,19 @@
*/
namespace Magento\Tax\Model\System\Message\Notification;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Tax\Model\Config;
+use Magento\Tax\Model\System\Message\NotificationInterface;
+
/**
* This class allows to display notification in the admin panel about possible discount errors.
*
* Discount errors may be caused by tax settings misconfiguration.
*/
-class DiscountErrors implements \Magento\Tax\Model\System\Message\NotificationInterface
+class DiscountErrors implements NotificationInterface
{
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- private $storeManager;
-
- /**
- * @var \Magento\Framework\UrlInterface
- */
- private $urlBuilder;
-
- /**
- * @var \Magento\Tax\Model\Config
- */
- private $taxConfig;
-
/**
* Websites with invalid discount settings
*
@@ -37,18 +28,15 @@ class DiscountErrors implements \Magento\Tax\Model\System\Message\NotificationIn
/**
* Initialize dependencies
*
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Magento\Framework\UrlInterface $urlBuilder
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param StoreManagerInterface $storeManager
+ * @param UrlInterface $urlBuilder
+ * @param Config $taxConfig
*/
public function __construct(
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\UrlInterface $urlBuilder,
- \Magento\Tax\Model\Config $taxConfig
+ private readonly StoreManagerInterface $storeManager,
+ private readonly UrlInterface $urlBuilder,
+ private readonly Config $taxConfig
) {
- $this->storeManager = $storeManager;
- $this->urlBuilder = $urlBuilder;
- $this->taxConfig = $taxConfig;
}
/**
@@ -92,7 +80,7 @@ public function getText()
);
$messageDetails .= "
";
}
-
+
return $messageDetails;
}
@@ -112,7 +100,7 @@ public function getSeverity()
* Before Discount / Excluding Tax
* Before Discount / Including Tax
*
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
+ * @param null|int|bool|string|Store $store $store
* @return bool
*/
private function checkSettings($store = null)
diff --git a/app/code/Magento/Tax/Model/System/Message/Notification/RoundingErrors.php b/app/code/Magento/Tax/Model/System/Message/Notification/RoundingErrors.php
index 99bec8bc58a89..fb094f1f6a000 100644
--- a/app/code/Magento/Tax/Model/System/Message/Notification/RoundingErrors.php
+++ b/app/code/Magento/Tax/Model/System/Message/Notification/RoundingErrors.php
@@ -5,28 +5,20 @@
*/
namespace Magento\Tax\Model\System\Message\Notification;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config;
+use Magento\Tax\Model\System\Message\NotificationInterface;
+
/**
* This class allows to display notification in the admin panel about possible rounding errors.
*
* Rounding errors may be caused by tax settings misconfiguration.
*/
-class RoundingErrors implements \Magento\Tax\Model\System\Message\NotificationInterface
+class RoundingErrors implements NotificationInterface
{
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- private $storeManager;
-
- /**
- * @var \Magento\Framework\UrlInterface
- */
- private $urlBuilder;
-
- /**
- * @var \Magento\Tax\Model\Config
- */
- private $taxConfig;
-
/**
* Stores with invalid display settings
*
@@ -35,18 +27,15 @@ class RoundingErrors implements \Magento\Tax\Model\System\Message\NotificationIn
private $storesWithInvalidSettings;
/**
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Magento\Framework\UrlInterface $urlBuilder
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param StoreManagerInterface $storeManager
+ * @param UrlInterface $urlBuilder
+ * @param Config $taxConfig
*/
public function __construct(
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\UrlInterface $urlBuilder,
- \Magento\Tax\Model\Config $taxConfig
+ private readonly StoreManagerInterface $storeManager,
+ private readonly UrlInterface $urlBuilder,
+ private readonly Config $taxConfig
) {
- $this->storeManager = $storeManager;
- $this->urlBuilder = $urlBuilder;
- $this->taxConfig = $taxConfig;
}
/**
@@ -109,16 +98,16 @@ public function getSeverity()
* Tax Calculation Method Based On 'Total' or 'Row'
* and at least one Price Display Settings has 'Including and Excluding Tax' value
*
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
+ * @param null|int|bool|string|Store $store $store
* @return bool
*/
private function checkSettings($store = null)
{
- if ($this->taxConfig->getAlgorithm($store) == \Magento\Tax\Model\Calculation::CALC_UNIT_BASE) {
+ if ($this->taxConfig->getAlgorithm($store) == Calculation::CALC_UNIT_BASE) {
return true;
}
- return $this->taxConfig->getPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH
- && $this->taxConfig->getShippingPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH
+ return $this->taxConfig->getPriceDisplayType($store) != Config::DISPLAY_TYPE_BOTH
+ && $this->taxConfig->getShippingPriceDisplayType($store) != Config::DISPLAY_TYPE_BOTH
&& !$this->taxConfig->displayCartPricesBoth($store)
&& !$this->taxConfig->displayCartSubtotalBoth($store)
&& !$this->taxConfig->displayCartShippingBoth($store)
diff --git a/app/code/Magento/Tax/Model/System/Message/NotificationInterface.php b/app/code/Magento/Tax/Model/System/Message/NotificationInterface.php
index 24116c805f497..9cb4501bc9145 100644
--- a/app/code/Magento/Tax/Model/System/Message/NotificationInterface.php
+++ b/app/code/Magento/Tax/Model/System/Message/NotificationInterface.php
@@ -5,11 +5,13 @@
*/
namespace Magento\Tax\Model\System\Message;
+use Magento\Framework\Notification\MessageInterface;
+
/**
* Notification interface for tax-related configuration issues.
*
* @api
*/
-interface NotificationInterface extends \Magento\Framework\Notification\MessageInterface
+interface NotificationInterface extends MessageInterface
{
}
diff --git a/app/code/Magento/Tax/Model/System/Message/Notifications.php b/app/code/Magento/Tax/Model/System/Message/Notifications.php
index 163054d9e9394..c2b729ed2e825 100644
--- a/app/code/Magento/Tax/Model/System/Message/Notifications.php
+++ b/app/code/Magento/Tax/Model/System/Message/Notifications.php
@@ -6,32 +6,19 @@
namespace Magento\Tax\Model\System\Message;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Escaper;
+use Magento\Framework\Notification\MessageInterface;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Tax\Model\Calculation;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Notifications class
*/
-class Notifications implements \Magento\Framework\Notification\MessageInterface
+class Notifications implements MessageInterface
{
- /**
- * Store manager object
- *
- * @var \Magento\Store\Model\StoreManagerInterface
- * @deprecated 100.1.0
- */
- protected $storeManager;
-
- /**
- * @var \Magento\Framework\UrlInterface
- */
- protected $urlBuilder;
-
- /**
- * Tax configuration object
- *
- * @var \Magento\Tax\Model\Config
- */
- protected $taxConfig;
-
/**
* Stores with invalid display settings
*
@@ -51,34 +38,20 @@ class Notifications implements \Magento\Framework\Notification\MessageInterface
protected $storesWithInvalidDiscountSettings;
/**
- * @var NotificationInterface[]
- */
- private $notifications = [];
-
- /**
- * @var \Magento\Framework\Escaper
- */
- private $escaper;
-
- /**
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- * @param \Magento\Framework\UrlInterface $urlBuilder
- * @param \Magento\Tax\Model\Config $taxConfig
+ * @param StoreManagerInterface $storeManager Store manager object @deprecated 100.1.0
+ * @param UrlInterface $urlBuilder
+ * @param TaxConfig $taxConfig Tax configuration object
* @param NotificationInterface[] $notifications
- * @param \Magento\Framework\Escaper|null $escaper
+ * @param Escaper|null $escaper
*/
public function __construct(
- \Magento\Store\Model\StoreManagerInterface $storeManager,
- \Magento\Framework\UrlInterface $urlBuilder,
- \Magento\Tax\Model\Config $taxConfig,
- $notifications = [],
- \Magento\Framework\Escaper $escaper = null
+ protected readonly StoreManagerInterface $storeManager,
+ protected readonly UrlInterface $urlBuilder,
+ protected readonly TaxConfig $taxConfig,
+ private $notifications = [],
+ private ?Escaper $escaper = null
) {
- $this->storeManager = $storeManager;
- $this->urlBuilder = $urlBuilder;
- $this->taxConfig = $taxConfig;
- $this->notifications = $notifications;
- $this->escaper = $escaper ?: ObjectManager::getInstance()->get(\Magento\Framework\Escaper::class);
+ $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
}
/**
@@ -166,18 +139,18 @@ public function getManageUrl()
* Tax Calculation Method Based On 'Total' or 'Row'
* and at least one Price Display Settings has 'Including and Excluding Tax' value
*
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
+ * @param null|int|bool|string|Store $store $store
* @return bool
* @deprecated 100.1.3
* @see \Magento\Tax\Model\System\Message\Notification\RoundingErrors::checkSettings
*/
public function checkDisplaySettings($store = null)
{
- if ($this->taxConfig->getAlgorithm($store) == \Magento\Tax\Model\Calculation::CALC_UNIT_BASE) {
+ if ($this->taxConfig->getAlgorithm($store) == Calculation::CALC_UNIT_BASE) {
return true;
}
- return $this->taxConfig->getPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH
- && $this->taxConfig->getShippingPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH
+ return $this->taxConfig->getPriceDisplayType($store) != TaxConfig::DISPLAY_TYPE_BOTH
+ && $this->taxConfig->getShippingPriceDisplayType($store) != TaxConfig::DISPLAY_TYPE_BOTH
&& !$this->taxConfig->displayCartPricesBoth($store)
&& !$this->taxConfig->displayCartSubtotalBoth($store)
&& !$this->taxConfig->displayCartShippingBoth($store)
@@ -193,7 +166,7 @@ public function checkDisplaySettings($store = null)
* Before Discount / Excluding Tax
* Before Discount / Including Tax
*
- * @param null|int|bool|string|\Magento\Store\Model\Store $store $store
+ * @param null|int|bool|string|Store $store $store
* @return bool
* @deprecated 100.1.3
* @see \Magento\Tax\Model\System\Message\Notification\DiscountErrors::checkSettings
diff --git a/app/code/Magento/Tax/Model/TaxAddressManager.php b/app/code/Magento/Tax/Model/TaxAddressManager.php
index ea44a740205d6..586fc8c90e03f 100644
--- a/app/code/Magento/Tax/Model/TaxAddressManager.php
+++ b/app/code/Magento/Tax/Model/TaxAddressManager.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Tax\Model;
+use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Model\Address;
use Magento\Customer\Model\Session;
use Magento\Tax\Api\TaxAddressManagerInterface;
@@ -15,18 +16,11 @@
class TaxAddressManager implements TaxAddressManagerInterface
{
/**
- * Customer session model.
- *
- * @var Session
+ * @param Session $customerSession Customer session model.
*/
- private $customerSession;
-
- /**
- * @param Session $customerSession
- */
- public function __construct(Session $customerSession)
- {
- $this->customerSession = $customerSession;
+ public function __construct(
+ private readonly Session $customerSession
+ ) {
}
/**
@@ -60,7 +54,7 @@ public function setDefaultAddressAfterSave(Address $address)
/**
* Set default Tax Shipping and Billing addresses into customer session after login.
*
- * @param \Magento\Customer\Api\Data\AddressInterface[] $addresses
+ * @param AddressInterface[] $addresses
* @return void
*/
public function setDefaultAddressAfterLogIn(array $addresses)
diff --git a/app/code/Magento/Tax/Model/TaxCalculation.php b/app/code/Magento/Tax/Model/TaxCalculation.php
index ac18dfec6c7ed..07bdf7e4cd7c3 100644
--- a/app/code/Magento/Tax/Model/TaxCalculation.php
+++ b/app/code/Magento/Tax/Model/TaxCalculation.php
@@ -6,6 +6,9 @@
namespace Magento\Tax\Model;
+use Magento\Framework\Api\DataObjectHelper;
+use Magento\Tax\Api\Data\QuoteDetailsInterface;
+use Magento\Tax\Api\Data\TaxDetailsInterface;
use Magento\Tax\Api\TaxCalculationInterface;
use Magento\Tax\Api\TaxClassManagementInterface;
use Magento\Tax\Api\Data\TaxDetailsItemInterface;
@@ -25,20 +28,6 @@
*/
class TaxCalculation implements TaxCalculationInterface
{
- /**
- * Tax Details factory
- *
- * @var TaxDetailsInterfaceFactory
- */
- protected $taxDetailsDataObjectFactory;
-
- /**
- * Tax configuration object
- *
- * @var Config
- */
- protected $config;
-
/**
* Tax calculation model
*
@@ -53,18 +42,6 @@ class TaxCalculation implements TaxCalculationInterface
*/
protected $discountTaxCompensations;
- /**
- * Tax details item factory
- *
- * @var TaxDetailsItemInterfaceFactory
- */
- protected $taxDetailsItemDataObjectFactory;
-
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- protected $storeManager;
-
/**
* Item code to Item object array.
*
@@ -79,60 +56,34 @@ class TaxCalculation implements TaxCalculationInterface
*/
private $parentToChildren;
- /**
- * Tax Class Management
- *
- * @var TaxClassManagementInterface
- */
- protected $taxClassManagement;
-
- /**
- * Calculator Factory
- *
- * @var CalculatorFactory
- */
- protected $calculatorFactory;
-
- /**
- * @var \Magento\Framework\Api\DataObjectHelper
- */
- protected $dataObjectHelper;
-
/**
* @param Calculation $calculation
- * @param CalculatorFactory $calculatorFactory
- * @param Config $config
- * @param TaxDetailsInterfaceFactory $taxDetailsDataObjectFactory
- * @param TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory
+ * @param CalculatorFactory $calculatorFactory Calculator Factory
+ * @param Config $config Tax configuration object
+ * @param TaxDetailsInterfaceFactory $taxDetailsDataObjectFactory Tax Details factory
+ * @param TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory Tax details item factory
* @param StoreManagerInterface $storeManager
- * @param TaxClassManagementInterface $taxClassManagement
- * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
+ * @param TaxClassManagementInterface $taxClassManagement Tax Class Management
+ * @param DataObjectHelper $dataObjectHelper
*/
public function __construct(
Calculation $calculation,
- CalculatorFactory $calculatorFactory,
- Config $config,
- TaxDetailsInterfaceFactory $taxDetailsDataObjectFactory,
- TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory,
- StoreManagerInterface $storeManager,
- TaxClassManagementInterface $taxClassManagement,
- \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
+ protected readonly CalculatorFactory $calculatorFactory,
+ protected readonly Config $config,
+ protected readonly TaxDetailsInterfaceFactory $taxDetailsDataObjectFactory,
+ protected readonly TaxDetailsItemInterfaceFactory $taxDetailsItemDataObjectFactory,
+ protected readonly StoreManagerInterface $storeManager,
+ protected readonly TaxClassManagementInterface $taxClassManagement,
+ protected readonly DataObjectHelper $dataObjectHelper
) {
$this->calculationTool = $calculation;
- $this->calculatorFactory = $calculatorFactory;
- $this->config = $config;
- $this->taxDetailsDataObjectFactory = $taxDetailsDataObjectFactory;
- $this->taxDetailsItemDataObjectFactory = $taxDetailsItemDataObjectFactory;
- $this->storeManager = $storeManager;
- $this->taxClassManagement = $taxClassManagement;
- $this->dataObjectHelper = $dataObjectHelper;
}
/**
* {@inheritdoc}
*/
public function calculateTax(
- \Magento\Tax\Api\Data\QuoteDetailsInterface $quoteDetails,
+ QuoteDetailsInterface $quoteDetails,
$storeId = null,
$round = true
) {
@@ -193,7 +144,7 @@ public function calculateTax(
$this->dataObjectHelper->populateWithArray(
$taxDetailsDataObject,
$taxDetailsData,
- \Magento\Tax\Api\Data\TaxDetailsInterface::class
+ TaxDetailsInterface::class
);
$taxDetailsDataObject->setItems($processedItems);
return $taxDetailsDataObject;
diff --git a/app/code/Magento/Tax/Model/TaxClass/AbstractType.php b/app/code/Magento/Tax/Model/TaxClass/AbstractType.php
index 88a9d0370db18..47996908b8106 100644
--- a/app/code/Magento/Tax/Model/TaxClass/AbstractType.php
+++ b/app/code/Magento/Tax/Model/TaxClass/AbstractType.php
@@ -9,10 +9,14 @@
*/
namespace Magento\Tax\Model\TaxClass;
-abstract class AbstractType extends \Magento\Framework\DataObject implements Type\TypeInterface
+use Magento\Framework\DataObject;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+use Magento\Tax\Model\Calculation\Rule as CalculationRule;
+
+abstract class AbstractType extends DataObject implements Type\TypeInterface
{
/**
- * @var \Magento\Tax\Model\Calculation\Rule
+ * @var CalculationRule
*/
protected $_calculationRule;
@@ -24,10 +28,10 @@ abstract class AbstractType extends \Magento\Framework\DataObject implements Typ
protected $_classType;
/**
- * @param \Magento\Tax\Model\Calculation\Rule $calculationRule
+ * @param CalculationRule $calculationRule
* @param array $data
*/
- public function __construct(\Magento\Tax\Model\Calculation\Rule $calculationRule, array $data = [])
+ public function __construct(CalculationRule $calculationRule, array $data = [])
{
parent::__construct($data);
$this->_calculationRule = $calculationRule;
@@ -36,7 +40,7 @@ public function __construct(\Magento\Tax\Model\Calculation\Rule $calculationRule
/**
* Get Collection of Tax Rules that are assigned to this tax class
*
- * @return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+ * @return AbstractCollection
*/
public function getAssignedToRules()
{
diff --git a/app/code/Magento/Tax/Model/TaxClass/Factory.php b/app/code/Magento/Tax/Model/TaxClass/Factory.php
index db028e54aef03..5e6180e767ddb 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Factory.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Factory.php
@@ -9,10 +9,17 @@
*/
namespace Magento\Tax\Model\TaxClass;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Tax\Model\ClassModel as TaxClassModel;
+use Magento\Tax\Model\TaxClass\Type\Customer as TaxClassTypeCustomer;
+use Magento\Tax\Model\TaxClass\Type\Product as TaxClassTypeProduct;
+use Magento\Tax\Model\TaxClass\Type\TypeInterface as TaxClassTypeInterface;
+
class Factory
{
/**
- * @var \Magento\Framework\ObjectManagerInterface
+ * @var ObjectManagerInterface
*/
protected $_objectManager;
@@ -22,30 +29,31 @@ class Factory
* @var array
*/
protected $_types = [
- \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER => \Magento\Tax\Model\TaxClass\Type\Customer::class,
- \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT => \Magento\Tax\Model\TaxClass\Type\Product::class,
+ TaxClassModel::TAX_CLASS_TYPE_CUSTOMER => TaxClassTypeCustomer::class,
+ TaxClassModel::TAX_CLASS_TYPE_PRODUCT => TaxClassTypeProduct::class,
];
/**
- * @param \Magento\Framework\ObjectManagerInterface $objectManager
+ * @param ObjectManagerInterface $objectManager
*/
- public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
- {
+ public function __construct(
+ ObjectManagerInterface $objectManager
+ ) {
$this->_objectManager = $objectManager;
}
/**
* Create new config object
*
- * @param \Magento\Tax\Model\ClassModel $taxClass
- * @return \Magento\Tax\Model\TaxClass\Type\TypeInterface
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @param TaxClassModel $taxClass
+ * @return TaxClassTypeInterface
+ * @throws LocalizedException
*/
- public function create(\Magento\Tax\Model\ClassModel $taxClass)
+ public function create(TaxClassModel $taxClass)
{
$taxClassType = $taxClass->getClassType();
if (!array_key_exists($taxClassType, $this->_types)) {
- throw new \Magento\Framework\Exception\LocalizedException(
+ throw new LocalizedException(
__('Invalid type of tax class "%1"', $taxClassType)
);
}
diff --git a/app/code/Magento/Tax/Model/TaxClass/Key.php b/app/code/Magento/Tax/Model/TaxClass/Key.php
index 8b8eb294e1c4f..00d11cdf880f6 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Key.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Key.php
@@ -6,6 +6,7 @@
namespace Magento\Tax\Model\TaxClass;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\TaxClassKeyExtensionInterface;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
/**
@@ -61,7 +62,7 @@ public function setValue($value)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\TaxClassKeyExtensionInterface|null
+ * @return TaxClassKeyExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -71,10 +72,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\TaxClassKeyExtensionInterface $extensionAttributes
+ * @param TaxClassKeyExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxClassKeyExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxClassKeyExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/TaxClass/Management.php b/app/code/Magento/Tax/Model/TaxClass/Management.php
index 67a8eb4f0d37d..d45d18cebd40c 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Management.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Management.php
@@ -10,44 +10,22 @@
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
+use Magento\Tax\Api\TaxClassManagementInterface;
use Magento\Tax\Model\ClassModel;
+use Magento\Tax\Model\TaxClass\Repository as TaxClassRepository;
-class Management implements \Magento\Tax\Api\TaxClassManagementInterface
+class Management implements TaxClassManagementInterface
{
/**
- * Filter Builder
- *
- * @var FilterBuilder
- */
- protected $filterBuilder;
-
- /**
- * Search Criteria Builder
- *
- * @var SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
- /**
- * Tax class repository
- *
- * @var \Magento\Tax\Model\TaxClass\Repository
- */
- protected $classRepository;
-
- /**
- * @param SearchCriteriaBuilder $searchCriteriaBuilder
- * @param FilterBuilder $filterBuilder
- * @param Repository $classRepository
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder Search Criteria Builder
+ * @param FilterBuilder $filterBuilder Filter Builder
+ * @param Repository $classRepository Tax class repository
*/
public function __construct(
- SearchCriteriaBuilder $searchCriteriaBuilder,
- FilterBuilder $filterBuilder,
- \Magento\Tax\Model\TaxClass\Repository $classRepository
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder,
+ protected readonly FilterBuilder $filterBuilder,
+ protected readonly TaxClassRepository $classRepository
) {
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
- $this->filterBuilder = $filterBuilder;
- $this->classRepository = $classRepository;
}
/**
diff --git a/app/code/Magento/Tax/Model/TaxClass/Repository.php b/app/code/Magento/Tax/Model/TaxClass/Repository.php
index f0d2fa963a571..db7eb55b5ccc0 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Repository.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Repository.php
@@ -7,11 +7,14 @@
namespace Magento\Tax\Model\TaxClass;
+use Exception;
+use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\FilterGroup;
use Magento\Framework\Api\SearchCriteria\CollectionProcessor;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\InputException;
@@ -19,86 +22,43 @@
use Magento\Framework\Validator\NotEmpty;
use Magento\Framework\Validator\ValidateException;
use Magento\Framework\Validator\ValidatorChain;
+use Magento\Tax\Api\Data\TaxClassInterface;
+use Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory;
use Magento\Tax\Api\TaxClassManagementInterface;
+use Magento\Tax\Api\TaxClassRepositoryInterface;
use Magento\Tax\Model\ClassModel;
use Magento\Tax\Model\ClassModelRegistry;
+use Magento\Tax\Model\ResourceModel\TaxClass as ResourceTaxClass;
use Magento\Tax\Model\ResourceModel\TaxClass\Collection as TaxClassCollection;
use Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory as TaxClassCollectionFactory;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface
+class Repository implements TaxClassRepositoryInterface
{
public const CLASS_ID_NOT_ALLOWED = 'class_id is not expected for this request.';
- /**
- * @var TaxClassCollectionFactory
- */
- protected $taxClassCollectionFactory;
-
- /**
- * @var \Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory
- */
- protected $searchResultsFactory;
-
- /**
- * @var ClassModelRegistry
- */
- protected $classModelRegistry;
-
- /**
- * @var SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
- /**
- * @var FilterBuilder
- */
- protected $filterBuilder;
-
- /**
- * @var \Magento\Tax\Model\ResourceModel\TaxClass
- */
- protected $taxClassResource;
-
- /**
- * @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
- */
- protected $joinProcessor;
-
- /**
- * @var \Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface
- */
- private $collectionProcessor;
-
/**
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
* @param TaxClassCollectionFactory $taxClassCollectionFactory
- * @param \Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory $searchResultsFactory
+ * @param TaxClassSearchResultsInterfaceFactory $searchResultsFactory
* @param ClassModelRegistry $classModelRegistry
- * @param \Magento\Tax\Model\ResourceModel\TaxClass $taxClassResource
- * @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
- * @param CollectionProcessorInterface $collectionProcessor
+ * @param ResourceTaxClass $taxClassResource
+ * @param JoinProcessorInterface $joinProcessor
+ * @param CollectionProcessorInterface|null $collectionProcessor
*/
public function __construct(
- SearchCriteriaBuilder $searchCriteriaBuilder,
- FilterBuilder $filterBuilder,
- TaxClassCollectionFactory $taxClassCollectionFactory,
- \Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory $searchResultsFactory,
- ClassModelRegistry $classModelRegistry,
- \Magento\Tax\Model\ResourceModel\TaxClass $taxClassResource,
- \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor,
- CollectionProcessorInterface $collectionProcessor = null
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder,
+ protected readonly FilterBuilder $filterBuilder,
+ protected readonly TaxClassCollectionFactory $taxClassCollectionFactory,
+ protected readonly TaxClassSearchResultsInterfaceFactory $searchResultsFactory,
+ protected readonly ClassModelRegistry $classModelRegistry,
+ protected readonly ResourceTaxClass $taxClassResource,
+ protected readonly JoinProcessorInterface $joinProcessor,
+ private ?CollectionProcessorInterface $collectionProcessor = null
) {
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
- $this->filterBuilder = $filterBuilder;
- $this->taxClassCollectionFactory = $taxClassCollectionFactory;
- $this->searchResultsFactory = $searchResultsFactory;
- $this->classModelRegistry = $classModelRegistry;
- $this->taxClassResource = $taxClassResource;
- $this->joinProcessor = $joinProcessor;
$this->collectionProcessor = $collectionProcessor
?: ObjectManager::getInstance()->get(CollectionProcessor::class);
}
@@ -106,7 +66,7 @@ public function __construct(
/**
* @inheritdoc
*/
- public function save(\Magento\Tax\Api\Data\TaxClassInterface $taxClass)
+ public function save(TaxClassInterface $taxClass)
{
if ($taxClass->getClassId()) {
$originalTaxClassModel = $this->get($taxClass->getClassId());
@@ -146,14 +106,14 @@ public function get($taxClassId)
/**
* @inheritdoc
*/
- public function delete(\Magento\Tax\Api\Data\TaxClassInterface $taxClass)
+ public function delete(TaxClassInterface $taxClass)
{
$taxClassId = $taxClass->getClassId();
try {
$this->taxClassResource->delete($taxClass);
} catch (CouldNotDeleteException $e) {
throw $e;
- } catch (\Exception $e) {
+ } catch (Exception $e) {
return false;
}
$this->classModelRegistry->remove($taxClassId);
@@ -172,11 +132,11 @@ public function deleteById($taxClassId)
/**
* Validate TaxClass Data
*
- * @param \Magento\Tax\Api\Data\TaxClassInterface $taxClass
+ * @param TaxClassInterface $taxClass
* @return void
* @throws InputException|ValidateException
*/
- protected function validateTaxClassData(\Magento\Tax\Api\Data\TaxClassInterface $taxClass)
+ protected function validateTaxClassData(TaxClassInterface $taxClass)
{
$exception = new InputException();
@@ -210,7 +170,7 @@ protected function validateTaxClassData(\Magento\Tax\Api\Data\TaxClassInterface
/**
* @inheritdoc
*/
- public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
+ public function getList(SearchCriteriaInterface $searchCriteria)
{
$searchResults = $this->searchResultsFactory->create();
$searchResults->setSearchCriteria($searchCriteria);
diff --git a/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php b/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php
index 80e1293984bb8..5f0c8a168b91d 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Source/Customer.php
@@ -6,45 +6,31 @@
namespace Magento\Tax\Model\TaxClass\Source;
+use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Exception\StateException;
use Magento\Tax\Api\TaxClassManagementInterface;
+use Magento\Tax\Api\TaxClassRepositoryInterface;
use Magento\Tax\Model\ClassModel;
/**
* Customer tax class source model.
*/
-class Customer extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
+class Customer extends AbstractSource
{
- /**
- * @var \Magento\Tax\Api\TaxClassRepositoryInterface
- */
- protected $taxClassRepository;
-
- /**
- * @var \Magento\Framework\Api\SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
- /**
- * @var \Magento\Framework\Api\FilterBuilder
- */
- protected $filterBuilder;
-
/**
* Initialize dependencies.
*
- * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassRepository
- * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
- * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
+ * @param TaxClassRepositoryInterface $taxClassRepository
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder
+ * @param FilterBuilder $filterBuilder
*/
public function __construct(
- \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassRepository,
- \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
- \Magento\Framework\Api\FilterBuilder $filterBuilder
+ protected readonly TaxClassRepositoryInterface $taxClassRepository,
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder,
+ protected readonly FilterBuilder $filterBuilder
) {
- $this->taxClassRepository = $taxClassRepository;
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
- $this->filterBuilder = $filterBuilder;
}
/**
diff --git a/app/code/Magento/Tax/Model/TaxClass/Source/Product.php b/app/code/Magento/Tax/Model/TaxClass/Source/Product.php
index 8dc6929a7b08e..08968f73944db 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Source/Product.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Source/Product.php
@@ -6,53 +6,61 @@
namespace Magento\Tax\Model\TaxClass\Source;
+use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option as ResourceEntityAttributeOption;
+use Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\DB\Ddl\Table;
+use Magento\Framework\DB\Select;
use Magento\Tax\Api\TaxClassManagementInterface;
+use Magento\Tax\Api\TaxClassRepositoryInterface;
use Magento\Tax\Model\ClassModel;
+use Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory;
/**
* Product tax class source model.
*/
-class Product extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
+class Product extends AbstractSource
{
/**
- * @var \Magento\Tax\Api\TaxClassRepositoryInterface
+ * @var TaxClassRepositoryInterface
*/
protected $_taxClassRepository;
/**
- * @var \Magento\Framework\Api\SearchCriteriaBuilder
+ * @var SearchCriteriaBuilder
*/
protected $_searchCriteriaBuilder;
/**
- * @var \Magento\Framework\Api\FilterBuilder
+ * @var FilterBuilder
*/
protected $_filterBuilder;
/**
- * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory
+ * @var OptionFactory
*/
protected $_optionFactory;
/**
- * @var \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory
+ * @var CollectionFactory
*/
private $_classesFactory;
/**
- * @param \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory $classesFactory
- * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $optionFactory
- * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassRepository
- * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
- * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
+ * @param CollectionFactory $classesFactory
+ * @param OptionFactory $optionFactory
+ * @param TaxClassRepositoryInterface $taxClassRepository
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder
+ * @param FilterBuilder $filterBuilder
*/
public function __construct(
- \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory $classesFactory,
- \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $optionFactory,
- \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassRepository,
- \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
- \Magento\Framework\Api\FilterBuilder $filterBuilder
+ CollectionFactory $classesFactory,
+ OptionFactory $optionFactory,
+ TaxClassRepositoryInterface $taxClassRepository,
+ SearchCriteriaBuilder $searchCriteriaBuilder,
+ FilterBuilder $filterBuilder
) {
$this->_classesFactory = $classesFactory;
$this->_optionFactory = $optionFactory;
@@ -136,12 +144,12 @@ public function getFlatColumns()
/**
* Retrieve Select for update attribute value in flat table
*
- * @param int $store
- * @return \Magento\Framework\DB\Select|null
+ * @param int $store
+ * @return Select|null
*/
public function getFlatUpdateSelect($store)
{
- /** @var $option \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option */
+ /** @var ResourceEntityAttributeOption $option */
$option = $this->_optionFactory->create();
return $option->getFlatUpdateSelect($this->getAttribute(), $store, false);
}
diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php b/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php
index fe8791f0cf7b6..c967c0f37d8ff 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Type/Customer.php
@@ -7,52 +7,40 @@
use Magento\Customer\Api\Data\GroupInterface as CustomerGroup;
use Magento\Customer\Api\GroupRepositoryInterface as CustomerGroupRepository;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Phrase;
+use Magento\Tax\Model\Calculation\Rule as CalculationRule;
+use Magento\Tax\Model\ClassModel as TaxClassModel;
+use Magento\Tax\Model\TaxClass\AbstractType as TaxClassAbstractType;
/**
* Customer Tax Class
*/
-class Customer extends \Magento\Tax\Model\TaxClass\AbstractType
+class Customer extends TaxClassAbstractType
{
- /**
- * @var CustomerGroupRepository
- */
- protected $customerGroupRepository;
-
- /**
- * @var \Magento\Framework\Api\FilterBuilder
- */
- protected $filterBuilder;
-
- /**
- * @var \Magento\Framework\Api\SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
/**
* Class Type
*
* @var string
*/
- protected $_classType = \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER;
+ protected $_classType = TaxClassModel::TAX_CLASS_TYPE_CUSTOMER;
/**
- * @param \Magento\Tax\Model\Calculation\Rule $calculationRule
+ * @param CalculationRule $calculationRule
* @param CustomerGroupRepository $customerGroupRepository
- * @param \Magento\Framework\Api\FilterBuilder $filterBuilder
- * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
+ * @param FilterBuilder $filterBuilder
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param array $data
*/
public function __construct(
- \Magento\Tax\Model\Calculation\Rule $calculationRule,
- CustomerGroupRepository $customerGroupRepository,
- \Magento\Framework\Api\FilterBuilder $filterBuilder,
- \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
+ CalculationRule $calculationRule,
+ protected readonly CustomerGroupRepository $customerGroupRepository,
+ protected readonly FilterBuilder $filterBuilder,
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder,
array $data = []
) {
parent::__construct($calculationRule, $data);
- $this->customerGroupRepository = $customerGroupRepository;
- $this->filterBuilder = $filterBuilder;
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
/**
@@ -75,7 +63,7 @@ public function isAssignedToObjects()
/**
* Get Name of Objects that use this Tax Class Type
*
- * @return \Magento\Framework\Phrase
+ * @return Phrase
*/
public function getObjectTypeName()
{
diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/Product.php b/app/code/Magento/Tax/Model/TaxClass/Type/Product.php
index 92d5a0bccd43d..8b31811a3e082 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Type/Product.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Type/Product.php
@@ -9,10 +9,16 @@
*/
namespace Magento\Tax\Model\TaxClass\Type;
-class Product extends \Magento\Tax\Model\TaxClass\AbstractType
+use Magento\Catalog\Model\Product as ModelProduct;
+use Magento\Framework\Phrase;
+use Magento\Tax\Model\Calculation\Rule as CalculationRule;
+use Magento\Tax\Model\ClassModel as TaxClassModel;
+use Magento\Tax\Model\TaxClass\AbstractType as TaxClassAbstractType;
+
+class Product extends TaxClassAbstractType
{
/**
- * @var \Magento\Catalog\Model\Product
+ * @var ModelProduct
*/
protected $_modelProduct;
@@ -21,16 +27,16 @@ class Product extends \Magento\Tax\Model\TaxClass\AbstractType
*
* @var string
*/
- protected $_classType = \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT;
+ protected $_classType = TaxClassModel::TAX_CLASS_TYPE_PRODUCT;
/**
- * @param \Magento\Tax\Model\Calculation\Rule $calculationRule
- * @param \Magento\Catalog\Model\Product $modelProduct
+ * @param CalculationRule $calculationRule
+ * @param ModelProduct $modelProduct
* @param array $data
*/
public function __construct(
- \Magento\Tax\Model\Calculation\Rule $calculationRule,
- \Magento\Catalog\Model\Product $modelProduct,
+ CalculationRule $calculationRule,
+ ModelProduct $modelProduct,
array $data = []
) {
parent::__construct($calculationRule, $data);
@@ -49,7 +55,7 @@ public function isAssignedToObjects()
/**
* Get Name of Objects that use this Tax Class Type
*
- * @return \Magento\Framework\Phrase
+ * @return Phrase
*/
public function getObjectTypeName()
{
diff --git a/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php b/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php
index 2c1142e8c513e..dab828d9d903c 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Type/TypeInterface.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Tax\Model\TaxClass\Type;
+use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
+
/**
* Interface \Magento\Tax\Model\TaxClass\Type\TypeInterface
*
@@ -22,7 +24,7 @@ public function isAssignedToObjects();
/**
* Get Collection of Tax Rules that are assigned to this tax class
*
- * @return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
+ * @return AbstractCollection
*/
public function getAssignedToRules();
diff --git a/app/code/Magento/Tax/Model/TaxConfigProvider.php b/app/code/Magento/Tax/Model/TaxConfigProvider.php
index db53ba6a171c1..966ba0335f185 100644
--- a/app/code/Magento/Tax/Model/TaxConfigProvider.php
+++ b/app/code/Magento/Tax/Model/TaxConfigProvider.php
@@ -6,32 +6,14 @@
namespace Magento\Tax\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
+use Magento\Store\Model\ScopeInterface;
use Magento\Tax\Helper\Data as TaxHelper;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Checkout\Model\Session as CheckoutSession;
+use Magento\Tax\Model\Config as TaxConfig;
class TaxConfigProvider implements ConfigProviderInterface
{
- /**
- * @var TaxHelper
- */
- protected $taxHelper;
-
- /**
- * @var Config
- */
- protected $taxConfig;
-
- /**
- * @var ScopeConfigInterface
- */
- protected $scopeConfig;
-
- /**
- * @var CheckoutSession
- */
- protected $checkoutSession;
-
/**
* @param TaxHelper $taxHelper
* @param Config $taxConfig
@@ -39,15 +21,11 @@ class TaxConfigProvider implements ConfigProviderInterface
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
- TaxHelper $taxHelper,
- Config $taxConfig,
- CheckoutSession $checkoutSession,
- ScopeConfigInterface $scopeConfig
+ protected readonly TaxHelper $taxHelper,
+ protected readonly Config $taxConfig,
+ protected readonly CheckoutSession $checkoutSession,
+ protected readonly ScopeConfigInterface $scopeConfig
) {
- $this->taxHelper = $taxHelper;
- $this->taxConfig = $taxConfig;
- $this->checkoutSession = $checkoutSession;
- $this->scopeConfig = $scopeConfig;
}
/**
@@ -56,8 +34,8 @@ public function __construct(
public function getConfig()
{
$defaultRegionId = $this->scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_REGION,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ TaxConfig::CONFIG_XML_PATH_DEFAULT_REGION,
+ ScopeInterface::SCOPE_STORE
);
// prevent wrong assignment on shipping rate estimation requests
if (0 == $defaultRegionId) {
@@ -74,13 +52,13 @@ public function getConfig()
'isZeroTaxDisplayed' => $this->taxConfig->displayCartZeroTax(),
'reloadOnBillingAddress' => $this->reloadOnBillingAddress(),
'defaultCountryId' => $this->scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_COUNTRY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ TaxConfig::CONFIG_XML_PATH_DEFAULT_COUNTRY,
+ ScopeInterface::SCOPE_STORE
),
'defaultRegionId' => $defaultRegionId,
'defaultPostcode' => $this->scopeConfig->getValue(
- \Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_POSTCODE,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ TaxConfig::CONFIG_XML_PATH_DEFAULT_POSTCODE,
+ ScopeInterface::SCOPE_STORE
),
];
}
@@ -183,7 +161,7 @@ protected function reloadOnBillingAddress()
$quote = $this->checkoutSession->getQuote();
$configValue = $this->scopeConfig->getValue(
Config::CONFIG_XML_PATH_BASED_ON,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ ScopeInterface::SCOPE_STORE
);
return 'billing' == $configValue || $quote->isVirtual();
}
diff --git a/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php b/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php
index f36de79ba6368..e624b1f838dd1 100644
--- a/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php
+++ b/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php
@@ -6,7 +6,9 @@
namespace Magento\Tax\Model\TaxDetails;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\AppliedTaxExtensionInterface;
use Magento\Tax\Api\Data\AppliedTaxInterface;
+use Magento\Tax\Api\Data\AppliedTaxRateInterface;
/**
* @codeCoverageIgnore
@@ -90,7 +92,7 @@ public function setAmount($amount)
/**
* Set rates
*
- * @param \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $rates
+ * @param AppliedTaxRateInterface[] $rates
* @return $this
*/
public function setRates(array $rates = null)
@@ -101,7 +103,7 @@ public function setRates(array $rates = null)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\AppliedTaxExtensionInterface|null
+ * @return AppliedTaxExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -111,10 +113,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes
+ * @param AppliedTaxExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(AppliedTaxExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php b/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php
index 0e0ec13f13497..61d2352ff0af4 100644
--- a/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php
+++ b/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php
@@ -6,6 +6,7 @@
namespace Magento\Tax\Model\TaxDetails;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface;
use Magento\Tax\Api\Data\AppliedTaxRateInterface;
/**
@@ -81,7 +82,7 @@ public function setPercent($percent)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface|null
+ * @return AppliedTaxRateExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -91,10 +92,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface $extensionAttributes
+ * @param AppliedTaxRateExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(AppliedTaxRateExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php b/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php
index 767d383e395fe..f721163066413 100644
--- a/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php
+++ b/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php
@@ -6,6 +6,8 @@
namespace Magento\Tax\Model\TaxDetails;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\AppliedTaxInterface;
+use Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface;
use Magento\Tax\Api\Data\TaxDetailsItemInterface;
/**
@@ -262,7 +264,7 @@ public function setDiscountTaxCompensationAmount($discountTaxCompensationAmount)
/**
* Set applied taxes
*
- * @param \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes
+ * @param AppliedTaxInterface[] $appliedTaxes
* @return $this
*/
public function setAppliedTaxes(array $appliedTaxes = null)
@@ -284,7 +286,7 @@ public function setAssociatedItemCode($associatedItemCode)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface|null
+ * @return TaxDetailsItemExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -294,10 +296,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes
+ * @param TaxDetailsItemExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxDetailsItemExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php b/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php
index bba6807c95451..223805a0cad5b 100644
--- a/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php
+++ b/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php
@@ -6,7 +6,10 @@
namespace Magento\Tax\Model\TaxDetails;
use Magento\Framework\Model\AbstractExtensibleModel;
+use Magento\Tax\Api\Data\AppliedTaxInterface;
+use Magento\Tax\Api\Data\TaxDetailsExtensionInterface;
use Magento\Tax\Api\Data\TaxDetailsInterface;
+use Magento\Tax\Api\Data\TaxDetailsItemInterface;
/**
* @codeCoverageIgnore
@@ -102,7 +105,7 @@ public function setDiscountTaxCompensationAmount($discountTaxCompensationAmount)
/**
* Set applied taxes
*
- * @param \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes
+ * @param AppliedTaxInterface[] $appliedTaxes
* @return $this
*/
public function setAppliedTaxes(array $appliedTaxes = null)
@@ -113,7 +116,7 @@ public function setAppliedTaxes(array $appliedTaxes = null)
/**
* Set TaxDetails items
*
- * @param \Magento\Tax\Api\Data\TaxDetailsItemInterface[] $items
+ * @param TaxDetailsItemInterface[] $items
* @return $this
*/
public function setItems(array $items = null)
@@ -124,7 +127,7 @@ public function setItems(array $items = null)
/**
* {@inheritdoc}
*
- * @return \Magento\Tax\Api\Data\TaxDetailsExtensionInterface|null
+ * @return TaxDetailsExtensionInterface|null
*/
public function getExtensionAttributes()
{
@@ -134,10 +137,10 @@ public function getExtensionAttributes()
/**
* {@inheritdoc}
*
- * @param \Magento\Tax\Api\Data\TaxDetailsExtensionInterface $extensionAttributes
+ * @param TaxDetailsExtensionInterface $extensionAttributes
* @return $this
*/
- public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsExtensionInterface $extensionAttributes)
+ public function setExtensionAttributes(TaxDetailsExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/Tax/Model/TaxRateCollection.php b/app/code/Magento/Tax/Model/TaxRateCollection.php
index 218682ffb6688..759d892f95dfe 100644
--- a/app/code/Magento/Tax/Model/TaxRateCollection.php
+++ b/app/code/Magento/Tax/Model/TaxRateCollection.php
@@ -6,6 +6,7 @@
namespace Magento\Tax\Model;
+use Magento\Framework\DataObject;
use Magento\Tax\Api\TaxRateRepositoryInterface;
use Magento\Framework\Data\Collection\EntityFactory;
use Magento\Framework\Api\AbstractServiceCollection;
@@ -13,6 +14,7 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
use Magento\Tax\Api\Data\TaxRateInterface as TaxRate;
+use Magento\Tax\Model\Calculation\Rate\Converter;
/**
* Tax rate collection for a grid backed by Services
@@ -25,11 +27,6 @@ class TaxRateCollection extends AbstractServiceCollection
*/
protected $taxRateRepository;
- /**
- * @var \Magento\Tax\Model\Calculation\Rate\Converter
- */
- protected $rateConverter;
-
/**
* Initialize dependencies.
*
@@ -38,7 +35,7 @@ class TaxRateCollection extends AbstractServiceCollection
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param SortOrderBuilder $sortOrderBuilder
* @param TaxRateRepositoryInterface $rateService
- * @param \Magento\Tax\Model\Calculation\Rate\Converter $rateConverter
+ * @param Converter $rateConverter
*/
public function __construct(
EntityFactory $entityFactory,
@@ -46,11 +43,10 @@ public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
SortOrderBuilder $sortOrderBuilder,
TaxRateRepositoryInterface $rateService,
- \Magento\Tax\Model\Calculation\Rate\Converter $rateConverter
+ protected readonly Converter $rateConverter
) {
parent::__construct($entityFactory, $filterBuilder, $searchCriteriaBuilder, $sortOrderBuilder);
$this->taxRateRepository = $rateService;
- $this->rateConverter = $rateConverter;
}
/**
@@ -74,11 +70,11 @@ public function loadData($printQuery = false, $logQuery = false)
* Creates a collection item that represents a tax rate for the tax rates grid.
*
* @param TaxRate $taxRate Input data for creating the item.
- * @return \Magento\Framework\DataObject Collection item that represents a tax rate
+ * @return DataObject Collection item that represents a tax rate
*/
protected function createTaxRateCollectionItem(TaxRate $taxRate)
{
- $collectionItem = new \Magento\Framework\DataObject();
+ $collectionItem = new DataObject();
$collectionItem->setTaxCalculationRateId($taxRate->getId());
$collectionItem->setCode($taxRate->getCode());
$collectionItem->setTaxCountryId($taxRate->getTaxCountryId());
diff --git a/app/code/Magento/Tax/Model/TaxRateManagement.php b/app/code/Magento/Tax/Model/TaxRateManagement.php
index ac28046a432ef..ba721877948c7 100644
--- a/app/code/Magento/Tax/Model/TaxRateManagement.php
+++ b/app/code/Magento/Tax/Model/TaxRateManagement.php
@@ -14,26 +14,6 @@
class TaxRateManagement implements TaxRateManagementInterface
{
- /**
- * @var SearchCriteriaBuilder
- */
- protected $searchCriteriaBuilder;
-
- /**
- * @var FilterBuilder
- */
- protected $filterBuilder;
-
- /**
- * @var TaxRuleRepositoryInterface
- */
- protected $taxRuleRepository;
-
- /**
- * @var TaxRateRepositoryInterface
- */
- protected $taxRateRepository;
-
/**
* @param TaxRuleRepositoryInterface $taxRuleRepository
* @param TaxRateRepositoryInterface $taxRateRepository
@@ -41,15 +21,11 @@ class TaxRateManagement implements TaxRateManagementInterface
* @param SearchCriteriaBuilder $searchCriteriaBuilder
*/
public function __construct(
- TaxRuleRepositoryInterface $taxRuleRepository,
- TaxRateRepositoryInterface $taxRateRepository,
- FilterBuilder $filterBuilder,
- SearchCriteriaBuilder $searchCriteriaBuilder
+ protected readonly TaxRuleRepositoryInterface $taxRuleRepository,
+ protected readonly TaxRateRepositoryInterface $taxRateRepository,
+ protected readonly FilterBuilder $filterBuilder,
+ protected readonly SearchCriteriaBuilder $searchCriteriaBuilder
) {
- $this->taxRuleRepository = $taxRuleRepository;
- $this->taxRateRepository = $taxRateRepository;
- $this->filterBuilder = $filterBuilder;
- $this->searchCriteriaBuilder = $searchCriteriaBuilder;
}
/**
diff --git a/app/code/Magento/Tax/Model/TaxRuleCollection.php b/app/code/Magento/Tax/Model/TaxRuleCollection.php
index 5c6f3b1f14455..f2c5d2ec8e7c6 100644
--- a/app/code/Magento/Tax/Model/TaxRuleCollection.php
+++ b/app/code/Magento/Tax/Model/TaxRuleCollection.php
@@ -11,6 +11,7 @@
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
+use Magento\Framework\DataObject;
use Magento\Tax\Api\Data\TaxRuleInterface;
use Magento\Tax\Api\TaxRuleRepositoryInterface;
@@ -19,11 +20,6 @@
*/
class TaxRuleCollection extends AbstractServiceCollection
{
- /**
- * @var TaxRuleRepositoryInterface
- */
- protected $ruleService;
-
/**
* Initialize dependencies.
*
@@ -38,10 +34,9 @@ public function __construct(
FilterBuilder $filterBuilder,
SearchCriteriaBuilder $searchCriteriaBuilder,
SortOrderBuilder $sortOrderBuilder,
- TaxRuleRepositoryInterface $ruleService
+ protected readonly TaxRuleRepositoryInterface $ruleService
) {
parent::__construct($entityFactory, $filterBuilder, $searchCriteriaBuilder, $sortOrderBuilder);
- $this->ruleService = $ruleService;
}
/**
@@ -65,11 +60,11 @@ public function loadData($printQuery = false, $logQuery = false)
* Creates a collection item that represents a tax rule for the tax rules grid.
*
* @param TaxRuleInterface $taxRule Input data for creating the item.
- * @return \Magento\Framework\DataObject Collection item that represents a tax rule
+ * @return DataObject Collection item that represents a tax rule
*/
protected function createTaxRuleCollectionItem(TaxRuleInterface $taxRule)
{
- $collectionItem = new \Magento\Framework\DataObject();
+ $collectionItem = new DataObject();
$collectionItem->setTaxCalculationRuleId($taxRule->getId());
$collectionItem->setCode($taxRule->getCode());
/* should cast to string so that some optional fields won't be null on the collection grid pages */
diff --git a/app/code/Magento/Tax/Model/TaxRuleRepository.php b/app/code/Magento/Tax/Model/TaxRuleRepository.php
index 9317519c57961..a41ebbc94ba41 100644
--- a/app/code/Magento/Tax/Model/TaxRuleRepository.php
+++ b/app/code/Magento/Tax/Model/TaxRuleRepository.php
@@ -6,8 +6,12 @@
namespace Magento\Tax\Model;
+use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\Search\FilterGroup;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
+use Magento\Framework\Api\SearchCriteriaInterface;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -26,11 +30,6 @@
*/
class TaxRuleRepository implements TaxRuleRepositoryInterface
{
- /**
- * @var TaxRuleRegistry
- */
- protected $taxRuleRegistry;
-
/**
* @var TaxRuleSearchResultsInterfaceFactory
*/
@@ -41,50 +40,26 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface
*/
protected $taxRuleModelFactory;
- /**
- * @var CollectionFactory
- */
- protected $collectionFactory;
-
- /**
- * @var ResourceRule
- */
- protected $resource;
-
- /**
- * @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
- */
- protected $joinProcessor;
-
- /**
- * @var CollectionProcessorInterface
- */
- private $collectionProcessor;
-
/**
* @param TaxRuleRegistry $taxRuleRegistry
* @param TaxRuleSearchResultsInterfaceFactory $searchResultsFactory
* @param RuleFactory $ruleFactory
* @param CollectionFactory $collectionFactory
* @param ResourceRule $resource
- * @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
+ * @param JoinProcessorInterface $joinProcessor
* @param CollectionProcessorInterface | null $collectionProcessor
*/
public function __construct(
- TaxRuleRegistry $taxRuleRegistry,
+ protected readonly TaxRuleRegistry $taxRuleRegistry,
TaxRuleSearchResultsInterfaceFactory $searchResultsFactory,
RuleFactory $ruleFactory,
- CollectionFactory $collectionFactory,
- ResourceRule $resource,
- \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor,
- CollectionProcessorInterface $collectionProcessor = null
+ protected readonly CollectionFactory $collectionFactory,
+ protected readonly ResourceRule $resource,
+ protected readonly JoinProcessorInterface $joinProcessor,
+ private ?CollectionProcessorInterface $collectionProcessor = null
) {
- $this->taxRuleRegistry = $taxRuleRegistry;
$this->taxRuleSearchResultsFactory = $searchResultsFactory;
$this->taxRuleModelFactory = $ruleFactory;
- $this->collectionFactory = $collectionFactory;
- $this->resource = $resource;
- $this->joinProcessor = $joinProcessor;
$this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
}
@@ -141,7 +116,7 @@ public function deleteById($ruleId)
/**
* {@inheritdoc}
*/
- public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
+ public function getList(SearchCriteriaInterface $searchCriteria)
{
$searchResults = $this->taxRuleSearchResultsFactory->create();
$searchResults->setSearchCriteria($searchCriteria);
@@ -162,7 +137,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
* @param Collection $collection
* @return void
* @deprecated 100.2.0
- * @throws \Magento\Framework\Exception\InputException
+ * @throws InputException
*/
protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
{
@@ -226,7 +201,7 @@ protected function translateField($field)
private function getCollectionProcessor()
{
if (!$this->collectionProcessor) {
- $this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
+ $this->collectionProcessor = ObjectManager::getInstance()->get(
'Magento\Tax\Model\Api\SearchCriteria\TaxRuleCollectionProcessor'
);
}
diff --git a/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php b/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php
index cf5d939b35c01..0fdd45dc8db61 100644
--- a/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php
+++ b/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php
@@ -18,48 +18,18 @@
*/
class AfterAddressSaveObserver implements ObserverInterface
{
- /**
- * @var Data
- */
- protected $taxHelper;
-
- /**
- * Module manager
- *
- * @var Manager
- */
- private $moduleManager;
-
- /**
- * Cache config
- *
- * @var Config
- */
- private $cacheConfig;
-
- /**
- * Manager to save data in customer session.
- *
- * @var TaxAddressManagerInterface
- */
- private $addressManager;
-
/**
* @param Data $taxHelper
- * @param Manager $moduleManager
- * @param Config $cacheConfig
- * @param TaxAddressManagerInterface $addressManager
+ * @param Manager $moduleManager Module manager
+ * @param Config $cacheConfig Cache config
+ * @param TaxAddressManagerInterface $addressManager Manager to save data in customer session.
*/
public function __construct(
- Data $taxHelper,
- Manager $moduleManager,
- Config $cacheConfig,
- TaxAddressManagerInterface $addressManager
+ protected readonly Data $taxHelper,
+ private readonly Manager $moduleManager,
+ private readonly Config $cacheConfig,
+ private readonly TaxAddressManagerInterface $addressManager
) {
- $this->taxHelper = $taxHelper;
- $this->moduleManager = $moduleManager;
- $this->cacheConfig = $cacheConfig;
- $this->addressManager = $addressManager;
}
/**
@@ -75,7 +45,7 @@ public function execute(Observer $observer)
&& $this->cacheConfig->isEnabled()
&& $this->taxHelper->isCatalogPriceDisplayAffectedByTax()
) {
- /** @var $customerAddress Address */
+ /** @var Address $customerAddress */
$address = $observer->getCustomerAddress();
$this->addressManager->setDefaultAddressAfterSave($address);
}
diff --git a/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php b/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php
index c1e4ad66d75d7..b4776cbc5cccd 100644
--- a/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php
+++ b/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php
@@ -6,6 +6,7 @@
namespace Magento\Tax\Observer;
use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Customer\Model\Data\Customer;
use Magento\Customer\Model\Session;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
@@ -20,64 +21,22 @@
*/
class CustomerLoggedInObserver implements ObserverInterface
{
- /**
- * @var Session
- */
- protected $customerSession;
-
- /**
- * @var Data
- */
- protected $taxHelper;
-
- /**
- * Module manager
- *
- * @var Manager
- */
- private $moduleManager;
-
- /**
- * Cache config
- *
- * @var Config
- */
- private $cacheConfig;
-
- /**
- * @var GroupRepositoryInterface
- */
- private $groupRepository;
-
- /**
- * Manager to save data in customer session.
- *
- * @var TaxAddressManagerInterface
- */
- private $addressManager;
-
/**
* @param GroupRepositoryInterface $groupRepository
* @param Session $customerSession
* @param Data $taxHelper
- * @param Manager $moduleManager
- * @param Config $cacheConfig
- * @param TaxAddressManagerInterface $addressManager
+ * @param Manager $moduleManager Module manager
+ * @param Config $cacheConfig Cache config
+ * @param TaxAddressManagerInterface $addressManager Manager to save data in customer session.
*/
public function __construct(
- GroupRepositoryInterface $groupRepository,
- Session $customerSession,
- Data $taxHelper,
- Manager $moduleManager,
- Config $cacheConfig,
- TaxAddressManagerInterface $addressManager
+ private readonly GroupRepositoryInterface $groupRepository,
+ protected readonly Session $customerSession,
+ protected readonly Data $taxHelper,
+ private readonly Manager $moduleManager,
+ private readonly Config $cacheConfig,
+ private readonly TaxAddressManagerInterface $addressManager
) {
- $this->groupRepository = $groupRepository;
- $this->customerSession = $customerSession;
- $this->taxHelper = $taxHelper;
- $this->moduleManager = $moduleManager;
- $this->cacheConfig = $cacheConfig;
- $this->addressManager = $addressManager;
}
/**
@@ -93,7 +52,7 @@ public function execute(Observer $observer)
&& $this->cacheConfig->isEnabled()
&& $this->taxHelper->isCatalogPriceDisplayAffectedByTax()
) {
- /** @var \Magento\Customer\Model\Data\Customer $customer */
+ /** @var Customer $customer */
$customer = $observer->getData('customer');
$customerGroupId = $customer->getGroupId();
$customerGroup = $this->groupRepository->getById($customerGroupId);
diff --git a/app/code/Magento/Tax/Observer/GetPriceConfigurationObserver.php b/app/code/Magento/Tax/Observer/GetPriceConfigurationObserver.php
index bad9757dafd89..2ed3789317f43 100644
--- a/app/code/Magento/Tax/Observer/GetPriceConfigurationObserver.php
+++ b/app/code/Magento/Tax/Observer/GetPriceConfigurationObserver.php
@@ -5,58 +5,51 @@
*/
namespace Magento\Tax\Observer;
+use Exception;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Type;
use Magento\Catalog\Pricing\Price\BasePrice;
use Magento\Catalog\Pricing\Price\RegularPrice;
+use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
+use Magento\Framework\Pricing\Amount\Base as PricingAmountBase;
+use Magento\Framework\Registry;
+use Magento\Tax\Helper\Data as TaxHelper;
/**
* Modifies the bundle config for the front end to resemble the tax included price when tax included prices.
*/
class GetPriceConfigurationObserver implements ObserverInterface
{
- /**
- * Tax data
- *
- * @var \Magento\Tax\Helper\Data
- */
- protected $taxData;
-
- /**
- * @var \Magento\Framework\Registry
- */
- protected $registry;
-
/**
* @var array Cache of the current bundle selection items
*/
private $selectionCache = [];
/**
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Tax\Helper\Data $taxData
+ * @param Registry $registry
+ * @param TaxHelper $taxData
*/
public function __construct(
- \Magento\Framework\Registry $registry,
- \Magento\Tax\Helper\Data $taxData
+ protected readonly Registry $registry,
+ protected readonly TaxHelper $taxData
) {
- $this->registry = $registry;
- $this->taxData = $taxData;
}
/**
* Modify the bundle config for the front end to resemble the tax included price when tax included prices
*
- * @param \Magento\Framework\Event\Observer $observer
+ * @param Observer $observer
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
$this->selectionCache = [];
if ($this->taxData->displayPriceIncludingTax()) {
- /** @var \Magento\Catalog\Model\Product $product */
+ /** @var Product $product */
$product = $this->registry->registry('current_product');
- if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
+ if ($product->getTypeId() == Type::TYPE_BUNDLE) {
$priceConfigObj = $observer->getData('configObj');
try {
$priceConfig = $this->recurConfigAndUpdatePrice(
@@ -64,7 +57,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
'prices'
);
$priceConfigObj->setConfig($priceConfig);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
return $this;
}
}
@@ -112,9 +105,9 @@ private function updatePriceForBundle($holder, $key)
{
if (array_key_exists($key, $holder)
&& array_key_exists('basePrice', $holder[$key])) {
- /** @var \Magento\Catalog\Model\Product $product */
+ /** @var Product $product */
$product = $this->registry->registry('current_product');
- if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
+ if ($product->getTypeId() == Type::TYPE_BUNDLE) {
if (!isset($this->selectionCache[$product->getId()])) {
$typeInstance = $product->getTypeInstance();
$typeInstance->setStoreFilter($product->getStoreId(), $product);
@@ -129,9 +122,9 @@ private function updatePriceForBundle($holder, $key)
foreach ($arrSelections as $selectionItem) {
if ($holder['optionId'] == $selectionItem->getId()) {
- /** @var \Magento\Framework\Pricing\Amount\Base $baseAmount */
+ /** @var PricingAmountBase $baseAmount */
$baseAmount = $selectionItem->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getAmount();
- /** @var \Magento\Framework\Pricing\Amount\Base $oldAmount */
+ /** @var PricingAmountBase $oldAmount */
$oldAmount =
$selectionItem->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getAmount();
if ($baseAmount->hasAdjustment('tax')) {
diff --git a/app/code/Magento/Tax/Observer/UpdateProductOptionsObserver.php b/app/code/Magento/Tax/Observer/UpdateProductOptionsObserver.php
index 40ffd451fb6ea..9802301312a00 100644
--- a/app/code/Magento/Tax/Observer/UpdateProductOptionsObserver.php
+++ b/app/code/Magento/Tax/Observer/UpdateProductOptionsObserver.php
@@ -6,41 +6,30 @@
namespace Magento\Tax\Observer;
+use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
+use Magento\Framework\Registry;
+use Magento\Tax\Helper\Data as TaxHelper;
class UpdateProductOptionsObserver implements ObserverInterface
{
/**
- * Tax data
- *
- * @var \Magento\Tax\Helper\Data
- */
- protected $taxData;
-
- /**
- * @var \Magento\Framework\Registry
- */
- protected $registry;
-
- /**
- * @param \Magento\Tax\Helper\Data $taxData
- * @param \Magento\Framework\Registry $registry
+ * @param TaxHelper $taxData Tax data
+ * @param Registry $registry
*/
public function __construct(
- \Magento\Tax\Helper\Data $taxData,
- \Magento\Framework\Registry $registry
+ protected readonly TaxHelper $taxData,
+ protected readonly Registry $registry
) {
- $this->taxData = $taxData;
- $this->registry = $registry;
}
/**
* Change default JavaScript templates for options rendering
*
- * @param \Magento\Framework\Event\Observer $observer
+ * @param Observer $observer
* @return $this
*/
- public function execute(\Magento\Framework\Event\Observer $observer)
+ public function execute(Observer $observer)
{
$response = $observer->getEvent()->getResponseObject();
$options = $response->getAdditionalOptions();
diff --git a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php
index 3952d1534f7dc..04906d587523f 100644
--- a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php
+++ b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php
@@ -6,6 +6,13 @@
namespace Magento\Tax\Plugin\Checkout\CustomerData;
+use Magento\Checkout\CustomerData\Cart as CustomerDataCart;
+use Magento\Checkout\Helper\Data as CheckoutHelper;
+use Magento\Checkout\Model\Session;
+use Magento\Quote\Model\Quote;
+use Magento\Quote\Model\Quote\Item as QuoteItem;
+use Magento\Tax\Block\Item\Price\Renderer;
+
/**
* Process quote items price, considering tax configuration.
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
@@ -13,22 +20,7 @@
class Cart
{
/**
- * @var \Magento\Checkout\Model\Session
- */
- protected $checkoutSession;
-
- /**
- * @var \Magento\Checkout\Helper\Data
- */
- protected $checkoutHelper;
-
- /**
- * @var \Magento\Tax\Block\Item\Price\Renderer
- */
- protected $itemPriceRenderer;
-
- /**
- * @var \Magento\Quote\Model\Quote|null
+ * @var Quote|null
*/
protected $quote = null;
@@ -38,29 +30,26 @@ class Cart
protected $totals = null;
/**
- * @param \Magento\Checkout\Model\Session $checkoutSession
- * @param \Magento\Checkout\Helper\Data $checkoutHelper
- * @param \Magento\Tax\Block\Item\Price\Renderer $itemPriceRenderer
+ * @param Session $checkoutSession
+ * @param CheckoutHelper $checkoutHelper
+ * @param Renderer $itemPriceRenderer
*/
public function __construct(
- \Magento\Checkout\Model\Session $checkoutSession,
- \Magento\Checkout\Helper\Data $checkoutHelper,
- \Magento\Tax\Block\Item\Price\Renderer $itemPriceRenderer
+ protected readonly Session $checkoutSession,
+ protected readonly CheckoutHelper $checkoutHelper,
+ protected readonly Renderer $itemPriceRenderer
) {
- $this->checkoutSession = $checkoutSession;
- $this->checkoutHelper = $checkoutHelper;
- $this->itemPriceRenderer = $itemPriceRenderer;
}
/**
* Add tax data to result
*
- * @param \Magento\Checkout\CustomerData\Cart $subject
+ * @param CustomerDataCart $subject
* @param array $result
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result)
+ public function afterGetSectionData(CustomerDataCart $subject, $result)
{
$result['subtotal_incl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalInclTax());
$result['subtotal_excl_tax'] = $this->checkoutHelper->formatPrice($this->getSubtotalExclTax());
@@ -135,7 +124,7 @@ public function getTotals()
/**
* Get active quote
*
- * @return \Magento\Quote\Model\Quote
+ * @return Quote
*/
protected function getQuote()
{
@@ -150,13 +139,13 @@ protected function getQuote()
*
* @param int $id
* @param array $itemsHaystack
- * @return \Magento\Quote\Model\Quote\Item | bool
+ * @return QuoteItem | bool
*/
protected function findItemById($id, $itemsHaystack)
{
if (is_array($itemsHaystack)) {
foreach ($itemsHaystack as $item) {
- /** @var $item \Magento\Quote\Model\Quote\Item */
+ /** @var QuoteItem $item */
if ((int)$item->getItemId() == $id) {
return $item;
}
diff --git a/app/code/Magento/Tax/Plugin/Ui/DataProvider/TaxSettings.php b/app/code/Magento/Tax/Plugin/Ui/DataProvider/TaxSettings.php
index 3bd55bdbb8a25..bf030d53501ee 100644
--- a/app/code/Magento/Tax/Plugin/Ui/DataProvider/TaxSettings.php
+++ b/app/code/Magento/Tax/Plugin/Ui/DataProvider/TaxSettings.php
@@ -6,7 +6,10 @@
namespace Magento\Tax\Plugin\Ui\DataProvider;
+use Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider;
+use Magento\Checkout\CustomerData\Cart as CustomerDataCart;
use Magento\Framework\App\Config;
+use Magento\Tax\Model\Config as TaxConfig;
/**
* Plugin on Data Provider for frontend ui components (Components are responsible
@@ -15,32 +18,27 @@
*/
class TaxSettings
{
- /**
- * @var Config
- */
- private $config;
-
/**
* TaxSettings constructor.
* @param Config $config
*/
- public function __construct(Config $config)
- {
- $this->config = $config;
+ public function __construct(
+ private readonly Config $config
+ ) {
}
/**
* Add tax data to result
*
- * @param \Magento\Checkout\CustomerData\Cart $subject
+ * @param CustomerDataCart $subject
* @param array $result
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function afterGetData(\Magento\Catalog\Ui\DataProvider\Product\Listing\DataProvider $subject, $result)
+ public function afterGetData(DataProvider $subject, $result)
{
$result['displayTaxes'] = $this->config
- ->getValue(\Magento\Tax\Model\Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE);
+ ->getValue(TaxConfig::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE);
return $result;
}
diff --git a/app/code/Magento/Tax/Pricing/Adjustment.php b/app/code/Magento/Tax/Pricing/Adjustment.php
index e8cbabeeb2197..2f76fb278ef44 100644
--- a/app/code/Magento/Tax/Pricing/Adjustment.php
+++ b/app/code/Magento/Tax/Pricing/Adjustment.php
@@ -6,6 +6,7 @@
namespace Magento\Tax\Pricing;
+use Magento\Catalog\Helper\Data as CatalogHelper;
use Magento\Framework\Pricing\Adjustment\AdjustmentInterface;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Tax\Helper\Data as TaxHelper;
@@ -20,33 +21,16 @@ class Adjustment implements AdjustmentInterface
*/
const ADJUSTMENT_CODE = 'tax';
- /**
- * @var TaxHelper
- */
- protected $taxHelper;
-
- /**
- * \Magento\Catalog\Helper\Data
- *
- * @var CatalogHelper
- */
- protected $catalogHelper;
-
- /**
- * @var int|null
- */
- protected $sortOrder;
-
/**
* @param TaxHelper $taxHelper
- * @param \Magento\Catalog\Helper\Data $catalogHelper
+ * @param CatalogHelper $catalogHelper
* @param int|null $sortOrder
*/
- public function __construct(TaxHelper $taxHelper, \Magento\Catalog\Helper\Data $catalogHelper, $sortOrder = null)
- {
- $this->taxHelper = $taxHelper;
- $this->catalogHelper = $catalogHelper;
- $this->sortOrder = $sortOrder;
+ public function __construct(
+ protected readonly TaxHelper $taxHelper,
+ protected CatalogHelper $catalogHelper,
+ protected $sortOrder = null
+ ) {
}
/**
diff --git a/app/code/Magento/Tax/Pricing/Render/Adjustment.php b/app/code/Magento/Tax/Pricing/Render/Adjustment.php
index 27686169dcd5f..2817663465633 100644
--- a/app/code/Magento/Tax/Pricing/Render/Adjustment.php
+++ b/app/code/Magento/Tax/Pricing/Render/Adjustment.php
@@ -7,8 +7,11 @@
namespace Magento\Tax\Pricing\Render;
use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Framework\Pricing\Render;
use Magento\Framework\Pricing\Render\AbstractAdjustment;
use Magento\Framework\View\Element\Template;
+use Magento\Tax\Helper\Data as TaxHelper;
+use Magento\Tax\Pricing\Adjustment as PricingAdjustment;
/**
* @method string getIdSuffix()
@@ -17,20 +20,20 @@
class Adjustment extends AbstractAdjustment
{
/**
- * @var \Magento\Tax\Helper\Data
+ * @var TaxHelper
*/
protected $taxHelper;
/**
* @param Template\Context $context
* @param PriceCurrencyInterface $priceCurrency
- * @param \Magento\Tax\Helper\Data $helper
+ * @param TaxHelper $helper
* @param array $data
*/
public function __construct(
Template\Context $context,
PriceCurrencyInterface $priceCurrency,
- \Magento\Tax\Helper\Data $helper,
+ TaxHelper $helper,
array $data = []
) {
$this->taxHelper = $helper;
@@ -45,7 +48,7 @@ public function __construct(
protected function apply()
{
if ($this->displayBothPrices()) {
- if ($this->getZone() !== \Magento\Framework\Pricing\Render::ZONE_ITEM_OPTION) {
+ if ($this->getZone() !== Render::ZONE_ITEM_OPTION) {
$this->amountRender->setPriceDisplayLabel(__('Incl. Tax'));
}
$this->amountRender->setPriceWrapperCss('price-including-tax');
@@ -71,7 +74,7 @@ protected function apply()
*/
public function getAdjustmentCode()
{
- return \Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE;
+ return PricingAdjustment::ADJUSTMENT_CODE;
}
/**
diff --git a/app/code/Magento/Tax/Setup/Patch/Data/AddTaxAttributeAndTaxClasses.php b/app/code/Magento/Tax/Setup/Patch/Data/AddTaxAttributeAndTaxClasses.php
index 8b7b9df936009..9ed4583bd28b9 100644
--- a/app/code/Magento/Tax/Setup/Patch/Data/AddTaxAttributeAndTaxClasses.php
+++ b/app/code/Magento/Tax/Setup/Patch/Data/AddTaxAttributeAndTaxClasses.php
@@ -6,10 +6,16 @@
namespace Magento\Tax\Setup\Patch\Data;
+use Magento\Catalog\Model\Product;
+use Magento\Directory\Model\Region;
use Magento\Directory\Model\RegionFactory;
+use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
+use Magento\Tax\Model\ClassModel;
+use Magento\Tax\Model\TaxClass\Source\Product as TaxClassSourceProduct;
use Magento\Tax\Setup\TaxSetup;
use Magento\Tax\Setup\TaxSetupFactory;
@@ -19,35 +25,18 @@
*/
class AddTaxAttributeAndTaxClasses implements DataPatchInterface, PatchVersionInterface
{
- /**
- * @param TaxSetupFactory $taxSetupFactory
- */
- private $taxSetupFactory;
-
- /**
- * @param RegionFactory $directoryRegionFactory
- */
- private $directoryRegionFactory;
-
- /**
- * @var \Magento\Framework\Setup\ModuleDataSetupInterface
- */
- private $moduleDataSetup;
-
/**
* AddTacAttributeAndTaxClasses constructor.
+ *
* @param TaxSetupFactory $taxSetupFactory
* @param RegionFactory $directoryRegionFactory
- * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ * @param ModuleDataSetupInterface $moduleDataSetup
*/
public function __construct(
- TaxSetupFactory $taxSetupFactory,
- RegionFactory $directoryRegionFactory,
- \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ private readonly TaxSetupFactory $taxSetupFactory,
+ private readonly RegionFactory $directoryRegionFactory,
+ private readonly ModuleDataSetupInterface $moduleDataSetup
) {
- $this->taxSetupFactory = $taxSetupFactory;
- $this->directoryRegionFactory = $directoryRegionFactory;
- $this->moduleDataSetup = $moduleDataSetup;
}
/**
@@ -62,7 +51,7 @@ public function apply()
* Add tax_class_id attribute to the 'eav_attribute' table
*/
$taxSetup->addAttribute(
- \Magento\Catalog\Model\Product::ENTITY,
+ Product::ENTITY,
'tax_class_id',
[
'group' => 'Product Details',
@@ -73,8 +62,8 @@ public function apply()
'label' => 'Tax Class',
'input' => 'select',
'class' => '',
- 'source' => \Magento\Tax\Model\TaxClass\Source\Product::class,
- 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_WEBSITE,
+ 'source' => TaxClassSourceProduct::class,
+ 'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
'visible' => true,
'required' => false,
'user_defined' => false,
@@ -99,12 +88,12 @@ public function apply()
[
'class_id' => 2,
'class_name' => 'Taxable Goods',
- 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT,
+ 'class_type' => ClassModel::TAX_CLASS_TYPE_PRODUCT,
],
[
'class_id' => 3,
'class_name' => 'Retail Customer',
- 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER
+ 'class_type' => ClassModel::TAX_CLASS_TYPE_CUSTOMER
],
];
foreach ($data as $row) {
@@ -116,7 +105,7 @@ public function apply()
/**
* install tax calculation rates
*/
- /** @var \Magento\Directory\Model\Region $region */
+ /** @var Region $region */
$region = $this->directoryRegionFactory->create();
$data = [
[
diff --git a/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxClassAttributeVisibility.php b/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxClassAttributeVisibility.php
index 24d21d513ca23..5d250df58f873 100644
--- a/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxClassAttributeVisibility.php
+++ b/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxClassAttributeVisibility.php
@@ -6,7 +6,9 @@
namespace Magento\Tax\Setup\Patch\Data;
+use Magento\Catalog\Model\Product;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
use Magento\Tax\Setup\TaxSetup;
@@ -18,27 +20,15 @@
*/
class UpdateTaxClassAttributeVisibility implements DataPatchInterface, PatchVersionInterface
{
- /**
- * @var \Magento\Framework\Setup\ModuleDataSetupInterface
- */
- private $moduleDataSetup;
-
- /**
- * @var TaxSetupFactory
- */
- private $taxSetupFactory;
-
/**
* UpdateTaxClassAttributeVisibility constructor.
- * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ * @param ModuleDataSetupInterface $moduleDataSetup
* @param TaxSetupFactory $taxSetupFactory
*/
public function __construct(
- \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
- TaxSetupFactory $taxSetupFactory
+ private readonly ModuleDataSetupInterface $moduleDataSetup,
+ private readonly TaxSetupFactory $taxSetupFactory
) {
- $this->moduleDataSetup = $moduleDataSetup;
- $this->taxSetupFactory = $taxSetupFactory;
}
/**
@@ -53,7 +43,7 @@ public function apply()
//Update the tax_class_id attribute in the 'catalog_eav_attribute' table
$taxSetup->updateAttribute(
- \Magento\Catalog\Model\Product::ENTITY,
+ Product::ENTITY,
'tax_class_id',
'is_visible_in_advanced_search',
false
diff --git a/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxRegionId.php b/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxRegionId.php
index d2f5aac442609..23e0dadc76bab 100644
--- a/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxRegionId.php
+++ b/app/code/Magento/Tax/Setup/Patch/Data/UpdateTaxRegionId.php
@@ -6,8 +6,11 @@
namespace Magento\Tax\Setup\Patch\Data;
+use Magento\Directory\Model\Region;
use Magento\Directory\Model\RegionFactory;
use Magento\Framework\Api\Search\SearchCriteriaFactory;
+use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Tax\Api\Data\TaxRateInterface;
use Magento\Tax\Api\TaxRateRepositoryInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Patch\DataPatchInterface;
@@ -16,43 +19,19 @@
class UpdateTaxRegionId implements DataPatchInterface, PatchVersionInterface
{
- /**
- * @var \Magento\Framework\Setup\ModuleDataSetupInterface
- */
- private $moduleDataSetup;
-
- /**
- * @var TaxRateRepositoryInterface
- */
- private $taxRateRepository;
-
- /**
- * @var SearchCriteriaFactory
- */
- private $searchCriteriaFactory;
-
- /**
- * @var RegionFactory
- */
- private $regionFactory;
-
/**
* UpdateTaxRegionId constructor.
- * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
+ * @param ModuleDataSetupInterface $moduleDataSetup
* @param TaxRateRepositoryInterface $taxRateRepository
* @param SearchCriteriaFactory $searchCriteriaFactory
* @param RegionFactory $regionFactory
*/
public function __construct(
- \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
- TaxRateRepositoryInterface $taxRateRepository,
- SearchCriteriaFactory $searchCriteriaFactory,
- \Magento\Directory\Model\RegionFactory $regionFactory
+ private readonly ModuleDataSetupInterface $moduleDataSetup,
+ private readonly TaxRateRepositoryInterface $taxRateRepository,
+ private readonly SearchCriteriaFactory $searchCriteriaFactory,
+ private readonly RegionFactory $regionFactory
) {
- $this->moduleDataSetup = $moduleDataSetup;
- $this->taxRateRepository = $taxRateRepository;
- $this->searchCriteriaFactory = $searchCriteriaFactory;
- $this->regionFactory = $regionFactory;
}
/**
@@ -64,11 +43,11 @@ public function apply()
//Update the tax_region_id
$taxRateList = $this->taxRateRepository->getList($this->searchCriteriaFactory->create());
- /** @var \Magento\Tax\Api\Data\TaxRateInterface $taxRateData */
+ /** @var TaxRateInterface $taxRateData */
foreach ($taxRateList->getItems() as $taxRateData) {
$regionCode = $this->parseRegionFromTaxCode($taxRateData->getCode());
if ($regionCode) {
- /** @var \Magento\Directory\Model\Region $region */
+ /** @var Region $region */
$region = $this->regionFactory->create();
$region->loadByCode($regionCode, $taxRateData->getTaxCountryId());
if ($taxRateData->getTaxPostcode() === null) {
diff --git a/app/code/Magento/Tax/Setup/TaxSetup.php b/app/code/Magento/Tax/Setup/TaxSetup.php
index 60959626ed755..92562a27b5ae0 100644
--- a/app/code/Magento/Tax/Setup/TaxSetup.php
+++ b/app/code/Magento/Tax/Setup/TaxSetup.php
@@ -7,6 +7,7 @@
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Sales\Setup\SalesSetup;
use Magento\Sales\Setup\SalesSetupFactory;
/**
@@ -15,31 +16,23 @@
class TaxSetup
{
/**
- * @var \Magento\Sales\Setup\SalesSetup
+ * @var SalesSetup
*/
protected $salesSetup;
- /**
- * Product type config
- *
- * @var ConfigInterface
- */
- protected $productTypeConfig;
-
/**
* Init
*
* @param ModuleDataSetupInterface $setup
* @param SalesSetupFactory $salesSetupFactory
- * @param ConfigInterface $productTypeConfig
+ * @param ConfigInterface $productTypeConfig Product type config
*/
public function __construct(
ModuleDataSetupInterface $setup,
SalesSetupFactory $salesSetupFactory,
- ConfigInterface $productTypeConfig
+ protected readonly ConfigInterface $productTypeConfig
) {
$this->salesSetup = $salesSetupFactory->create(['resourceName' => 'tax_setup', 'setup' => $setup]);
- $this->productTypeConfig = $productTypeConfig;
}
/**
diff --git a/app/code/Magento/Tax/Ui/DataProvider/Product/Listing/Collector/Tax.php b/app/code/Magento/Tax/Ui/DataProvider/Product/Listing/Collector/Tax.php
index d84ffa27c6878..7f8865800169e 100644
--- a/app/code/Magento/Tax/Ui/DataProvider/Product/Listing/Collector/Tax.php
+++ b/app/code/Magento/Tax/Ui/DataProvider/Product/Listing/Collector/Tax.php
@@ -7,6 +7,7 @@
namespace Magento\Tax\Ui\DataProvider\Product\Listing\Collector;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\Data\ProductRender\PriceInfoExtensionInterfaceFactory;
use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterfaceFactory;
use Magento\Catalog\Api\Data\ProductRenderInterface;
use Magento\Catalog\Model\ProductRender\FormattedPriceInfoBuilder;
@@ -32,42 +33,18 @@ class Tax implements ProductRenderCollectorInterface
/** adjustment regular price key */
const KEY_ADJUSTMENT_REGULAR_PRICE = "regular_price";
- /**
- * @var PriceCurrencyInterface
- */
- private $priceCurrency;
-
- /**
- * @var \Magento\Catalog\Api\Data\ProductRender\PriceInfoExtensionInterface
- */
- private $priceInfoExtensionFactory;
-
- /**
- * @var PriceInfoInterfaceFactory
- */
- private $priceInfoFactory;
-
- /**
- * @var FormattedPriceInfoBuilder
- */
- private $formattedPriceInfoBuilder;
-
/**
* @param PriceCurrencyInterface $priceCurrency
- * @param \Magento\Catalog\Api\Data\ProductRender\PriceInfoExtensionInterfaceFactory $priceInfoExtensionFactory
+ * @param PriceInfoExtensionInterfaceFactory $priceInfoExtensionFactory
* @param PriceInfoInterfaceFactory $priceInfoFactory
* @param FormattedPriceInfoBuilder $formattedPriceInfoBuilder
*/
public function __construct(
- PriceCurrencyInterface $priceCurrency,
- \Magento\Catalog\Api\Data\ProductRender\PriceInfoExtensionInterfaceFactory $priceInfoExtensionFactory,
- PriceInfoInterfaceFactory $priceInfoFactory,
- FormattedPriceInfoBuilder $formattedPriceInfoBuilder
+ private readonly PriceCurrencyInterface $priceCurrency,
+ private readonly PriceInfoExtensionInterfaceFactory $priceInfoExtensionFactory,
+ private readonly PriceInfoInterfaceFactory $priceInfoFactory,
+ private readonly FormattedPriceInfoBuilder $formattedPriceInfoBuilder
) {
- $this->priceCurrency = $priceCurrency;
- $this->priceInfoExtensionFactory = $priceInfoExtensionFactory;
- $this->priceInfoFactory = $priceInfoFactory;
- $this->formattedPriceInfoBuilder = $formattedPriceInfoBuilder;
}
/**