Skip to content

Commit

Permalink
PhpStan fixes (OpenMage#4146)
Browse files Browse the repository at this point in the history
* Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)

* Rector: CQ - UnusedForeachValueToArrayKeysRector

See Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector

* fixes + phpstan

See fix at rector: rectorphp/rector-src#6164

* Fixes some phpstan errors

* Revert "Rector: CQ - UnusedForeachValueToArrayKeysRector (#1)"

This reverts commit 3d7eaf6.

* Update app/code/core/Mage/Tag/Model/Tag.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Updated docblock

- have to keep array from parent method

---------

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
  • Loading branch information
sreichel and kiatng committed Sep 2, 2024
1 parent 35f331b commit 99c778a
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 144 deletions.
2 changes: 1 addition & 1 deletion app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Mage_Cms_Model_Wysiwyg_Images_Storage extends Varien_Object
/**
* Config object
*
* @var Mage_Core_Model_Config_Element|Varien_Simplexml_Element|false
* @var Mage_Core_Model_Config_Element
*/
protected $_config;

Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,9 @@ protected function _getUrlModelClass()
*/
protected function _getUrlModel()
{
return Mage::getModel($this->_getUrlModelClass());
/** @var Mage_Core_Model_Url $model */
$model = Mage::getModel($this->_getUrlModelClass());
return $model;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ protected function _getLastSubkey($key, $withBrackets = true)
/**
* Set array helper
*
* @param Mage_Core_Helper_Abstract|Mage_Core_Helper_Array $helper
* @param Mage_Core_Helper_Array $helper
* @return $this
*/
public function setArrayHelper(Mage_Core_Helper_Abstract $helper)
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Core/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ protected function _getSectionConfig($path)
* Get node value from cached section data
*
* @param array $path
* @return false|Varien_Simplexml_Element
* @return false|Mage_Core_Model_Config_Element
*/
public function getSectionNode($path)
{
Expand All @@ -741,7 +741,7 @@ public function getSectionNode($path)
* Returns node found by the $path and scope info
*
* @inheritDoc
* @return Mage_Core_Model_Config_Element|Varien_Simplexml_Element|false
* @return Mage_Core_Model_Config_Element
*/
public function getNode($path = null, $scope = '', $scopeCode = null)
{
Expand Down Expand Up @@ -1150,7 +1150,7 @@ public function substDistroServerVars($data)
* Get module config node
*
* @param string $moduleName
* @return Mage_Core_Model_Config_Element|SimpleXMLElement
* @return Mage_Core_Model_Config_Element
*/
public function getModuleConfig($moduleName = '')
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,9 @@ public function roundPrice($price)
/**
* Format price with currency filter (taking rate into consideration)
*
* @param double $price
* @param float $price
* @param bool $includeContainer
* @return string
* @return string|float
*/
public function formatPrice($price, $includeContainer = true)
{
Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function mageFindClassFile($class)
* @param string $errstr
* @param string $errfile
* @param int $errline
* @return bool|void
* @return bool|null
*/
function mageCoreErrorHandler($errno, $errstr, $errfile, $errline)
{
Expand Down Expand Up @@ -184,14 +184,15 @@ function mageCoreErrorHandler($errno, $errstr, $errfile, $errline)
throw new Exception($errorMessage);
} else {
Mage::log($errorMessage, Zend_Log::ERR);
return null;
}
}

/**
* @param bool $return
* @param bool $html
* @param bool $showFirst
* @return string|void
* @return string|null
*
* @SuppressWarnings(PHPMD.ErrorControlOperator)
*/
Expand All @@ -216,6 +217,7 @@ function mageDebugBacktrace($return = false, $html = true, $showFirst = false)
return $out;
} else {
echo $out;
return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Tag/Block/Customer/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function _loadTags()
$this->_tags = [];

$tags = Mage::getResourceModel('tag/tag_collection')
->addPopularity(null, Mage::app()->getStore()->getId())
->addPopularity()
->setOrder('popularity', 'DESC')
->addCustomerFilter(Mage::getSingleton('customer/session')->getCustomerId())
->setActiveFilter()
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Tag/Block/Product/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function _getCollection()
protected function _beforeToHtml()
{
if (!$this->getProductId()) {
return false;
return $this;
}

return parent::_beforeToHtml();
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Tag/Block/Product/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class Mage_Tag_Block_Product_Result extends Mage_Catalog_Block_Product_Abstract
{
/**
* @var Mage_Tag_Model_Resource_Tag_Collection|null
* @var Mage_Tag_Model_Resource_Product_Collection|null
*/
protected $_productCollection;

Expand Down Expand Up @@ -81,7 +81,7 @@ public function getProductListHtml()
}

/**
* @return Mage_Tag_Model_Resource_Tag_Collection
* @return Mage_Tag_Model_Resource_Product_Collection
* @throws Mage_Core_Model_Store_Exception
*/
protected function _getProductCollection()
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Tag/Model/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function info($tagId, $store)
*/
public function add($data)
{
$result = [];
$data = $this->_prepareDataForAdd($data);
/** @var Mage_Catalog_Model_Product $product */
$product = Mage::getModel('catalog/product')->load($data['product_id']);
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Tag/Model/Api/V2.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function add($data)
*
* @param int $tagId
* @param string|int $store
* @return object
* @return object|array
*/
public function info($tagId, $store)
{
Expand All @@ -74,7 +74,7 @@ public function info($tagId, $store)
/**
* Convert data from object to array before add
*
* @param object $data
* @param array|object $data
* @return array
*/
protected function _prepareDataForAdd($data)
Expand All @@ -86,7 +86,7 @@ protected function _prepareDataForAdd($data)
/**
* Convert data from object to array before update
*
* @param object $data
* @param array|object $data
* @return array
*/
protected function _prepareDataForUpdate($data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
class Mage_Tag_Model_Entity_Customer_Collection extends Mage_Customer_Model_Entity_Customer_Collection
{
protected $_tagTable;

protected $_tagRelTable;

public function __construct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public function getSelectCountSql()
public function addProductName()
{
$productsId = [];
$productsSku = [];
$productsData = [];

foreach ($this->getItems() as $item) {
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Tag/Model/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ public function saveRelation($productId, $customerId, $storeId)
->setActive(Mage_Tag_Model_Tag_Relation::STATUS_ACTIVE)
->setCreatedAt($relationModel->getResource()->formatDate(time()));

$result = '';
$relationModelSaveNeed = false;
switch ($this->getStatus()) {
case $this->getApprovedStatus():
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Simplexml/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function addChild($name, $value=null, $namespace=null)
* @todo Do we need to make it xpath look-a-like?
* @todo Check if we still need all this and revert to plain XPath if this makes any sense
* @todo param string $path Subset of xpath. Example: "child/grand[@attrName='attrValue']/subGrand"
* @param string $path Example: "child/grand@attrName=attrValue/subGrand" (to make it faster without regex)
* @param array|string $path Example: "child/grand@attrName=attrValue/subGrand" (to make it faster without regex)
* @return Varien_Simplexml_Element|false
*/
public function descend($path)
Expand Down
Loading

0 comments on commit 99c778a

Please sign in to comment.