From c337f1048257e784a8c8d02031d8ca2744633aa6 Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Tue, 31 Dec 2024 14:12:46 +0100 Subject: [PATCH 1/2] Don't use void return value from method calls. Fixes errors phpstan found while scanning on level 0. --- .../Magento/Downloadable/Model/Product/TypeHandler/Link.php | 3 ++- .../Eav/Model/ResourceModel/Entity/Attribute/Group.php | 4 ++-- app/code/Magento/Store/Block/Store/Switcher.php | 3 ++- lib/internal/Magento/Framework/HTTP/Client/Socket.php | 6 ++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php index 6d567605f8b85..4dfa9c875b6b7 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php @@ -81,7 +81,8 @@ public function save(Product $product, array $data) protected function clear() { $this->sampleItem = []; - return parent::clear(); + + parent::clear(); } /** diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php index 0b9c42d887041..bdbefb0f474e0 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php @@ -161,7 +161,7 @@ public function updateDefaultGroup($attributeSetId) protected function saveNewObject(AbstractModel $object) { try { - return parent::saveNewObject($object); + parent::saveNewObject($object); } catch (DuplicateException $e) { throw new AttributeGroupAlreadyExistsException( __( @@ -178,7 +178,7 @@ protected function saveNewObject(AbstractModel $object) protected function updateObject(AbstractModel $object) { try { - return parent::updateObject($object); + parent::updateObject($object); } catch (DuplicateException $e) { throw new AttributeGroupAlreadyExistsException( __( diff --git a/app/code/Magento/Store/Block/Store/Switcher.php b/app/code/Magento/Store/Block/Store/Switcher.php index 3406933b90bf5..4399d0d1a5172 100644 --- a/app/code/Magento/Store/Block/Store/Switcher.php +++ b/app/code/Magento/Store/Block/Store/Switcher.php @@ -67,7 +67,8 @@ protected function _construct() $this->_loadData(); $this->setStores([]); $this->setLanguages([]); - return parent::_construct(); + + parent::_construct(); } /** diff --git a/lib/internal/Magento/Framework/HTTP/Client/Socket.php b/lib/internal/Magento/Framework/HTTP/Client/Socket.php index f0261e397ea88..8a4c833fb9fc2 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Socket.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Socket.php @@ -419,8 +419,7 @@ protected function processResponse() $line = explode(" ", $responseLine, 3); if (count($line) != 3) { - // phpstan:ignore "Result of method Magento\Framework\HTTP\Client\Socket::doError() (void) is used." - return $this->doError("Invalid response line returned from server: " . $responseLine); + $this->doError("Invalid response line returned from server: " . $responseLine); } $this->_responseStatus = (int)$line[1]; $this->processResponseHeaders(); @@ -466,8 +465,7 @@ protected function makeRequest($method, $uri, $params = []) $errno = $errstr = ''; $this->_sock = @fsockopen($this->_host, $this->_port, $errno, $errstr, $this->_timeout); if (!$this->_sock) { - // phpstan:ignore "Result of method Magento\Framework\HTTP\Client\Socket::doError() (void) is used." - return $this->doError(sprintf("[errno: %d] %s", $errno, $errstr)); + $this->doError(sprintf("[errno: %d] %s", $errno, $errstr)); } $crlf = "\r\n"; From 7774d4a2e60cbd1b057f10761c8ee8fb0492325a Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Tue, 31 Dec 2024 14:28:43 +0100 Subject: [PATCH 2/2] Fixed static tests. --- .../Model/Product/TypeHandler/Link.php | 37 ++++++++----------- .../ResourceModel/Entity/Attribute/Group.php | 8 ++-- .../Magento/Store/Block/Store/Switcher.php | 20 ++++++---- .../Magento/Framework/HTTP/Client/Socket.php | 4 +- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php index 4dfa9c875b6b7..9eb4dd184adb8 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php @@ -1,7 +1,7 @@ getLinksPurchasedSeparately()) { $product->setIsCustomOptionChanged(); } + + return $this; } /** - * {@inheritdoc} + * @inheritdoc */ protected function clear() { @@ -86,7 +88,7 @@ protected function clear() } /** - * @return ComponentInterface + * @inheritdoc */ protected function createItem() { @@ -94,10 +96,7 @@ protected function createItem() } /** - * @param ComponentInterface $model - * @param array $data - * @param Product $product - * @return void + * @inheritdoc */ protected function setDataToModel(ComponentInterface $model, array $data, Product $product) { @@ -125,9 +124,7 @@ protected function setDataToModel(ComponentInterface $model, array $data, Produc } /** - * @param ComponentInterface $model - * @param Product $product - * @return void + * @inheritdoc */ protected function linkToProduct(ComponentInterface $model, Product $product) { @@ -135,7 +132,7 @@ protected function linkToProduct(ComponentInterface $model, Product $product) } /** - * @return void + * @inheritdoc */ protected function processDelete() { @@ -145,7 +142,7 @@ protected function processDelete() } /** - * {@inheritdoc} + * @inheritdoc */ protected function saveItem(Product $product, array $item) { @@ -157,9 +154,7 @@ protected function saveItem(Product $product, array $item) } /** - * @param ComponentInterface $model - * @param array $files - * @return void + * @inheritdoc */ protected function setFiles(ComponentInterface $model, array $files) { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php index bdbefb0f474e0..ee065e58344c6 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group.php @@ -1,7 +1,7 @@