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 fixes #2396

Merged
merged 6 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fixed getAddUrl...()
  • Loading branch information
sreichel committed Aug 10, 2022
commit e6a64ba8c66856434f65c8ac8174a606c5ad0ef9
45 changes: 0 additions & 45 deletions .github/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2140,36 +2140,11 @@ parameters:
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrl\\(\\)\\.$#"
count: 3
path: ../app/code/core/Mage/Catalog/Block/Product/Abstract.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrlCustom\\(\\)\\.$#"
count: 2
path: ../app/code/core/Mage/Catalog/Block/Product/Abstract.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrlWithCustomParams\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/Abstract.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getCurrentPageLayout\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/Abstract.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrlWithCustomParams\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/Compare/List.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrlWithParams\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/Compare/List.php

-
message: "#^Method Mage_Catalog_Model_Resource_Product_Compare_Item_Collection\\:\\:useProductItem\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
Expand Down Expand Up @@ -2200,26 +2175,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrl\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/Price.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrlCustom\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/Price.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrl\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/View.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getAddUrlCustom\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Catalog/Block/Product/View.php

-
message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:init\\(\\)\\.$#"
count: 1
Expand Down
22 changes: 16 additions & 6 deletions app/code/core/Mage/Catalog/Block/Product/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,13 @@ public function displayProductStockStatus()
*/
public function getAddToWishlistUrlCustom($product, $addFormKey = true)
{
/** @var Mage_Wishlist_Helper_Data $helper */
$helper = $this->helper('wishlist');

if (!$addFormKey) {
return $this->helper('wishlist')->getAddUrlWithCustomParams($product, array(), false);
return $helper->getAddUrlWithCustomParams($product, array(), false);
}
return $this->helper('wishlist')->getAddUrl($product);
return $helper->getAddUrl($product);
}

/**
Expand All @@ -647,10 +650,13 @@ public function getAddToWishlistUrlCustom($product, $addFormKey = true)
*/
public function getAddToCompareUrlCustom($product, $addFormKey = true)
{
/** @var Mage_Catalog_Helper_Product_Compare $helper */
$helper = $this->helper('catalog/product_compare');

if (!$addFormKey) {
return $this->helper('catalog/product_compare')->getAddUrlCustom($product, false);
return $helper->getAddUrlCustom($product, false);
}
return $this->helper('catalog/product_compare')->getAddUrl($product);
return $helper->getAddUrl($product);
}

/**
Expand Down Expand Up @@ -684,12 +690,16 @@ protected function _prepareLayout()
*/
public function getAddToCartUrlCustom($product, $additional = array(), $addFormKey = true)
{
/** @var Mage_Checkout_Helper_Cart $helper */
$helper = $this->helper('checkout/cart');

if (!$product->getTypeInstance(true)->hasRequiredOptions($product)) {
if (!$addFormKey) {
return $this->helper('checkout/cart')->getAddUrlCustom($product, $additional, false);
return $helper->getAddUrlCustom($product, $additional, false);
}
return $this->helper('checkout/cart')->getAddUrl($product, $additional);
return $helper->getAddUrl($product, $additional);
}

if ($addFormKey) {
$additional = array_merge(
$additional,
Expand Down
7 changes: 5 additions & 2 deletions app/code/core/Mage/Catalog/Block/Product/Compare/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,14 @@ public function getAddToWishlistUrlCustom($product, $addFormKey = true)
Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $continueUrl
);

/** @var Mage_Wishlist_Helper_Data $helper */
$helper = $this->helper('wishlist');

if (!$addFormKey) {
return $this->helper('wishlist')->getAddUrlWithCustomParams($product, $params, false);
return $helper->getAddUrlWithCustomParams($product, $params, false);
}

return $this->helper('wishlist')->getAddUrlWithParams($product, $params);
return $helper->getAddUrlWithParams($product, $params);
}

}
7 changes: 5 additions & 2 deletions app/code/core/Mage/Catalog/Block/Product/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,12 @@ public function getProductAttribute($attribute)
*/
public function getAddToCartUrlCustom($product, $additional = array(), $addFormKey = true)
{
/** @var Mage_Checkout_Helper_Cart $helper */
$helper = $this->helper('checkout/cart');

if (!$addFormKey) {
return $this->helper('checkout/cart')->getAddUrlCustom($product, $additional, false);
return $helper->getAddUrlCustom($product, $additional, false);
}
return $this->helper('checkout/cart')->getAddUrl($product, $additional);
return $helper->getAddUrl($product, $additional);
}
}
7 changes: 5 additions & 2 deletions app/code/core/Mage/Catalog/Block/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,12 @@ public function getAddToCartUrlCustom($product, $additional = array(), $addFormK
$additional[Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED] =
Mage::helper('core')->urlEncode($addUrlValue);

/** @var Mage_Checkout_Helper_Cart $helper */
$helper = $this->helper('checkout/cart');

if (!$addFormKey) {
return $this->helper('checkout/cart')->getAddUrlCustom($product, $additional, false);
return $helper->getAddUrlCustom($product, $additional, false);
}
return $this->helper('checkout/cart')->getAddUrl($product, $additional);
return $helper->getAddUrl($product, $additional);
}
}