From 066a483bdc24761be70f2f12be942b38c5f51896 Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Tue, 16 Feb 2021 14:25:30 +0200 Subject: [PATCH] marked as api --- .../Adminhtml/Product/Edit/Button/Generic.php | 4 + app/code/Magento/Checkout/Controller/Cart.php | 51 ++++++++----- .../Magento/Customer/Setup/CustomerSetup.php | 74 ++++++++++++------- .../Quote/Item/CartItemOptionsProcessor.php | 16 +++- .../Sales/Controller/Adminhtml/Order.php | 61 ++++++++------- .../Model/Order/Pdf/Total/DefaultTotal.php | 33 ++++++--- .../Framework/Data/Form/Element/Image.php | 18 +++-- 7 files changed, 163 insertions(+), 94 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Button/Generic.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Button/Generic.php index 089e4d6e5cb97..d8f2be06fd40f 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Button/Generic.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Button/Generic.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Button; use Magento\Catalog\Api\Data\ProductInterface; @@ -12,6 +14,8 @@ /** * Class Generic + * + * @api */ class Generic implements ButtonProviderInterface { diff --git a/app/code/Magento/Checkout/Controller/Cart.php b/app/code/Magento/Checkout/Controller/Cart.php index 0c65fa9a51f48..e5acc1d32d389 100644 --- a/app/code/Magento/Checkout/Controller/Cart.php +++ b/app/code/Magento/Checkout/Controller/Cart.php @@ -3,56 +3,69 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Checkout\Controller; use Magento\Catalog\Controller\Product\View\ViewInterface; use Magento\Checkout\Model\Cart as CustomerCart; +use Magento\Checkout\Model\Session; +use Magento\Framework\App\Action\Context; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\Data\Form\FormKey\Validator; +use Magento\Framework\UrlInterface; +use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; /** * Shopping cart controller + * + * @api */ abstract class Cart extends \Magento\Framework\App\Action\Action implements ViewInterface { /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ protected $_scopeConfig; /** - * @var \Magento\Checkout\Model\Session + * @var Session */ protected $_checkoutSession; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Framework\Data\Form\FormKey\Validator + * @var Validator */ protected $_formKeyValidator; /** - * @var \Magento\Checkout\Model\Cart + * @var CustomerCart */ protected $cart; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator + * @param Context $context + * @param ScopeConfigInterface $scopeConfig + * @param Session $checkoutSession + * @param StoreManagerInterface $storeManager + * @param Validator $formKeyValidator * @param CustomerCart $cart * @codeCoverageIgnore */ public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator, + Context $context, + ScopeConfigInterface $scopeConfig, + Session $checkoutSession, + StoreManagerInterface $storeManager, + Validator $formKeyValidator, CustomerCart $cart ) { $this->_formKeyValidator = $formKeyValidator; @@ -68,7 +81,7 @@ public function __construct( * * @param null|string $backUrl * - * @return \Magento\Framework\Controller\Result\Redirect + * @return Redirect */ protected function _goBack($backUrl = null) { @@ -96,10 +109,10 @@ protected function _isInternalUrl($url) /** * Url must start from base secure or base unsecure url */ - /** @var $store \Magento\Store\Model\Store */ + /** @var $store Store */ $store = $this->_storeManager->getStore(); $unsecure = strpos($url, (string) $store->getBaseUrl()) === 0; - $secure = strpos($url, (string) $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK, true)) === 0; + $secure = strpos($url, (string) $store->getBaseUrl(UrlInterface::URL_TYPE_LINK, true)) === 0; return $unsecure || $secure; } @@ -136,7 +149,7 @@ private function shouldRedirectToCart() { return $this->_scopeConfig->isSetFlag( 'checkout/cart/redirect_to_cart', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ScopeInterface::SCOPE_STORE ); } } diff --git a/app/code/Magento/Customer/Setup/CustomerSetup.php b/app/code/Magento/Customer/Setup/CustomerSetup.php index c074285765e59..f4ebf86cb4521 100644 --- a/app/code/Magento/Customer/Setup/CustomerSetup.php +++ b/app/code/Magento/Customer/Setup/CustomerSetup.php @@ -1,20 +1,43 @@ [ - 'entity_type_id' => \Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, - 'entity_model' => \Magento\Customer\Model\ResourceModel\Customer::class, - 'attribute_model' => \Magento\Customer\Model\Attribute::class, + 'entity_type_id' => CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER, + 'entity_model' => Customer::class, + 'attribute_model' => Attribute::class, 'table' => 'customer_entity', - 'increment_model' => \Magento\Eav\Model\Entity\Increment\NumericValue::class, + 'increment_model' => NumericValue::class, 'additional_attribute_table' => 'customer_eav_attribute', 'entity_attribute_collection' => \Magento\Customer\Model\ResourceModel\Attribute\Collection::class, 'attributes' => [ @@ -140,7 +163,7 @@ public function getDefaultEntities() 'label' => 'Associate to Website', 'input' => 'select', 'source' => \Magento\Customer\Model\Customer\Attribute\Source\Website::class, - 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Website::class, + 'backend' => Website::class, 'sort_order' => 10, 'position' => 10, 'adminhtml_only' => 1, @@ -150,7 +173,7 @@ public function getDefaultEntities() 'label' => 'Create In', 'input' => 'select', 'source' => \Magento\Customer\Model\Customer\Attribute\Source\Store::class, - 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Store::class, + 'backend' => Store::class, 'sort_order' => 20, 'visible' => false, 'adminhtml_only' => 1, @@ -223,7 +246,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Group', 'input' => 'select', - 'source' => \Magento\Customer\Model\Customer\Attribute\Source\Group::class, + 'source' => Group::class, 'sort_order' => 25, 'position' => 25, 'adminhtml_only' => 1, @@ -234,7 +257,7 @@ public function getDefaultEntities() 'label' => 'Date of Birth', 'input' => 'date', 'frontend' => \Magento\Eav\Model\Entity\Attribute\Frontend\Datetime::class, - 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\Datetime::class, + 'backend' => Datetime::class, 'required' => false, 'sort_order' => 90, 'visible' => false, @@ -247,7 +270,7 @@ public function getDefaultEntities() 'password_hash' => [ 'type' => 'static', 'input' => 'hidden', - 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Password::class, + 'backend' => Password::class, 'required' => false, 'sort_order' => 81, 'visible' => false, @@ -271,7 +294,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Default Billing Address', 'input' => 'text', - 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Billing::class, + 'backend' => Billing::class, 'required' => false, 'sort_order' => 82, 'visible' => false, @@ -280,7 +303,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Default Shipping Address', 'input' => 'text', - 'backend' => \Magento\Customer\Model\Customer\Attribute\Backend\Shipping::class, + 'backend' => Shipping::class, 'required' => false, 'sort_order' => 83, 'visible' => false, @@ -318,7 +341,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Gender', 'input' => 'select', - 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Table::class, + 'source' => Table::class, 'required' => false, 'sort_order' => 110, 'visible' => false, @@ -332,7 +355,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Disable Automatic Group Change Based on VAT ID', 'input' => 'boolean', - 'backend' => \Magento\Customer\Model\Attribute\Backend\Data\Boolean::class, + 'backend' => Boolean::class, 'position' => 28, 'required' => false, 'adminhtml_only' => true @@ -340,13 +363,12 @@ public function getDefaultEntities() ], ], 'customer_address' => [ - 'entity_type_id' => \Magento\Customer\Api\AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS, - 'entity_model' => \Magento\Customer\Model\ResourceModel\Address::class, - 'attribute_model' => \Magento\Customer\Model\Attribute::class, + 'entity_type_id' => AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS, + 'entity_model' => Address::class, + 'attribute_model' => Attribute::class, 'table' => 'customer_address_entity', 'additional_attribute_table' => 'customer_eav_attribute', - 'entity_attribute_collection' => - \Magento\Customer\Model\ResourceModel\Address\Attribute\Collection::class, + 'entity_attribute_collection' => Collection::class, 'attributes' => [ 'prefix' => [ 'type' => 'static', @@ -407,7 +429,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Street Address', 'input' => 'multiline', - 'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\DefaultBackend::class, + 'backend' => DefaultBackend::class, 'sort_order' => 70, 'multiline_count' => 2, 'validate_rules' => '{"max_text_length":255,"min_text_length":1}', @@ -425,7 +447,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'Country', 'input' => 'select', - 'source' => \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::class, + 'source' => Country::class, 'sort_order' => 90, 'position' => 90, ], @@ -433,7 +455,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'State/Province', 'input' => 'text', - 'backend' => \Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region::class, + 'backend' => Region::class, 'required' => false, 'sort_order' => 100, 'position' => 100, @@ -442,7 +464,7 @@ public function getDefaultEntities() 'type' => 'static', 'label' => 'State/Province', 'input' => 'hidden', - 'source' => \Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::class, + 'source' => Address\Attribute\Source\Region::class, 'required' => false, 'sort_order' => 100, 'position' => 100, @@ -453,7 +475,7 @@ public function getDefaultEntities() 'input' => 'text', 'sort_order' => 110, 'validate_rules' => '[]', - 'data' => \Magento\Customer\Model\Attribute\Data\Postcode::class, + 'data' => Postcode::class, 'position' => 110, 'required' => false, ], diff --git a/app/code/Magento/Quote/Model/Quote/Item/CartItemOptionsProcessor.php b/app/code/Magento/Quote/Model/Quote/Item/CartItemOptionsProcessor.php index bf9a49bac909c..092c490ea4469 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/CartItemOptionsProcessor.php +++ b/app/code/Magento/Quote/Model/Quote/Item/CartItemOptionsProcessor.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Quote\Model\Quote\Item; +use Magento\Framework\DataObject; use Magento\Quote\Api\Data\CartItemInterface; +/** + * Cart item options processor + * + * @api + */ class CartItemOptionsProcessor { /** @@ -25,7 +33,7 @@ public function __construct(CartItemProcessorsPool $cartItemProcessorsPool) /** * @param string $productType * @param CartItemInterface $cartItem - * @return \Magento\Framework\DataObject|float + * @return DataObject|float */ public function getBuyRequest($productType, CartItemInterface $cartItem) { @@ -41,8 +49,8 @@ public function getBuyRequest($productType, CartItemInterface $cartItem) * Add custom options to buy request. * * @param CartItemInterface $cartItem - * @param \Magento\Framework\DataObject|float $params - * @return \Magento\Framework\DataObject|float + * @param DataObject|float $params + * @return DataObject|float */ private function addCustomOptionsToBuyRequest(CartItemInterface $cartItem, $params) { @@ -51,7 +59,7 @@ private function addCustomOptionsToBuyRequest(CartItemInterface $cartItem, $para if (!$buyRequestUpdate) { return $params; } - if ($params instanceof \Magento\Framework\DataObject) { + if ($params instanceof DataObject) { $buyRequestUpdate->addData($params->getData()); } elseif (is_numeric($params)) { $buyRequestUpdate->setData('qty', $params); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php index 0066c5f4c828a..9412289306298 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php @@ -3,9 +3,20 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Controller\Adminhtml; use Magento\Backend\App\Action; +use Magento\Backend\Model\View\Result\Page; +use Magento\Framework\App\Response\Http\FileFactory; +use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\Result\RawFactory; +use Magento\Framework\Registry; +use Magento\Framework\Translate\InlineInterface; +use Magento\Framework\View\Result\LayoutFactory; +use Magento\Framework\View\Result\PageFactory; +use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderManagementInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Magento\Framework\Exception\NoSuchEntityException; @@ -15,11 +26,11 @@ /** * Adminhtml sales orders controller * - * @author Magento Core Team + * @api * @SuppressWarnings(PHPMD.NumberOfChildren) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -abstract class Order extends \Magento\Backend\App\Action +abstract class Order extends Action { /** * Authorization level of a basic admin session @@ -38,37 +49,37 @@ abstract class Order extends \Magento\Backend\App\Action /** * Core registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $_coreRegistry = null; /** - * @var \Magento\Framework\App\Response\Http\FileFactory + * @var FileFactory */ protected $_fileFactory; /** - * @var \Magento\Framework\Translate\InlineInterface + * @var InlineInterface */ protected $_translateInline; /** - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; /** - * @var \Magento\Framework\Controller\Result\JsonFactory + * @var JsonFactory */ protected $resultJsonFactory; /** - * @var \Magento\Framework\View\Result\LayoutFactory + * @var LayoutFactory */ protected $resultLayoutFactory; /** - * @var \Magento\Framework\Controller\Result\RawFactory + * @var RawFactory */ protected $resultRawFactory; @@ -89,13 +100,13 @@ abstract class Order extends \Magento\Backend\App\Action /** * @param Action\Context $context - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory - * @param \Magento\Framework\Translate\InlineInterface $translateInline - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory - * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory - * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory + * @param Registry $coreRegistry + * @param FileFactory $fileFactory + * @param InlineInterface $translateInline + * @param PageFactory $resultPageFactory + * @param JsonFactory $resultJsonFactory + * @param LayoutFactory $resultLayoutFactory + * @param RawFactory $resultRawFactory * @param OrderManagementInterface $orderManagement * @param OrderRepositoryInterface $orderRepository * @param LoggerInterface $logger @@ -105,13 +116,13 @@ abstract class Order extends \Magento\Backend\App\Action */ public function __construct( Action\Context $context, - \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\App\Response\Http\FileFactory $fileFactory, - \Magento\Framework\Translate\InlineInterface $translateInline, - \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, - \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, - \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, + Registry $coreRegistry, + FileFactory $fileFactory, + InlineInterface $translateInline, + PageFactory $resultPageFactory, + JsonFactory $resultJsonFactory, + LayoutFactory $resultLayoutFactory, + RawFactory $resultRawFactory, OrderManagementInterface $orderManagement, OrderRepositoryInterface $orderRepository, LoggerInterface $logger @@ -132,7 +143,7 @@ public function __construct( /** * Init layout, menu and breadcrumb * - * @return \Magento\Backend\Model\View\Result\Page + * @return Page */ protected function _initAction() { @@ -146,7 +157,7 @@ protected function _initAction() /** * Initialize order model instance * - * @return \Magento\Sales\Api\Data\OrderInterface|false + * @return OrderInterface|false */ protected function _initOrder() { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php b/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php index b71f0fd0ec7df..23ae36ea4f3e3 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Total/DefaultTotal.php @@ -3,43 +3,52 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Sales\Model\Order\Pdf\Total; +use Magento\Framework\DataObject; +use Magento\Sales\Model\Order; +use Magento\Tax\Helper\Data; +use Magento\Tax\Model\Calculation; +use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\Collection; +use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory; + /** * Sales Order Total PDF model * - * @method \Magento\Sales\Model\Order getOrder() + * @api + * @method Order getOrder() */ -class DefaultTotal extends \Magento\Framework\DataObject +class DefaultTotal extends DataObject { /** - * @var \Magento\Tax\Helper\Data + * @var Data */ protected $_taxHelper; /** - * @var \Magento\Tax\Model\Calculation + * @var Calculation */ protected $_taxCalculation; /** - * @var \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory + * @var CollectionFactory */ protected $_taxOrdersFactory; /** * Initialize dependencies * - * @param \Magento\Tax\Helper\Data $taxHelper - * @param \Magento\Tax\Model\Calculation $taxCalculation - * @param \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory + * @param Data $taxHelper + * @param Calculation $taxCalculation + * @param CollectionFactory $ordersFactory * @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, + Data $taxHelper, + Calculation $taxCalculation, + CollectionFactory $ordersFactory, array $data = [] ) { $this->_taxHelper = $taxHelper; @@ -104,7 +113,7 @@ public function getFullTaxInfo() $tax['font_size'] = $fontSize; } } else { - /** @var $orders \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\Collection */ + /** @var $orders Collection */ $orders = $this->_taxOrdersFactory->create(); $rates = $orders->loadByOrder($this->getOrder())->toArray(); $fullInfo = $this->_taxCalculation->reproduceProcess($rates['items']); diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Image.php b/lib/internal/Magento/Framework/Data/Form/Element/Image.php index 5a0cab45d44d6..4197415f5dc79 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Image.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Image.php @@ -3,20 +3,22 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); -/** - * Category form input image element - * - * @author Magento Core Team - */ namespace Magento\Framework\Data\Form\Element; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Escaper; use Magento\Framework\Math\Random; use Magento\Framework\UrlInterface; use Magento\Framework\View\Helper\SecureHtmlRenderer; -class Image extends \Magento\Framework\Data\Form\Element\AbstractElement +/** + * Category form input image element + * + * @api + */ +class Image extends AbstractElement { /** * @var UrlInterface @@ -36,7 +38,7 @@ class Image extends \Magento\Framework\Data\Form\Element\AbstractElement /** * @param Factory $factoryElement * @param CollectionFactory $factoryCollection - * @param \Magento\Framework\Escaper $escaper + * @param Escaper $escaper * @param UrlInterface $urlBuilder * @param array $data * @param SecureHtmlRenderer|null $secureRenderer @@ -45,7 +47,7 @@ class Image extends \Magento\Framework\Data\Form\Element\AbstractElement public function __construct( Factory $factoryElement, CollectionFactory $factoryCollection, - \Magento\Framework\Escaper $escaper, + Escaper $escaper, UrlInterface $urlBuilder, $data = [], ?SecureHtmlRenderer $secureRenderer = null,