Skip to content

Commit f78816c

Browse files
authored
Some phpstan fixes (OpenMage#4276)
* fixes mktime * fixes with return type void returns * fixes getRowUrl * phpstan * rector * minor fix
1 parent 2111640 commit f78816c

File tree

32 files changed

+158
-289
lines changed

32 files changed

+158
-289
lines changed

.phpstan.dist.baseline.neon

Lines changed: 0 additions & 195 deletions
Large diffs are not rendered by default.

app/code/core/Mage/Adminhtml/Block/Cache/Grid.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,15 @@ protected function _prepareCollection()
5252
*/
5353
protected function _afterLoadCollection()
5454
{
55-
foreach ($this->_collection as $item) {
56-
}
5755
return $this;
5856
}
5957

6058
/**
6159
* @inheritDoc
60+
* @throws Exception
6261
*/
6362
protected function _prepareColumns()
6463
{
65-
$baseUrl = $this->getUrl();
6664
$this->addColumn('cache_type', [
6765
'header' => $this->__('Cache Type'),
6866
'width' => '180',
@@ -104,6 +102,7 @@ protected function _prepareColumns()
104102
*
105103
* @return string
106104
*/
105+
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed
107106
public function decorateStatus($value, $row, $column, $isExport)
108107
{
109108
$class = '';
@@ -122,11 +121,12 @@ public function decorateStatus($value, $row, $column, $isExport)
122121
/**
123122
* Get row edit url
124123
*
125-
* @return false
124+
* @return string
126125
*/
126+
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
127127
public function getRowUrl($row)
128128
{
129-
return false;
129+
return '';
130130
}
131131

132132
/**

app/code/core/Mage/Adminhtml/Block/Report/Config/Form/Field/YtdStart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
2626
$_months = [];
2727
for ($i = 1; $i <= 12; $i++) {
2828
$_months[$i] = Mage::app()->getLocale()
29-
->date(mktime(0, null, null, $i))
29+
->date(mktime(0, 0, 0, $i))
3030
->get(Zend_Date::MONTH_NAME);
3131
}
3232

app/code/core/Mage/Adminhtml/Block/Tax/Rate/Grid/Renderer/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function _getValue(Varien_Object $row)
2525
{
2626
$data = parent::_getValue($row);
2727
if ((int) $data == $data) {
28-
return (string) number_format($data, 2);
28+
return (string) number_format((float)$data, 2);
2929
}
3030
if (!is_null($data)) {
3131
return $data * 1;

app/code/core/Mage/Adminhtml/Model/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ public function hasChildren($node, $websiteCode = null, $storeCode = null, $isFi
199199
/**
200200
* Get translate module name
201201
*
202-
* @param Varien_Simplexml_Element $sectionNode
203-
* @param Varien_Simplexml_Element $groupNode
204-
* @param Varien_Simplexml_Element $fieldNode
202+
* @param Varien_Simplexml_Element|false|null $sectionNode
203+
* @param Varien_Simplexml_Element|false|null $groupNode
204+
* @param Varien_Simplexml_Element|false|null $fieldNode
205205
* @return string
206206
*/
207207
public function getAttributeModule($sectionNode = null, $groupNode = null, $fieldNode = null)

app/code/core/Mage/Adminhtml/Model/System/Store.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,16 @@ class Mage_Adminhtml_Model_System_Store extends Varien_Object
4848
/**
4949
* @var bool
5050
*/
51+
// phpcs:ignore Ecg.PHP.PrivateClassMember.PrivateClassMemberError
5152
private $_isAdminScopeAllowed = true;
5253

5354
/**
5455
* Init model
5556
* Load Website, Group and Store collections
56-
*
57-
* @return $this
5857
*/
5958
public function __construct()
6059
{
61-
return $this->reload();
60+
$this->reload();
6261
}
6362

6463
/**
@@ -122,6 +121,7 @@ public function getStoreValuesForForm($empty = false, $all = false)
122121
];
123122
}
124123

124+
// phpcs:ignore Ecg.Security.ForbiddenFunction.Found
125125
$nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
126126

127127
foreach ($this->_websiteCollection as $website) {

app/code/core/Mage/Api/Model/Roles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getUsersCollection()
7171
*/
7272
public function getResourcesTree()
7373
{
74-
return $this->_buildResourcesArray(null, null, null, null, true);
74+
return $this->_buildResourcesArray(null, null, 0, null, true);
7575
}
7676

7777
/**
@@ -87,7 +87,7 @@ public function getResourcesList()
8787
*/
8888
public function getResourcesList2D()
8989
{
90-
return $this->_buildResourcesArray(null, null, null, true);
90+
return $this->_buildResourcesArray(null, null, 0, true);
9191
}
9292

9393
/**

app/code/core/Mage/Catalog/Helper/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public function addParamsToBuyRequest($buyRequest, $params)
439439
* Return loaded product instance
440440
*
441441
* @param int|string $productId (SKU or ID)
442-
* @param int $store
442+
* @param int|null $store
443443
* @param string $identifierType
444444
* @return Mage_Catalog_Model_Product
445445
*/

app/code/core/Mage/Catalog/Model/Product.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@
219219
*
220220
* @method int getTaxClassId()
221221
* @method string getThumbnail()
222-
* @method float getTaxPercent()
223-
* @method $this setTaxPercent(float $value)
222+
* @method float|null getTaxPercent()
223+
* @method $this setTaxPercent(float|null $value)
224224
* @method $this setTypeId(int $value)
225225
* @method bool getTypeHasOptions()
226226
* @method $this setTypeHasOptions(bool $value)
@@ -942,7 +942,7 @@ public function getFormatedPrice()
942942
* products it's called very often in Item->getProduct(). So removing chain of magic with more cpu consuming
943943
* algorithms gives nice optimization boost.
944944
*
945-
* @param float $price Price amount
945+
* @param float|null $price Price amount
946946
* @return $this
947947
*/
948948
public function setFinalPrice($price)

app/code/core/Mage/Catalog/Model/Url.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function _addCategoryUrlPath($category)
134134
/**
135135
* Retrieve stores array or store model
136136
*
137-
* @param int $storeId
137+
* @param int|null $storeId
138138
* @return Mage_Core_Model_Store|array
139139
*/
140140
public function getStores($storeId = null)
@@ -312,6 +312,7 @@ protected function _refreshCategoryRewrites(Varien_Object $category, $parentPath
312312
* Refresh product rewrite
313313
*
314314
* @return $this
315+
* @throws Mage_Core_Exception
315316
*/
316317
protected function _refreshProductRewrite(Varien_Object $product, Varien_Object $category)
317318
{
@@ -502,7 +503,7 @@ public function refreshProductRewrite($productId, $storeId = null)
502503
/**
503504
* Refresh all product rewrites for designated store
504505
*
505-
* @param int $storeId
506+
* @param int|null $storeId
506507
* @return $this
507508
*/
508509
public function refreshProductRewrites($storeId)

0 commit comments

Comments
 (0)