From e5ce0e90f3ee27a8cc36026898a72a0ca9b3f4f0 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Mon, 18 Jan 2021 14:22:12 +0100 Subject: [PATCH 01/10] Add missing phpdocs --- app/code/Magento/Customer/Model/Customer.php | 8 ++++---- .../Magento/Framework/Stdlib/DateTime/DateTime.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index f90b67216254d..606aec2d63ed4 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -660,7 +660,7 @@ public function decryptPassword($password) * Retrieve default address by type(attribute) * * @param string $attributeCode address type attribute code - * @return Address|false + * @return Address|bool */ public function getPrimaryAddress($attributeCode) { @@ -672,7 +672,7 @@ public function getPrimaryAddress($attributeCode) /** * Get customer default billing address * - * @return Address + * @return Address|bool */ public function getPrimaryBillingAddress() { @@ -682,7 +682,7 @@ public function getPrimaryBillingAddress() /** * Get customer default billing address * - * @return Address + * @return Address|bool */ public function getDefaultBillingAddress() { @@ -692,7 +692,7 @@ public function getDefaultBillingAddress() /** * Get default customer shipping address * - * @return Address + * @return Address|bool */ public function getPrimaryShippingAddress() { diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/DateTime.php b/lib/internal/Magento/Framework/Stdlib/DateTime/DateTime.php index 99f3a76b46d7d..0037e156a97e7 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/DateTime.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/DateTime.php @@ -54,7 +54,7 @@ public function calculateOffset($timezone = null) * Forms GMT date * * @param string $format - * @param int|string $input date in current timezone + * @param int|string|\DateTimeInterface|null $input date in current timezone * @return string */ public function gmtDate($format = null, $input = null) @@ -74,7 +74,7 @@ public function gmtDate($format = null, $input = null) * Converts input date into date with timezone offset. Input date must be in GMT timezone. * * @param string $format - * @param int|string $input date in GMT timezone + * @param int|string|\DateTimeInterface|null $input date in GMT timezone * @return string */ public function date($format = null, $input = null) @@ -89,7 +89,7 @@ public function date($format = null, $input = null) /** * Forms GMT timestamp * - * @param int|string|\DateTimeInterface $input date in current timezone + * @param int|string|\DateTimeInterface|null $input date in current timezone * @return int */ public function gmtTimestamp($input = null) @@ -116,7 +116,7 @@ public function gmtTimestamp($input = null) /** * Converts input date into timestamp with timezone offset. Input date must be in GMT timezone. * - * @param int|string $input date in GMT timezone + * @param int|string|\DateTimeInterface|null $input date in GMT timezone * @return int */ public function timestamp($input = null) From a10e2e6c6c14a99c1e045821238f6551b6cd627c Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Wed, 2 Jun 2021 12:22:40 +0200 Subject: [PATCH 02/10] Improve phpdocs --- app/code/Magento/Customer/Model/Customer.php | 14 +++++++------- app/code/Magento/Store/Model/Store.php | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 606aec2d63ed4..4e8c30abfde5a 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -660,7 +660,7 @@ public function decryptPassword($password) * Retrieve default address by type(attribute) * * @param string $attributeCode address type attribute code - * @return Address|bool + * @return Address|false */ public function getPrimaryAddress($attributeCode) { @@ -672,7 +672,7 @@ public function getPrimaryAddress($attributeCode) /** * Get customer default billing address * - * @return Address|bool + * @return Address|false */ public function getPrimaryBillingAddress() { @@ -682,7 +682,7 @@ public function getPrimaryBillingAddress() /** * Get customer default billing address * - * @return Address|bool + * @return Address|false */ public function getDefaultBillingAddress() { @@ -692,7 +692,7 @@ public function getDefaultBillingAddress() /** * Get default customer shipping address * - * @return Address|bool + * @return Address|false */ public function getPrimaryShippingAddress() { @@ -702,7 +702,7 @@ public function getPrimaryShippingAddress() /** * Get default customer shipping address * - * @return Address + * @return Address|false */ public function getDefaultShippingAddress() { @@ -773,7 +773,7 @@ public function getAdditionalAddresses() * Check if address is primary * * @param Address $address - * @return boolean + * @return bool */ public function isAddressPrimary(Address $address) { @@ -1284,7 +1284,7 @@ public function changeResetPasswordLinkToken($passwordLinkToken) /** * Check if current reset password link token is expired * - * @return boolean + * @return bool */ public function isResetPasswordLinkTokenExpired() { diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index 7bcb3282ba552..032d407464a3f 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -579,7 +579,7 @@ public function setWebsite(Website $website) /** * Retrieve store website * - * @return Website|bool + * @return Website|false * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getWebsite() @@ -744,7 +744,7 @@ protected function _isCustomEntryPoint() * * @param Filesystem $filesystem * @param bool $secure - * @return string|bool + * @return string|false */ protected function _getMediaScriptUrl(Filesystem $filesystem, $secure) { @@ -815,7 +815,7 @@ public function isUrlSecure() /** * Check if request was secure * - * @return boolean + * @return bool */ public function isCurrentlySecure() { @@ -1049,7 +1049,7 @@ public function setGroup(Group $group) /** * Retrieve group model * - * @return Group|bool + * @return Group|false * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getGroup() @@ -1163,7 +1163,7 @@ public function getDefaultGroupId() /** * Check if store can be deleted * - * @return boolean + * @return bool * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function isCanDelete() From 94f7b9e28a60902adfe100a1025b220d8ee67bed Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Wed, 2 Jun 2021 13:36:29 +0200 Subject: [PATCH 03/10] Add phpdocs --- .../Magento/Eav/Model/Entity/Collection/AbstractCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index b29d45f75c993..80c370de77c8b 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -1679,7 +1679,7 @@ public function getMainTable() /** * Wrapper for compatibility with \Magento\Framework\Data\Collection\AbstractDb * - * @param string $field + * @param array|string|integer|\Magento\Framework\App\Config\Element $field * @param string $alias * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @return $this|\Magento\Framework\Data\Collection\AbstractDb From 8de4a0f72b5bc4591c4e17711d8bf965cfb33472 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Fri, 8 Oct 2021 10:14:23 +0200 Subject: [PATCH 04/10] Fix phdoc for Quote\Item::getOptionByCode --- app/code/Magento/Quote/Model/Quote/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/Quote/Item.php b/app/code/Magento/Quote/Model/Quote/Item.php index 22554380ca61e..a256e4392bda3 100644 --- a/app/code/Magento/Quote/Model/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Item.php @@ -709,7 +709,7 @@ protected function _addOptionCode($option) * Get item option by code * * @param string $code - * @return \Magento\Quote\Model\Quote\Item\Option || null + * @return \Magento\Quote\Model\Quote\Item\Option|null */ public function getOptionByCode($code) { From d47861c8af66cb2b27809b794bd679090ec2cbef Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Fri, 8 Oct 2021 10:31:24 +0200 Subject: [PATCH 05/10] Fix phpdocs in Magento\Quote\Model\Quote --- app/code/Magento/Quote/Model/Quote.php | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index 48cd4b2eb2fad..304416c131077 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -15,6 +15,7 @@ use Magento\Quote\Api\Data\PaymentInterface; use Magento\Quote\Model\Quote\Address; use Magento\Quote\Model\Quote\Address\Total as AddressTotal; +use Magento\Quote\Model\Quote\Item; use Magento\Sales\Model\Status; use Magento\Store\Model\ScopeInterface; use Magento\Framework\App\ObjectManager; @@ -1422,13 +1423,13 @@ public function getItemsCollection($useCache = true) /** * Retrieve quote items array * - * @return array + * @return Item[] */ public function getAllItems() { $items = []; foreach ($this->getItemsCollection() as $item) { - /** @var \Magento\Quote\Model\Quote\Item $item */ + /** @var Item $item */ if (!$item->isDeleted()) { $items[] = $item; } @@ -1439,7 +1440,7 @@ public function getAllItems() /** * Get array of all items what can be display directly * - * @return \Magento\Quote\Model\Quote\Item[] + * @return Item[] */ public function getAllVisibleItems() { @@ -1502,7 +1503,7 @@ public function hasProductId($productId) * Retrieve item model object by item identifier * * @param int $itemId - * @return \Magento\Quote\Model\Quote\Item|false + * @return Item|false */ public function getItemById($itemId) { @@ -1518,10 +1519,10 @@ public function getItemById($itemId) /** * Delete quote item. If it does not have identifier then it will be only removed from collection * - * @param \Magento\Quote\Model\Quote\Item $item + * @param Item $item * @return $this */ - public function deleteItem(\Magento\Quote\Model\Quote\Item $item) + public function deleteItem(Item $item) { if ($item->getId()) { $this->removeItem($item->getId()); @@ -1599,11 +1600,11 @@ public function removeAllItems() /** * Adding new item to quote * - * @param \Magento\Quote\Model\Quote\Item $item + * @param Item $item * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ - public function addItem(\Magento\Quote\Model\Quote\Item $item) + public function addItem(Item $item) { $item->setQuote($this); if (!$item->getId()) { @@ -1619,7 +1620,7 @@ public function addItem(\Magento\Quote\Model\Quote\Item $item) * @param mixed $product * @param null|float|\Magento\Framework\DataObject $request * @param null|string $processMode - * @return \Magento\Quote\Model\Quote\Item|string + * @return Item|string * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -1720,7 +1721,7 @@ public function addProduct( * * @param \Magento\Catalog\Model\Product $product * @param int $qty - * @return \Magento\Quote\Model\Quote\Item + * @return Item * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _addCatalogProduct(\Magento\Catalog\Model\Product $product, $qty = 1) @@ -1772,7 +1773,7 @@ protected function _addCatalogProduct(\Magento\Catalog\Model\Product $product, $ * @param int $itemId * @param \Magento\Framework\DataObject $buyRequest * @param null|array|\Magento\Framework\DataObject $params - * @return \Magento\Quote\Model\Quote\Item + * @return Item * @throws \Magento\Framework\Exception\LocalizedException * * @see \Magento\Catalog\Helper\Product::addParamsToBuyRequest() @@ -1839,7 +1840,7 @@ public function updateItem($itemId, $buyRequest, $params = null) * Retrieve quote item by product id * * @param \Magento\Catalog\Model\Product $product - * @return \Magento\Quote\Model\Quote\Item|bool + * @return Item|false */ public function getItemByProduct($product) { @@ -2316,7 +2317,7 @@ public function validateMinimumAmount($multishipping = false) ? $address->getBaseTaxAmount() + $address->getBaseDiscountTaxCompensationAmount() : 0; foreach ($address->getQuote()->getItemsCollection() as $item) { - /** @var \Magento\Quote\Model\Quote\Item $item */ + /** @var Item $item */ $amount = $includeDiscount ? $item->getBaseRowTotal() - $item->getBaseDiscountAmount() + $taxes : $item->getBaseRowTotal() + $taxes; @@ -2353,7 +2354,7 @@ public function isVirtual() $isVirtual = true; $countItems = 0; foreach ($this->getItemsCollection() as $_item) { - /* @var $_item \Magento\Quote\Model\Quote\Item */ + /* @var Item $_item */ if ($_item->isDeleted() || $_item->getParentItemId()) { continue; } From 3c7ffceb079b4df59a70e80537f00fd1cdbac85d Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Thu, 14 Oct 2021 08:32:58 +0200 Subject: [PATCH 06/10] Remove false return type from AbstractDb::getConnection --- .../Magento/Framework/Model/ResourceModel/Db/AbstractDb.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php index 33427a219f9c1..df3126c504b96 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php @@ -306,7 +306,7 @@ public function getTable($tableName) * Get connection by resource name * * @param string $resourceName - * @return \Magento\Framework\DB\Adapter\AdapterInterface|false + * @return \Magento\Framework\DB\Adapter\AdapterInterface */ protected function _getConnection($resourceName) { @@ -325,7 +325,7 @@ protected function _getConnection($resourceName) /** * Get connection * - * @return \Magento\Framework\DB\Adapter\AdapterInterface|false + * @return \Magento\Framework\DB\Adapter\AdapterInterface */ public function getConnection() { From 572a6555326ac301afc435309650c1f6d21f6801 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Thu, 18 Nov 2021 09:07:49 +0100 Subject: [PATCH 07/10] Remove bool return type from SerializerInterface::serialize --- .../Magento/Framework/Serialize/SerializerInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Serialize/SerializerInterface.php b/lib/internal/Magento/Framework/Serialize/SerializerInterface.php index 24ace0c38b84e..01ca0b37d1727 100644 --- a/lib/internal/Magento/Framework/Serialize/SerializerInterface.php +++ b/lib/internal/Magento/Framework/Serialize/SerializerInterface.php @@ -17,7 +17,7 @@ interface SerializerInterface * Serialize data into string * * @param string|int|float|bool|array|null $data - * @return string|bool + * @return string * @throws \InvalidArgumentException * @since 101.0.0 */ From c0d235830067c047de0d203fa8ea20796b58c2bd Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Thu, 18 Nov 2021 16:55:46 +0100 Subject: [PATCH 08/10] Fix incorrect bool return types --- lib/internal/Magento/Framework/Data/Structure.php | 8 ++++---- lib/internal/Magento/Framework/View/Layout.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Structure.php b/lib/internal/Magento/Framework/Data/Structure.php index b22395f1ba835..34d0db043a1c0 100644 --- a/lib/internal/Magento/Framework/Data/Structure.php +++ b/lib/internal/Magento/Framework/Data/Structure.php @@ -168,7 +168,7 @@ public function createElement($elementId, array $data) * Get existing element * * @param string $elementId - * @return array|bool + * @return array|false */ public function getElement($elementId) { @@ -446,7 +446,7 @@ private function _getRelativeOffset($parentId, $siblingId, $delta) * * @param string $parentId * @param string $alias - * @return string|bool + * @return string|false */ public function getChildId($parentId, $alias) { @@ -473,7 +473,7 @@ public function getChildren($parentId) * Get name of parent element * * @param string $childId - * @return string|bool + * @return string|false */ public function getParentId($childId) { @@ -485,7 +485,7 @@ public function getParentId($childId) * * @param string $parentId * @param string $childId - * @return string|bool + * @return string|false */ public function getChildAlias($parentId, $childId) { diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php index eeba7485e0469..23b2ea98a5f04 100644 --- a/lib/internal/Magento/Framework/View/Layout.php +++ b/lib/internal/Magento/Framework/View/Layout.php @@ -389,7 +389,7 @@ protected function addToOutputRootContainers() * * @param string $parentName * @param string $alias - * @return bool|\Magento\Framework\View\Element\AbstractBlock + * @return \Magento\Framework\View\Element\AbstractBlock|false */ public function getChildBlock($parentName, $alias) { @@ -487,7 +487,7 @@ public function getChildBlocks($parentName) * * @param string $parentName * @param string $alias - * @return bool|string + * @return string|false */ public function getChildName($parentName, $alias) { @@ -889,7 +889,7 @@ public function getAllBlocks() * Get block object by name * * @param string $name - * @return \Magento\Framework\View\Element\AbstractBlock|bool + * @return \Magento\Framework\View\Element\AbstractBlock|false */ public function getBlock($name) { @@ -905,7 +905,7 @@ public function getBlock($name) * Get Ui Component object by name * * @param string $name - * @return \Magento\Framework\View\Element\AbstractBlock|bool + * @return \Magento\Framework\View\Element\AbstractBlock|false */ public function getUiComponent($name) { @@ -916,7 +916,7 @@ public function getUiComponent($name) * Gets parent name of an element with specified name * * @param string $childName - * @return bool|string + * @return string|false */ public function getParentName($childName) { @@ -928,7 +928,7 @@ public function getParentName($childName) * Get element alias by name * * @param string $name - * @return bool|string + * @return string|false */ public function getElementAlias($name) { From 4a75694e4dd9c438771fc76de74953de44faa689 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Thu, 18 Nov 2021 17:06:26 +0100 Subject: [PATCH 09/10] Fix Quote\Item::getParenItem nullability --- app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php index 058411abe720b..053eb2f774eb9 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php @@ -202,7 +202,7 @@ public function setParentItem($parentItem) /** * Get parent item * - * @return Item + * @return Item|null */ public function getParentItem() { From 1c3dbd2feefbe7b722b76d92eb37dbf2a7938355 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Fri, 19 Nov 2021 10:14:30 +0100 Subject: [PATCH 10/10] Fix incorrect bool types in AbstractBlock --- .../Magento/Framework/View/Element/AbstractBlock.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index ea47c22d8f602..48044c5b18de2 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -263,7 +263,7 @@ protected function _construct() /** * Retrieve parent block * - * @return \Magento\Framework\View\Element\AbstractBlock|bool + * @return \Magento\Framework\View\Element\AbstractBlock|false */ public function getParentBlock() { @@ -489,7 +489,7 @@ public function unsetChildren() * Retrieve child block by name * * @param string $alias - * @return \Magento\Framework\View\Element\AbstractBlock|bool + * @return \Magento\Framework\View\Element\AbstractBlock|false */ public function getChildBlock($alias) { @@ -587,7 +587,7 @@ public function getBlockHtml($name) * @param string|int|null $siblingName * @param bool $after * @param string $alias - * @return $this|bool + * @return $this|false */ public function insert($element, $siblingName = 0, $after = true, $alias = '') { @@ -1082,7 +1082,7 @@ protected function getCacheTags() /** * Get block cache life time * - * @return int|bool|null + * @return int|null */ protected function getCacheLifetime() {