Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhpStan: some fixes #4363

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
597 changes: 1 addition & 596 deletions .phpstan.dist.baseline.neon

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public function getValidateButton()
$optionsVarName = $this->getJsVariablePrefix() . 'VatParameters';
$beforeHtml = '<script type="text/javascript">var ' . $optionsVarName . ' = ' . $vatValidateOptions
. ';</script>';
$this->_validateButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData([

/** @var Mage_Adminhtml_Block_Widget_Button $block */
$block = $this->getLayout()->createBlock('adminhtml/widget_button');
$this->_validateButton = $block->setData([
'label' => Mage::helper('customer')->__('Validate VAT Number'),
'before_html' => $beforeHtml,
'onclick' => 'order.validateVat(' . $optionsVarName . ')'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function getAddressId()
/**
* Return address object
*
* @return Mage_Customer_Model_Address
* @return Mage_Sales_Model_Quote_Address
*/
public function getAddress()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected function _getExtraJs($element, $tooltipsExist = false)
* Collapsed or expanded fieldset when page loaded?
*
* @param Varien_Data_Form_Element_Abstract $element
* @return int|bool
* @return int|false
*/
protected function _getCollapseState($element)
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
/**
* Collection object
*
* @var Mage_Core_Model_Resource_Db_Collection_Abstract|Varien_Data_Collection_Db|null
* @var Varien_Data_Collection_Db|null
*/
protected $_collection = null;

Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Authorizenet/Model/Directpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function authorize(Varien_Object $payment, $amount)
/**
* Send capture request to gateway
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return $this
* @throws Mage_Core_Exception
Expand Down Expand Up @@ -220,6 +221,7 @@ public function refund(Varien_Object $payment, $amount)
/**
* refund the amount with transaction id
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param string $amount
* @return $this
* @throws Mage_Core_Exception
Expand Down Expand Up @@ -323,7 +325,7 @@ public function initialize($paymentAction, $stateObject)
switch ($paymentAction) {
case self::ACTION_AUTHORIZE:
case self::ACTION_AUTHORIZE_CAPTURE:
/** @var Mage_Authorizenet_Model_Directpost $payment */
/** @var Mage_Sales_Model_Order_Payment|Mage_Sales_Model_Quote_Payment $payment */
$payment = $this->getInfoInstance();
$order = $payment->getOrder();
$order->setCanSendNewEmailFlag(false);
Expand Down Expand Up @@ -638,7 +640,7 @@ protected function _captureOrder(Mage_Sales_Model_Order $order)
/**
* Return additional information`s transaction_id value of parent transaction model
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param Mage_Sales_Model_Order_Payment|Varien_Object $payment
* @return string
*/
protected function _getRealParentTransactionId($payment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function setDataFromOrder(Mage_Sales_Model_Order $order, Mage_Authorizene
*/
public function signRequestData()
{
$fpTimestamp = time();
$fpTimestamp = (string) time();
$signatureKey = $this->_getSignatureKey();
if (!empty($signatureKey)) {
$hash = $this->_generateSha2RequestSign(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function getOrderItem()
/**
* Retrieve Value HTML
*
* @param Mage_Sales_Model_Order_Item $item
* @param Mage_Sales_Model_Order_Invoice_Item $item
* @return string
*/
public function getValueHtml($item)
Expand All @@ -253,13 +253,13 @@ public function getValueHtml($item)
/**
* Can show price info for item
*
* @param Mage_Sales_Model_Order_Item $item
* @param Mage_Sales_Model_Order_Invoice_Item $item
* @return bool
*/
public function canShowPriceInfo($item)
{
if (($item->getOrderItem()->getParentItem() && $this->isChildCalculated())
|| (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated())
|| (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated())
) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Block/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mage_Catalog_Block_Navigation extends Mage_Core_Block_Template
/**
* Current category key
*
* @var string
* @var int|string
*/
protected $_currentCategoryKey;

Expand Down Expand Up @@ -93,7 +93,7 @@ public function getCacheKeyInfo()
/**
* Get current category key
*
* @return mixed
* @return int|string
*/
public function getCurrenCategoryKey()
{
Expand Down
6 changes: 4 additions & 2 deletions app/code/core/Mage/Catalog/Block/Product/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function getAddToCompareUrl($product)
* Gets minimal sales quantity
*
* @param Mage_Catalog_Model_Product $product
* @return int|null
* @return float|null
*/
public function getMinimalQty($product)
{
Expand Down Expand Up @@ -316,7 +316,9 @@ protected function _initReviewsHelperBlock()
return false;
}

$this->_reviewsHelperBlock = $this->getLayout()->createBlock('review/helper');
/** @var Mage_Review_Block_Helper $block */
$block = $this->getLayout()->createBlock('review/helper');
$this->_reviewsHelperBlock = $block;
}

return true;
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Mage_Catalog_Block_Product_List_Toolbar extends Mage_Core_Block_Template
/**
* List of available view types
*
* @var string
* @var array
*/
protected $_availableMode = [];

Expand Down Expand Up @@ -535,7 +535,7 @@ public function isModeActive($mode)
/**
* Retrieve availables view modes
*
* @return string
* @return array
*/
public function getModes()
{
Expand All @@ -550,7 +550,7 @@ public function getModes()
*/
public function setModes($modes)
{
if (!isset($this->_availableMode)) {
if (!$this->_availableMode) {
$this->_availableMode = $modes;
}
return $this;
Expand Down Expand Up @@ -649,7 +649,7 @@ public function getDefaultPerPageValue()
}
return Mage::getStoreConfig('catalog/frontend/grid_per_page');
}
return 0;
return '0';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Block/Product/New.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Mage_Catalog_Block_Product_New extends Mage_Catalog_Block_Product_Abstract
/**
* Products count
*
* @var null
* @var int
*/
protected $_productsCount;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function getTotalNum()
public function getLastPageNum()
{
if ($this->_lastPage === null) {
$this->_lastPage = ceil($this->getCollectionSize() / $this->getLimit());
$this->_lastPage = (int) ceil($this->getCollectionSize() / $this->getLimit());
if ($this->_lastPage <= 0) {
$this->_lastPage = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Block/Seo/Sitemap/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ protected function _prepareLayout()
*/
public function getItemUrl($product)
{
$helper = Mage::helper('catalog/product');
/** @var Mage_Catalog_Helper_Product $helper */
$helper = Mage::helper('catalog/product');
return $helper->getProductUrl($product);
}
}
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Mage_Catalog_Helper_Data extends Mage_Core_Helper_Abstract
/**
* Breadcrumb Path cache
*
* @var string|array<string, array<string, string|null>>
* @var array<string, array<string, string|null>>
*/
protected $_categoryPath;

Expand Down Expand Up @@ -78,7 +78,7 @@ public function setStoreId($store)
* Return current category path or get it from current category
* and creating array of categories|product paths for breadcrumbs
*
* @return string
* @return array
*/
public function getBreadcrumbPath()
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Helper/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public function getSkipSaleableCheck()
* Gets minimal sales quantity
*
* @param Mage_Catalog_Model_Product $product
* @return int|null
* @return float|null
*/
public function getMinimalQty($product)
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Api2/Product/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ protected function _getTierPrices()
/**
* Default implementation. May be different for customer/guest/admin role.
*
* @return null
* @return int|null
*/
protected function _getCustomerGroupId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ protected function _filterStockData(&$stockData)
* Filter out fields if Use Config Settings option used
*
* @param array $data
* @param string $fields
* @param array $fields
*/
protected function _filterConfigValueUsed(&$data, $fields)
{
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Catalog/Model/Category/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ protected function _getRequestPath(Mage_Catalog_Model_Category $category)
public function getUrlInstance()
{
if ($this->_url === null) {
$this->_url = $this->_factory->getModel('core/url');
/** @var Mage_Core_Model_Url $model */
$model = $this->_factory->getModel('core/url');
$this->_url = $model;
}
return $this->_url;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function _apply($package, $theme)
* Apply custom design
*
* @param string $design
* @return null|false
* @return void|false
*/
public function applyCustomDesign($design)
{
Expand Down
16 changes: 12 additions & 4 deletions app/code/core/Mage/Catalog/Model/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ class Mage_Catalog_Model_Factory extends Mage_Core_Model_Factory
*/
public function getCategoryUrlRewriteHelper()
{
return $this->getHelper(
/** @var Mage_Catalog_Helper_Category_Url_Rewrite_Interface $model */
$model = $this->getHelper(
(string)$this->_config->getNode(self::XML_PATH_CATEGORY_URL_REWRITE_HELPER_CLASS)
);
return $model;
}

/**
Expand All @@ -58,9 +60,11 @@ public function getCategoryUrlRewriteHelper()
*/
public function getProductUrlRewriteHelper()
{
return $this->getHelper(
/** @var Mage_Catalog_Helper_Product_Url_Rewrite_Interface $model */
$model = $this->getHelper(
(string)$this->_config->getNode(self::XML_PATH_PRODUCT_URL_REWRITE_HELPER_CLASS)
);
return $model;
}

/**
Expand All @@ -70,9 +74,11 @@ public function getProductUrlRewriteHelper()
*/
public function getProductUrlInstance()
{
return $this->getModel(
/** @var Mage_Catalog_Model_Product_Url $model */
$model = $this->getModel(
(string)$this->_config->getNode(self::XML_PATH_PRODUCT_URL_MODEL)
);
return $model;
}

/**
Expand All @@ -82,8 +88,10 @@ public function getProductUrlInstance()
*/
public function getCategoryUrlInstance()
{
return $this->getModel(
/** @var Mage_Catalog_Model_Category_Url $model */
$model = $this->getModel(
(string)$this->_config->getNode(self::XML_PATH_CATEGORY_URL_MODEL)
);
return $model;
}
}
6 changes: 3 additions & 3 deletions app/code/core/Mage/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1884,8 +1884,8 @@ public function addOption(Mage_Catalog_Model_Product_Option $option)
/**
* Get option from options array of product by given option id
*
* @param int $optionId
* @return Mage_Catalog_Model_Product_Option | null
* @param string $optionId
* @return Mage_Catalog_Model_Product_Option|null
*/
public function getOptionById($optionId)
{
Expand Down Expand Up @@ -1983,7 +1983,7 @@ public function hasCustomOptions()
* Check availability display product in category
*
* @param int $categoryId
* @return bool
* @return string
*/
public function canBeShowInCategory($categoryId)
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Model/Product/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function delete($productId, $identifierType = null)
/**
* Get list of additional attributes which are not in default create/update list
*
* @param int $productType
* @param string $productType
* @param int $attributeSetId
* @return array
*/
Expand Down Expand Up @@ -428,7 +428,7 @@ public function getAdditionalAttributes($productType, $attributeSetId)
/**
* Check if product type exists
*
* @param int $productType
* @param string $productType
* @throw Mage_Api_Exception
*/
protected function _checkProductTypeExists($productType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function _calcSelectionPrice($priceInfo, $productPrice)
/**
* @param array $values
* @param string $index
* @return bool
* @return array|false
*/
protected function _getValueByIndex($values, $index)
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Resource/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function deleteEntity(Mage_Core_Model_Abstract $object)
* Defines is Attribute used by super products
*
* @param int $attributeSet
* @return int
* @return false|string|null
*/
public function isUsedBySuperProducts(Mage_Core_Model_Abstract $object, $attributeSet = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @package Mage_Catalog
*
* @method Mage_Catalog_Model_Category getFirstItem()
* @method Mage_Catalog_Model_Category getItemById(int $value)
* @method Mage_Catalog_Model_Category getItemById(string $value)
* @method Mage_Catalog_Model_Category[] getItems()
*/
class Mage_Catalog_Model_Resource_Category_Collection extends Mage_Catalog_Model_Resource_Collection_Abstract
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Model/Resource/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public function refreshIndex($product)
* if product parameter is null - idex will be refreshed for all products
*
* @param Mage_Core_Model_Store $store
* @param Mage_Catalog_Model_Product $product
* @param Mage_Catalog_Model_Product|array $product
* @throws Mage_Core_Exception
* @return $this
*/
Expand Down
Loading