diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon index deb8965ed7f..8ff6b70df33 100644 --- a/.github/phpstan-baseline.neon +++ b/.github/phpstan-baseline.neon @@ -350,11 +350,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist.php - - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 3 - path: ../app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getGroups\\(\\)\\.$#" count: 1 @@ -960,11 +955,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/Block/Store/Switcher.php - - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" count: 1 @@ -1010,21 +1000,11 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php - - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tabs.php - - message: "#^Method Mage_Adminhtml_Block_Widget_Grid\\:\\:setDefaultSort\\(\\) invoked with 2 parameters, 1 required\\.$#" count: 1 path: ../app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/History.php - - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tabs.php - - message: "#^Call to method getIdCollection\\(\\) on an unknown class Mage_Dataflow_Model_Import_Export\\.$#" count: 1 @@ -1210,11 +1190,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/Block/Urlrewrite/Category/Tree.php - - - message: "#^Cannot call method addLink\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/Block/Widget.php - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:decodeFilter\\(\\)\\.$#" count: 1 @@ -1285,11 +1260,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php - - - message: "#^Cannot call method addLink\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/Controller/Action.php - - message: "#^Cannot call method addValueFilter\\(\\) on Mage_Core_Model_Resource_Db_Collection_Abstract\\|false\\.$#" count: 1 @@ -1485,11 +1455,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php - - - message: "#^Method Mage_Adminhtml_Sales_Order_CreditmemoController\\:\\:_needToAddDummy\\(\\) should return bool but return statement is missing\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php - - message: "#^Parameter \\$order of method Mage_Adminhtml_Sales_Order_CreditmemoController\\:\\:_initInvoice\\(\\) has invalid type unknown_type\\.$#" count: 1 @@ -1500,16 +1465,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php - - - message: "#^Method Mage_Adminhtml_Sales_Order_InvoiceController\\:\\:_needToAddDummy\\(\\) should return bool but return statement is missing\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php - - - - message: "#^Method Mage_Adminhtml_Sales_Order_InvoiceController\\:\\:_needToAddDummyForShipment\\(\\) should return bool but return statement is missing\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php - - message: "#^Undefined variable\\: \\$shippingResponse$#" count: 1 @@ -1525,11 +1480,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php - - - message: "#^Method Mage_Adminhtml_Sales_Order_ShipmentController\\:\\:_needToAddDummy\\(\\) should return bool but return statement is missing\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php - - message: "#^Method Mage_Adminhtml_Controller_Action\\:\\:_setForcedFormKeyActions\\(\\) invoked with 2 parameters, 1 required\\.$#" count: 1 @@ -1540,11 +1490,6 @@ parameters: count: 4 path: ../app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php - - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 1 - path: ../app/code/core/Mage/Adminhtml/controllers/System/CacheController.php - - message: "#^Cannot call method initForm\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" count: 1 @@ -2180,26 +2125,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Captcha/controllers/RefreshController.php - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addCrumb\\(\\)\\.$#" - count: 2 - path: ../app/code/core/Mage/Catalog/Block/Breadcrumbs.php - - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addItem\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/Catalog/Block/Category/View.php - - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addLinkRel\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/Catalog/Block/Category/View.php - - - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:canUseCanonicalTag\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/Catalog/Block/Category/View.php - - message: "#^Cannot call method count\\(\\) on string\\.$#" count: 2 @@ -2215,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 @@ -2275,36 +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_Block_Abstract\\:\\:addLinkRel\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/Catalog/Block/Product/View.php - - - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:canUseCanonicalTag\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/Catalog/Block/Product/View.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 @@ -3240,21 +3110,11 @@ parameters: count: 1 path: ../app/code/core/Mage/CatalogRule/Model/Rule.php - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addCrumb\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php - - message: "#^Method Mage_Eav_Model_Entity_Attribute_Source_Interface\\:\\:getAllOptions\\(\\) invoked with 1 parameter, 0 required\\.$#" count: 1 path: ../app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addCrumb\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getQueryText\\(\\)\\.$#" count: 1 @@ -3265,11 +3125,6 @@ parameters: count: 1 path: ../app/code/core/Mage/CatalogSearch/Block/Autocomplete.php - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addCrumb\\(\\)\\.$#" - count: 1 - path: ../app/code/core/Mage/CatalogSearch/Block/Result.php - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:getEscapedQueryText\\(\\)\\.$#" count: 1 @@ -5895,11 +5750,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Review/controllers/CustomerController.php - - - message: "#^Call to an undefined method Mage_Core_Block_Abstract\\:\\:addCrumb\\(\\)\\.$#" - count: 2 - path: ../app/code/core/Mage/Review/controllers/ProductController.php - - message: "#^Call to an undefined method Mage_Core_Helper_Abstract\\:\\:init\\(\\)\\.$#" count: 1 @@ -6110,11 +5960,6 @@ parameters: count: 1 path: ../app/code/core/Mage/Sales/Block/Order/View.php - - - message: "#^Cannot call method addCrumb\\(\\) on Mage_Core_Block_Abstract\\|false\\.$#" - count: 2 - path: ../app/code/core/Mage/Sales/Helper/Guest.php - - message: "#^Method Mage_Sales_Model_Billing_Agreement\\:\\:getStatusLabel\\(\\) should return string but return statement is missing\\.$#" count: 1 diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php index ad5808ae328..1927714df93 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php @@ -36,26 +36,25 @@ public function __construct() $this->setTitle(Mage::helper('customer')->__('Customer Information')); } + /** + * @return Mage_Adminhtml_Block_Widget_Tabs + * @throws Exception + */ protected function _beforeToHtml() { -/* - if (Mage::registry('current_customer')->getId()) { - $this->addTab('view', array( - 'label' => Mage::helper('customer')->__('Customer View'), - 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_view')->toHtml(), - 'active' => true - )); - } -*/ + /** @var Mage_Adminhtml_Block_Customer_Edit_Tab_Account $block */ + $block = $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account'); $this->addTab('account', array( 'label' => Mage::helper('customer')->__('Account Information'), - 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(), + 'content' => $block->initForm()->toHtml(), 'active' => Mage::registry('current_customer')->getId() ? false : true )); + /** @var Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses $block */ + $block = $this->getLayout()->createBlock('adminhtml/customer_edit_tab_addresses'); $this->addTab('addresses', array( 'label' => Mage::helper('customer')->__('Addresses'), - 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_addresses')->initForm()->toHtml(), + 'content' => $block->initForm()->toHtml(), )); @@ -83,10 +82,12 @@ protected function _beforeToHtml() 'url' => $this->getUrl('*/*/wishlist', array('_current' => true)), )); + /** @var Mage_Adminhtml_Block_Customer_Edit_Tab_Newsletter $block */ + $block = $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter'); if (Mage::getSingleton('admin/session')->isAllowed('newsletter/subscriber')) { $this->addTab('newsletter', array( 'label' => Mage::helper('customer')->__('Newsletter'), - 'content' => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_newsletter')->initForm()->toHtml() + 'content' => $block->initForm()->toHtml() )); } @@ -112,6 +113,9 @@ protected function _beforeToHtml() return parent::_beforeToHtml(); } + /** + * @throws Exception + */ protected function _updateActiveTab() { $tabId = $this->getRequest()->getParam('tab'); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php index 4e30bf7a786..0af621c05db 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php @@ -27,6 +27,9 @@ */ class Mage_Adminhtml_Block_System_Cache_Edit extends Mage_Adminhtml_Block_Widget { + /** + * Mage_Adminhtml_Block_System_Cache_Edit constructor. + */ public function __construct() { parent::__construct(); @@ -34,6 +37,9 @@ public function __construct() $this->setTitle('Cache Management'); } + /** + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild('save_button', @@ -47,22 +53,30 @@ protected function _prepareLayout() return parent::_prepareLayout(); } + /** + * @return string + */ public function getSaveButtonHtml() { return $this->getChildHtml('save_button'); } + /** + * @return string + */ public function getSaveUrl() { return $this->getUrl('*/*/save', array('_current'=>true)); } + /** + * @return $this + */ public function initForm() { - $this->setChild('form', - $this->getLayout()->createBlock('adminhtml/system_cache_form') - ->initForm() - ); + /** @var Mage_Adminhtml_Block_System_Cache_Form $block */ + $block = $this->getLayout()->createBlock('adminhtml/system_cache_form'); + $this->setChild('form', $block->initForm()); return $this; } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php index 65f0166c543..dfcb245e23b 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php @@ -31,6 +31,10 @@ class Mage_Adminhtml_Block_System_Config_Edit extends Mage_Adminhtml_Block_Widge protected $_section; + /** + * Mage_Adminhtml_Block_System_Config_Edit constructor. + * @throws Exception + */ public function __construct() { parent::__construct(); @@ -45,6 +49,9 @@ public function __construct() $this->setHeaderCss((string)$this->_section->header_css); } + /** + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild('save_button', @@ -58,25 +65,27 @@ protected function _prepareLayout() return parent::_prepareLayout(); } + /** + * @return string + */ public function getSaveButtonHtml() { return $this->getChildHtml('save_button'); } + /** + * @return string + */ public function getSaveUrl() { return $this->getUrl('*/*/save', array('_current'=>true)); } + /** + * @return $this + */ public function initForm() { - /* - $this->setChild('dwstree', - $this->getLayout()->createBlock('adminhtml/system_config_dwstree') - ->initTabs() - ); - */ - $blockName = (string)$this->_section->frontend_model; if (empty($blockName)) { $blockName = self::DEFAULT_SECTION_BLOCK; @@ -87,6 +96,4 @@ public function initForm() ); return $this; } - - } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php index b17372b85be..28a64fb2e21 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php @@ -27,6 +27,9 @@ */ class Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_View extends Mage_Adminhtml_Block_Widget_Form { + /** + * @return $this + */ public function initForm() { $form = new Varien_Data_Form(); @@ -53,6 +56,5 @@ public function initForm() return $this; } - } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tabs.php index 0ac4f0910a7..7f1cfe4c66f 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tabs.php @@ -27,6 +27,9 @@ */ class Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { + /** + * Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tabs constructor. + */ public function __construct() { parent::__construct(); @@ -35,6 +38,10 @@ public function __construct() $this->setTitle(Mage::helper('adminhtml')->__('Import/Export Profile')); } + /** + * @inheritDoc + * @throws Exception + */ protected function _beforeToHtml() { $profile = Mage::registry('current_convert_profile'); @@ -51,7 +58,7 @@ protected function _beforeToHtml() )); if (!$new) { - if ($profile->getDirection()!='export') { + if ($profile->getDirection() !== 'export') { $this->addTab('upload', array( 'label' => Mage::helper('adminhtml')->__('Upload File'), 'content' => $this->getLayout()->createBlock('adminhtml/system_convert_gui_edit_tab_upload')->toHtml(), @@ -63,9 +70,12 @@ protected function _beforeToHtml() 'content' => $this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_run')->toHtml(), )); + /** @var Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_View + $block */ + $block = $this->getLayout()->createBlock('adminhtml/system_convert_gui_edit_tab_view'); $this->addTab('view', array( 'label' => Mage::helper('adminhtml')->__('Profile Actions XML'), - 'content' => $this->getLayout()->createBlock('adminhtml/system_convert_gui_edit_tab_view')->initForm()->toHtml(), + 'content' => $block->initForm()->toHtml(), )); $this->addTab('history', array( diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php index 19c3bfdd5a3..b0b57997b55 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php @@ -27,6 +27,9 @@ */ class Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tab_Edit extends Mage_Adminhtml_Block_Widget_Form { + /** + * @return $this + */ public function initForm() { $form = new Varien_Data_Form(); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tabs.php index afc5904b28c..1b5a1ad66b0 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tabs.php @@ -27,6 +27,9 @@ */ class Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { + /** + * Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tabs constructor. + */ public function __construct() { parent::__construct(); @@ -35,13 +38,19 @@ public function __construct() $this->setTitle(Mage::helper('adminhtml')->__('Import/Export Profile')); } + /** + * @inheritDoc + * @throws Exception + */ protected function _beforeToHtml() { $new = !Mage::registry('current_convert_profile')->getId(); + /** @var Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tab_Edit $block */ + $block = $this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_edit'); $this->addTab('edit', array( 'label' => Mage::helper('adminhtml')->__('Profile Actions XML'), - 'content' => $this->getLayout()->createBlock('adminhtml/system_convert_profile_edit_tab_edit')->initForm()->toHtml(), + 'content' => $block->initForm()->toHtml(), 'active' => true, )); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget.php b/app/code/core/Mage/Adminhtml/Block/Widget.php index 11460a2eee4..13f21af3f0f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget.php @@ -24,6 +24,9 @@ * @category Mage * @package Mage_Adminhtml * @author Magento Core Team + * + * @method $this setHeaderCss(string $value) + * @method $this setTitle(string $value) */ class Mage_Adminhtml_Block_Widget extends Mage_Adminhtml_Block_Template { @@ -56,11 +59,13 @@ public function getCurrentUrl($params = array()) protected function _addBreadcrumb($label, $title=null, $link=null) { - $this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link); + /** @var Mage_Adminhtml_Block_Widget_Breadcrumbs $block */ + $block = $this->getLayout()->getBlock('breadcrumbs'); + $block->addLink($label, $title, $link); } /** - * Create buttonn and return its html + * Create button and return its html * * @param string $label * @param string $onclick @@ -68,7 +73,8 @@ protected function _addBreadcrumb($label, $title=null, $link=null) * @param string $id * @return string */ - public function getButtonHtml($label, $onclick, $class='', $id=null) { + public function getButtonHtml($label, $onclick, $class='', $id=null) + { return $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => $label, @@ -80,6 +86,9 @@ public function getButtonHtml($label, $onclick, $class='', $id=null) { ->toHtml(); } + /** + * @return string + */ public function getGlobalIcon() { return ''.$this->__('Global Attribute').''; diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Breadcrumbs.php b/app/code/core/Mage/Adminhtml/Block/Widget/Breadcrumbs.php index 5dfbc0dd2d5..d2bc3af429c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Breadcrumbs.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Breadcrumbs.php @@ -34,13 +34,22 @@ class Mage_Adminhtml_Block_Widget_Breadcrumbs extends Mage_Adminhtml_Block_Templ */ protected $_links = array(); + /** + * Mage_Adminhtml_Block_Widget_Breadcrumbs constructor. + */ public function __construct() { $this->setTemplate('widget/breadcrumbs.phtml'); $this->addLink(Mage::helper('adminhtml')->__('Home'), Mage::helper('adminhtml')->__('Home'), $this->getUrl('*')); } - public function addLink($label, $title=null, $url=null) + /** + * @param string $label + * @param string|null $title + * @param string|null $url + * @return $this + */ + public function addLink($label, $title = null, $url = null) { if (empty($title)) { $title = $label; @@ -53,6 +62,9 @@ public function addLink($label, $title=null, $url=null) return $this; } + /** + * @inheritDoc + */ protected function _beforeToHtml() { // TODO - Moved to Beta 2, no breadcrumbs displaying in Beta 1 diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index 5306e9f72ec..ea6baf976b9 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -122,7 +122,9 @@ protected function _setActiveMenu($menuPath) */ protected function _addBreadcrumb($label, $title, $link=null) { - $this->getLayout()->getBlock('breadcrumbs')->addLink($label, $title, $link); + /** @var Mage_Adminhtml_Block_Widget_Breadcrumbs $block */ + $block = $this->getLayout()->getBlock('breadcrumbs'); + $block->addLink($label, $title, $link); return $this; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php index d9fa8488c37..84d0ec40f83 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/CreditmemoController.php @@ -407,7 +407,7 @@ public function addCommentAction() /** * Decides if we need to create dummy invoice item or not - * for eaxample we don't need create dummy parent if all + * for example we don't need create dummy parent if all * children are not in process * * @deprecated after 1.4, Mage_Sales_Model_Service_Order used @@ -426,7 +426,9 @@ protected function _needToAddDummy($item, $qtys) { } } return false; - } else if($item->getParentItem()) { + } + + if($item->getParentItem()) { if (isset($qtys[$item->getParentItem()->getId()]) && isset($qtys[$item->getParentItem()->getId()]['qty']) && $qtys[$item->getParentItem()->getId()]['qty'] > 0) @@ -435,6 +437,8 @@ protected function _needToAddDummy($item, $qtys) { } return false; } + + return false; } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php index 2304b4779d1..91b6fba723c 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/InvoiceController.php @@ -415,7 +415,7 @@ public function addCommentAction() /** * Decides if we need to create dummy invoice item or not - * for eaxample we don't need create dummy parent if all + * for example we don't need create dummy parent if all * children are not in process * * @deprecated after 1.4, Mage_Sales_Model_Service_Order used @@ -431,17 +431,21 @@ protected function _needToAddDummy($item, $qtys) { } } return false; - } else if($item->getParentItem()) { + } + + if ($item->getParentItem()) { if (isset($qtys[$item->getParentItem()->getId()]) && $qtys[$item->getParentItem()->getId()] > 0) { return true; } return false; } + + return false; } /** * Decides if we need to create dummy shipment item or not - * for eaxample we don't need create dummy parent if all + * for example we don't need create dummy parent if all * children are not in process * * @deprecated after 1.4, Mage_Sales_Model_Service_Order used @@ -463,7 +467,9 @@ protected function _needToAddDummyForShipment($item, $qtys) { return true; } return false; - } else if($item->getParentItem()) { + } + + if ($item->getParentItem()) { if ($item->getIsVirtual()) { return false; } @@ -472,6 +478,8 @@ protected function _needToAddDummyForShipment($item, $qtys) { } return false; } + + return false; } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php index 04d0fa1f07c..d1157007116 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php @@ -452,7 +452,7 @@ public function addCommentAction() /** * Decides if we need to create dummy shipment item or not - * for eaxample we don't need create dummy parent if all + * for example we don't need create dummy parent if all * children are not in process * * @deprecated after 1.4, Mage_Sales_Model_Service_Order used @@ -472,7 +472,9 @@ protected function _needToAddDummy($item, $qtys) { } } return false; - } else if($item->getParentItem()) { + } + + if ($item->getParentItem()) { if ($item->getIsVirtual()) { return false; } @@ -482,6 +484,8 @@ protected function _needToAddDummy($item, $qtys) { } return false; } + + return false; } /** diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php b/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php index b9b141331d5..308e1967804 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/CacheController.php @@ -48,9 +48,11 @@ protected function _getSession() */ public function indexAction() { + /** @var Mage_Adminhtml_Block_System_Cache_Edit $block */ + $block = $this->getLayout()->createBlock('adminhtml/system_cache_edit'); $this->loadLayout() ->_setActiveMenu('system/cache') - ->_addContent($this->getLayout()->createBlock('adminhtml/system_cache_edit')->initForm()) + ->_addContent($block->initForm()) ->renderLayout(); } diff --git a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php index e107ac69e42..9534405c7b3 100644 --- a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php +++ b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php @@ -46,7 +46,9 @@ public function getTitleSeparator($store = null) */ protected function _prepareLayout() { - if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) { + /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbsBlock */ + $breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'); + if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('home', array( 'label'=>Mage::helper('catalog')->__('Home'), 'title'=>Mage::helper('catalog')->__('Go to Home Page'), diff --git a/app/code/core/Mage/Catalog/Block/Category/View.php b/app/code/core/Mage/Catalog/Block/Category/View.php index 4dbd474a0d6..3576d52279e 100644 --- a/app/code/core/Mage/Catalog/Block/Category/View.php +++ b/app/code/core/Mage/Catalog/Block/Category/View.php @@ -37,7 +37,9 @@ protected function _prepareLayout() $this->getLayout()->createBlock('catalog/breadcrumbs'); - if ($headBlock = $this->getLayout()->getBlock('head')) { + /** @var Mage_Page_Block_Html_Head $headBlock */ + $headBlock = $this->getLayout()->getBlock('head'); + if ($headBlock) { $category = $this->getCurrentCategory(); if ($title = $category->getMetaTitle()) { $headBlock->setTitle($title); @@ -48,7 +50,10 @@ protected function _prepareLayout() if ($keywords = $category->getMetaKeywords()) { $headBlock->setKeywords($keywords); } - if ($this->helper('catalog/category')->canUseCanonicalTag()) { + + /** @var Mage_Catalog_Helper_Category $helper */ + $helper = $this->helper('catalog/category'); + if ($helper->canUseCanonicalTag()) { $headBlock->addLinkRel('canonical', $category->getUrl()); } /* diff --git a/app/code/core/Mage/Catalog/Block/Product/Abstract.php b/app/code/core/Mage/Catalog/Block/Product/Abstract.php index 7a44ae26b24..21ea13ad87f 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Abstract.php +++ b/app/code/core/Mage/Catalog/Block/Product/Abstract.php @@ -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); } /** @@ -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); } /** @@ -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, diff --git a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php index 87009d95661..d06e520e9a2 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php +++ b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php @@ -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); } } diff --git a/app/code/core/Mage/Catalog/Block/Product/Price.php b/app/code/core/Mage/Catalog/Block/Product/Price.php index a1dde38ffbc..2b6ca7cd922 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Price.php +++ b/app/code/core/Mage/Catalog/Block/Product/Price.php @@ -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); } } diff --git a/app/code/core/Mage/Catalog/Block/Product/View.php b/app/code/core/Mage/Catalog/Block/Product/View.php index 2fcc00c0f12..fbf08da58d0 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View.php +++ b/app/code/core/Mage/Catalog/Block/Product/View.php @@ -30,6 +30,8 @@ * @method $this setCustomAddToCartUrl(string $value) * @method bool hasCustomAddToCartUrl() * @method string getCustomAddToCartUrl() + * @method bool hasCustomAddToCartPostUrl() + * @method string getCustomAddToCartPostUrl() */ class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstract { @@ -48,6 +50,8 @@ class Mage_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstrac protected function _prepareLayout() { $this->getLayout()->createBlock('catalog/breadcrumbs'); + + /** @var Mage_Page_Block_Html_Head $headBlock */ $headBlock = $this->getLayout()->getBlock('head'); if ($headBlock) { $product = $this->getProduct(); @@ -68,7 +72,10 @@ protected function _prepareLayout() } else { $headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255)); } - if ($this->helper('catalog/product')->canUseCanonicalTag()) { + + /** @var Mage_Catalog_Helper_Product $helper */ + $helper = $this->helper('catalog/product'); + if ($helper->canUseCanonicalTag()) { $params = array('_ignore_category' => true); $headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params)); } @@ -81,6 +88,7 @@ protected function _prepareLayout() * Retrieve current product model * * @return Mage_Catalog_Model_Product + * @throws Mage_Core_Exception */ public function getProduct() { @@ -108,6 +116,7 @@ public function canEmailToFriend() * @param Mage_Catalog_Model_Product $product * @param array $additional * @return string + * @throws Exception */ public function getAddToCartUrl($product, $additional = array()) { @@ -119,6 +128,7 @@ public function getAddToCartUrl($product, $additional = array()) * price calculation depending on product options * * @return string + * @throws Mage_Core_Exception */ public function getJsonConfig() { @@ -127,7 +137,6 @@ public function getJsonConfig() return Mage::helper('core')->jsonEncode($config); } - /* @var Mage_Catalog_Model_Product $product */ $product = $this->getProduct(); /** @var Mage_Catalog_Helper_Product_Type_Composite $compositeProductHelper */ @@ -152,6 +161,7 @@ public function getJsonConfig() * Return true if product has options * * @return bool + * @throws Mage_Core_Exception */ public function hasOptions() { @@ -165,6 +175,7 @@ public function hasOptions() * Check if product has required options * * @return bool + * @throws Mage_Core_Exception */ public function hasRequiredOptions() { @@ -178,6 +189,7 @@ public function hasRequiredOptions() * instantly. * * @return bool + * @throws Mage_Core_Exception */ public function isStartCustomization() { @@ -190,6 +202,7 @@ public function isStartCustomization() * * @param null|Mage_Catalog_Model_Product $product * @return int|float + * @throws Mage_Core_Exception */ public function getProductDefaultQty($product = null) { @@ -204,6 +217,7 @@ public function getProductDefaultQty($product = null) * Retrieve block cache tags * * @return array + * @throws Mage_Core_Exception */ public function getCacheTags() { @@ -217,6 +231,7 @@ public function getCacheTags() * @param array $additional * @param bool $addFormKey * @return string + * @throws Exception */ public function getAddToCartUrlCustom($product, $additional = array(), $addFormKey = true) { @@ -234,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); } } diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php index 039e62b77ce..176d9b6f20b 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php @@ -33,7 +33,9 @@ class Mage_CatalogSearch_Block_Advanced_Form extends Mage_Core_Block_Template public function _prepareLayout() { // add Home breadcrumb - if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) { + /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ + $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); + if ($breadcrumbs) { $breadcrumbs->addCrumb('home', array( 'label'=>Mage::helper('catalogsearch')->__('Home'), 'title'=>Mage::helper('catalogsearch')->__('Go to Home Page'), diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php index 1fa42f7538c..5ad88a38b7e 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php @@ -34,7 +34,9 @@ class Mage_CatalogSearch_Block_Advanced_Result extends Mage_Core_Block_Template */ protected function _prepareLayout() { - if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) { + /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ + $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); + if ($breadcrumbs) { $breadcrumbs->addCrumb('home', array( 'label'=>Mage::helper('catalogsearch')->__('Home'), 'title'=>Mage::helper('catalogsearch')->__('Go to Home Page'), diff --git a/app/code/core/Mage/CatalogSearch/Block/Result.php b/app/code/core/Mage/CatalogSearch/Block/Result.php index 358ed685327..a92bd86aef3 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Result.php @@ -54,6 +54,7 @@ protected function _getQuery() protected function _prepareLayout() { // add Home breadcrumb + /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbs) { $title = $this->__("Search results for: '%s'", $this->helper('catalogsearch')->getQueryText()); diff --git a/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php b/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php index 7da316899ac..2ab36c752d6 100644 --- a/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php +++ b/app/code/core/Mage/Page/Block/Html/Breadcrumbs.php @@ -68,7 +68,7 @@ public function addCrumb($crumbName, $crumbInfo, $after = false) $this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly')); if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) { if ($after && isset($this->_crumbs[$after])) { - $offset = array_search($after, array_keys($this->_crumbs)) + 1; + $offset = array_search($after, array_keys($this->_crumbs), true) + 1; $this->_crumbs = array_slice($this->_crumbs, 0, $offset, true) + array($crumbName => $crumbInfo) + array_slice($this->_crumbs, $offset, null, true); } else { $this->_crumbs[$crumbName] = $crumbInfo; @@ -86,7 +86,7 @@ public function addCrumbBefore($crumbName, $crumbInfo, $before = false) { if ($before && isset($this->_crumbs[$before])) { $keys = array_keys($this->_crumbs); - $offset = array_search($before, $keys); + $offset = array_search($before, $keys, true); # add before first if (!$offset) { $this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly')); diff --git a/app/code/core/Mage/Review/controllers/ProductController.php b/app/code/core/Mage/Review/controllers/ProductController.php index fc547ad6bb7..f43b1625ee6 100644 --- a/app/code/core/Mage/Review/controllers/ProductController.php +++ b/app/code/core/Mage/Review/controllers/ProductController.php @@ -235,7 +235,9 @@ public function listAction() $this->_initProductLayout($product); // update breadcrumbs - if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) { + /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbsBlock */ + $breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'); + if ($breadcrumbsBlock) { $breadcrumbsBlock->addCrumb('product', array( 'label' => $product->getName(), 'link' => $product->getProductUrl(), diff --git a/app/code/core/Mage/Sales/Helper/Guest.php b/app/code/core/Mage/Sales/Helper/Guest.php index df68e92fac9..1c3c35a5e83 100644 --- a/app/code/core/Mage/Sales/Helper/Guest.php +++ b/app/code/core/Mage/Sales/Helper/Guest.php @@ -127,6 +127,7 @@ public function loadValidOrder() */ public function getBreadcrumbs($controller) { + /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ $breadcrumbs = $controller->getLayout()->getBlock('breadcrumbs'); $breadcrumbs->addCrumb( 'home',