Skip to content

Commit c21481f

Browse files
authored
Phpstan: DocBlock fixes (#5101)
* update * update * composer.lock * fix cast to int * fix cast to int - allow float * fix * fix * baseline - see #5097
1 parent e1f7ec8 commit c21481f

File tree

93 files changed

+609
-798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+609
-798
lines changed

.phpstan.dist.baseline.neon

Lines changed: 6 additions & 642 deletions
Large diffs are not rendered by default.

.phpstan.dist.neon

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,37 +96,18 @@ parameters:
9696
- app/design/adminhtml/default/default/template/tax/class/page/edit.phtml
9797
- app/design/adminhtml/default/default/template/tax/toolbar/class/save.phtml
9898
- app/design/adminhtml/default/default/template/tax/toolbar/rule/save.phtml
99-
- app/design/frontend/base/default/template/bundle/catalog/product/list/partof.phtml
100-
- app/design/frontend/base/default/template/bundle/catalog/product/view/options/notice.phtml
101-
- app/design/frontend/base/default/template/catalog/category/page.phtml
102-
- app/design/frontend/base/default/template/catalog/category/widget/link/link_block.phtml
103-
- app/design/frontend/base/default/template/catalog/category/widget/link/link_inline.phtml
104-
- app/design/frontend/base/default/template/catalog/product/view/price.phtml
105-
- app/design/frontend/base/default/template/catalog/product/widget/link/link_block.phtml
106-
- app/design/frontend/base/default/template/catalog/product/widget/link/link_inline.phtml
107-
- app/design/frontend/base/default/template/checkout/cart/render/default.phtml
108-
- app/design/frontend/base/default/template/checkout/cart/render/simple.phtml
109-
- app/design/frontend/base/default/template/cms/widget/link/link_block.phtml
110-
- app/design/frontend/base/default/template/cms/widget/link/link_inline.phtml
111-
- app/design/frontend/base/default/template/cms/widget/static_block/default.phtml
112-
- app/design/frontend/base/default/template/core/messages.phtml
113-
- app/design/frontend/base/default/template/customer/address.phtml
114-
- app/design/frontend/base/default/template/customer/balance.phtml
115-
- app/design/frontend/base/default/template/customer/form/address.phtml
116-
- app/design/frontend/base/default/template/customer/form/changepassword.phtml
117-
- app/design/frontend/base/default/template/customer/orders.phtml
118-
- app/design/frontend/base/default/template/customer/wishlist.phtml
119-
- app/design/frontend/base/default/template/directory/currency/switch.phtml
120-
- app/design/frontend/base/default/template/page/redirect.phtml
121-
- app/design/frontend/base/default/template/paypal/hss/review/button.phtml
122-
- app/design/frontend/rwd/default/template/checkout/cart/render/default.phtml
123-
- app/design/frontend/rwd/default/template/checkout/cart/render/simple.phtml
124-
- app/design/frontend/rwd/default/template/customer/form/address.phtml
125-
- app/design/frontend/rwd/default/template/customer/form/changepassword.phtml
126-
- app/design/frontend/rwd/default/template/paypal/express/review/address.phtml
127-
- app/design/install/default/default/template/page.phtml
99+
-
100+
# update phpstan plugin
101+
identifier: method.protected
102+
paths:
103+
- app/design/*/*/template/*
128104
-
129105
identifier: phpunit.coversMethod
106+
-
107+
# update phpstan plugin
108+
identifier: property.protected
109+
paths:
110+
- app/design/*/*/template/*
130111
-
131112
identifier: variable.undefined
132113
paths:

app/code/core/Mage/Adminhtml/Block/Notification/Window.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
/**
1111
* @package Mage_Adminhtml
12+
*
13+
* @property string $_aclResourcePath
1214
*/
1315
class Mage_Adminhtml_Block_Notification_Window extends Mage_Adminhtml_Block_Notification_Toolbar
1416
{
@@ -72,6 +74,7 @@ protected function _construct()
7274
* Can we show notification window
7375
*
7476
* @return bool
77+
* @throws Exception
7578
*/
7679
public function canShow()
7780
{
@@ -126,6 +129,7 @@ public function getLastNotice()
126129
* Retrieve severity icons url
127130
*
128131
* @return string
132+
* @throws Mage_Core_Exception
129133
*/
130134
public function getSeverityIconsUrl()
131135
{

app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Packaging.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function getShipment()
2929
* Configuration for popup window for packaging
3030
*
3131
* @return string
32+
* @throws Exception
33+
* @throws Mage_Core_Exception
3234
*/
3335
public function getConfigDataJson()
3436
{
@@ -205,6 +207,7 @@ public function getPackages()
205207
* @param int $itemId
206208
* @param string $itemsOf
207209
* @return Varien_Object
210+
* @throws Mage_Core_Exception
208211
*/
209212
public function getShipmentItem($itemId, $itemsOf)
210213
{
@@ -263,6 +266,7 @@ public function getDeliveryConfirmationTypes()
263266
* Print button for creating pdf
264267
*
265268
* @return string
269+
* @throws Mage_Core_Exception
266270
*/
267271
public function getPrintButton()
268272
{
@@ -360,7 +364,7 @@ public function getQtyOrderedItem($itemId)
360364
if ($itemId) {
361365
return $this->getShipment()->getOrder()->getItemById($itemId)->getQtyOrdered() * 1;
362366
} else {
363-
return;
367+
return null;
364368
}
365369
}
366370
}

app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Tracking/Info.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Shipment tracking control form
1212
*
1313
* @package Mage_Adminhtml
14+
*
15+
* @property Mage_Sales_Model_Order_Shipment_Track $trackingInfo
1416
*/
1517
class Mage_Adminhtml_Block_Sales_Order_Shipment_Tracking_Info extends Mage_Adminhtml_Block_Template
1618
{

app/code/core/Mage/Adminhtml/Block/System/Config/Form.php

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function __construct()
8181

8282
/**
8383
* @return $this
84+
* @throws Mage_Core_Exception
8485
*/
8586
protected function _initObjects()
8687
{
@@ -97,6 +98,8 @@ protected function _initObjects()
9798

9899
/**
99100
* @return $this
101+
* @throws Exception
102+
* @throws Mage_Core_Exception
100103
*/
101104
public function initForm()
102105
{
@@ -114,7 +117,7 @@ public function initForm()
114117
}
115118

116119
foreach ($sections as $section) {
117-
/** @var Varien_Simplexml_Element $section */
120+
/** @var Mage_Core_Model_Config_Element $section */
118121
if (!$this->_canShowField($section)) {
119122
continue;
120123
}
@@ -124,7 +127,7 @@ public function initForm()
124127
usort($groups, [$this, '_sortForm']);
125128

126129
foreach ($groups as $group) {
127-
/** @var Varien_Simplexml_Element $group */
130+
/** @var Mage_Core_Model_Config_Element $group */
128131
if (!$this->_canShowField($group)) {
129132
continue;
130133
}
@@ -142,9 +145,11 @@ public function initForm()
142145
* Init config group
143146
*
144147
* @param Varien_Data_Form $form
145-
* @param Varien_Simplexml_Element $group
146-
* @param Varien_Simplexml_Element $section
148+
* @param Mage_Core_Model_Config_Element $group
149+
* @param Mage_Core_Model_Config_Element $section
147150
* @param null|Varien_Data_Form_Element_Fieldset $parentElement
151+
* @throws Exception
152+
* @throws Mage_Core_Exception
148153
*/
149154
protected function _initGroup($form, $group, $section, $parentElement = null)
150155
{
@@ -220,12 +225,13 @@ protected function _getDependence()
220225
* Init fieldset fields
221226
*
222227
* @param Varien_Data_Form_Element_Fieldset $fieldset
223-
* @param Varien_Simplexml_Element $group
224-
* @param Varien_Simplexml_Element $section
228+
* @param Mage_Core_Model_Config_Element $group
229+
* @param Mage_Core_Model_Config_Element $section
225230
* @param string $fieldPrefix
226231
* @param string $labelPrefix
227-
* @throw Mage_Core_Exception
228232
* @return $this
233+
* @throws Exception
234+
* @throws Mage_Core_Exception
229235
*/
230236
public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
231237
{
@@ -397,8 +403,8 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe
397403
'scope' => $this->getScope(),
398404
'scope_id' => $this->getScopeId(),
399405
'scope_label' => $this->getScopeLabel($element),
400-
'can_use_default_value' => $this->canUseDefaultValue((int) $element->show_in_default),
401-
'can_use_website_value' => $this->canUseWebsiteValue((int) $element->show_in_website),
406+
'can_use_default_value' => $this->canUseDefaultValue($element->show_in_default),
407+
'can_use_website_value' => $this->canUseWebsiteValue($element->show_in_website),
402408
];
403409
if ($this->isOverwrittenByEnvVariable($path)) {
404410
$elementFieldData['scope_label'] = $this->_scopeLabels[self::SCOPE_ENV];
@@ -576,8 +582,9 @@ protected function _sortForm($a, $b)
576582
}
577583

578584
/**
579-
* @param Varien_Simplexml_Element $field
585+
* @param Mage_Core_Model_Config_Element $field
580586
* @return bool
587+
* @throws Exception
581588
*/
582589
public function canUseDefaultValue($field)
583590
{
@@ -593,8 +600,9 @@ public function canUseDefaultValue($field)
593600
}
594601

595602
/**
596-
* @param Varien_Simplexml_Element $field
603+
* @param Mage_Core_Model_Config_Element $field
597604
* @return bool
605+
* @throws Exception
598606
*/
599607
public function canUseWebsiteValue($field)
600608
{
@@ -608,8 +616,9 @@ public function canUseWebsiteValue($field)
608616
/**
609617
* Checking field visibility
610618
*
611-
* @param Varien_Simplexml_Element $field
619+
* @param Mage_Core_Model_Config_Element $field
612620
* @return bool
621+
* @throws Exception
613622
*/
614623
protected function _canShowField($field)
615624
{
@@ -635,6 +644,7 @@ protected function _canShowField($field)
635644
* Retrieve current scope
636645
*
637646
* @return string
647+
* @throws Exception
638648
*/
639649
public function getScope()
640650
{
@@ -656,6 +666,8 @@ public function getScope()
656666

657667
/**
658668
* Returns true if element was overwritten by ENV variable
669+
*
670+
* @throws Exception
659671
*/
660672
public function isOverwrittenByEnvVariable(string $path): bool
661673
{
@@ -701,6 +713,7 @@ public function getScopeLabel($element)
701713
* Get current scope code
702714
*
703715
* @return string
716+
* @throws Exception
704717
*/
705718
public function getScopeCode()
706719
{
@@ -724,6 +737,8 @@ public function getScopeCode()
724737
* Get current scope code
725738
*
726739
* @return int|string
740+
* @throws Exception
741+
* @throws Mage_Core_Exception
727742
*/
728743
public function getScopeId()
729744
{
@@ -766,6 +781,7 @@ protected function _getAdditionalElementTypes()
766781
/**
767782
* @TODO delete this methods when {^see above^} is done
768783
* @return string
784+
* @throws Exception
769785
*/
770786
public function getSectionCode()
771787
{
@@ -775,6 +791,7 @@ public function getSectionCode()
775791
/**
776792
* @TODO delete this methods when {^see above^} is done
777793
* @return string
794+
* @throws Exception
778795
*/
779796
public function getWebsiteCode()
780797
{
@@ -784,6 +801,7 @@ public function getWebsiteCode()
784801
/**
785802
* @TODO delete this methods when {^see above^} is done
786803
* @return string
804+
* @throws Exception
787805
*/
788806
public function getStoreCode()
789807
{

app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function setDestElementId($elementId)
8383
* @param string $tabId new tab Id
8484
* @param array|string|Varien_Object $tab
8585
* @param string $afterTabId
86+
* @throws Exception
8687
*/
8788
public function addTabAfter($tabId, $tab, $afterTabId)
8889
{
@@ -96,6 +97,7 @@ public function addTabAfter($tabId, $tab, $afterTabId)
9697
* @param string $tabId
9798
* @param array|string|Varien_Object $tab
9899
* @return $this
100+
* @throws Exception
99101
*/
100102
public function addTab($tabId, $tab)
101103
{
@@ -181,9 +183,9 @@ public function setActiveTab($tabId)
181183
*/
182184
protected function _setActiveTab($tabId)
183185
{
184-
foreach ($this->_tabs as $id => $tab) {
186+
foreach ($this->_tabs as $key => $tab) {
185187
if ($this->getTabId($tab) == $tabId) {
186-
$this->_activeTab = $id;
188+
$this->_activeTab = $key;
187189
$tab->setActive(true);
188190
return $this;
189191
}
@@ -194,6 +196,7 @@ protected function _setActiveTab($tabId)
194196

195197
/**
196198
* @inheritDoc
199+
* @throws Exception
197200
*/
198201
protected function _beforeToHtml()
199202
{
@@ -408,7 +411,6 @@ public function getTabContent($tab)
408411
*
409412
* @param string $tabOneId
410413
* @param string $tabTwoId
411-
* @param string $tabNId...
412414
*/
413415
public function bindShadowTabs($tabOneId, $tabTwoId)
414416
{

app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class Mage_Adminhtml_Report_StatisticsController extends Mage_Adminhtml_Controll
2727
*/
2828
protected $_adminSession = null;
2929

30+
/**
31+
* @throws Mage_Core_Exception
32+
* @throws Mage_Core_Model_Store_Exception
33+
*/
3034
public function _initAction()
3135
{
3236
$act = $this->getRequest()->getActionName();
@@ -40,6 +44,9 @@ public function _initAction()
4044
return $this;
4145
}
4246

47+
/**
48+
* @throws Zend_Locale_Exception
49+
*/
4350
public function _initReportAction($blocks)
4451
{
4552
if (!is_array($blocks)) {
@@ -71,6 +78,7 @@ public function _initReportAction($blocks)
7178
* Retrieve array of collection names by code specified in request
7279
*
7380
* @return array
81+
* @throws Exception
7482
* @deprecated after 1.4.0.1
7583
*/
7684
protected function _getCollectionNames()
@@ -120,11 +128,11 @@ public function refreshRecentAction()
120128
}
121129

122130
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Recent statistics have been updated.'));
123-
} catch (Mage_Core_Exception $e) {
124-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
125-
} catch (Exception $e) {
131+
} catch (Mage_Core_Exception $mageCoreException) {
132+
Mage::getSingleton('adminhtml/session')->addError($mageCoreException->getMessage());
133+
} catch (Exception $exception) {
126134
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to refresh recent statistics.'));
127-
Mage::logException($e);
135+
Mage::logException($exception);
128136
}
129137

130138
if ($this->_getSession()->isFirstPageAfterLogin()) {
@@ -150,11 +158,11 @@ public function refreshLifetimeAction()
150158
}
151159

152160
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Lifetime statistics have been updated.'));
153-
} catch (Mage_Core_Exception $e) {
154-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
155-
} catch (Exception $e) {
161+
} catch (Mage_Core_Exception $mageCoreException) {
162+
Mage::getSingleton('adminhtml/session')->addError($mageCoreException->getMessage());
163+
} catch (Exception $exception) {
156164
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to refresh lifetime statistics.'));
157-
Mage::logException($e);
165+
Mage::logException($exception);
158166
}
159167

160168
if ($this->_getSession()->isFirstPageAfterLogin()) {
@@ -166,6 +174,10 @@ public function refreshLifetimeAction()
166174
return $this;
167175
}
168176

177+
/**
178+
* @throws Mage_Core_Exception
179+
* @throws Mage_Core_Model_Store_Exception
180+
*/
169181
public function indexAction()
170182
{
171183
$this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('Refresh Statistics'));

0 commit comments

Comments
 (0)