Skip to content

Commit d033c75

Browse files
authored
PHPStan: fixed "Access to an undefined property" (OpenMage#2554)
1 parent a24224d commit d033c75

File tree

20 files changed

+280
-358
lines changed

20 files changed

+280
-358
lines changed

.github/phpstan-baseline.neon

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

app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,23 @@
2525
*/
2626
class Mage_Adminhtml_Block_Catalog_Category_Tab_Design extends Mage_Adminhtml_Block_Catalog_Form
2727
{
28+
/**
29+
* @var Mage_Catalog_Model_Category
30+
*/
31+
protected $_category;
32+
33+
/**
34+
* Mage_Adminhtml_Block_Catalog_Category_Tab_Design constructor.
35+
*/
2836
public function __construct()
2937
{
3038
parent::__construct();
3139
$this->setShowGlobalIcon(true);
3240
}
3341

42+
/**
43+
* @return Mage_Catalog_Model_Category
44+
*/
3445
public function getCategory()
3546
{
3647
if (!$this->_category) {
@@ -39,6 +50,9 @@ public function getCategory()
3950
return $this->_category;
4051
}
4152

53+
/**
54+
* @return $this
55+
*/
4256
public function _prepareLayout()
4357
{
4458
parent::_prepareLayout();

app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
*/
2828
class Mage_Adminhtml_Block_Customer_Edit_Tab_Cart extends Mage_Adminhtml_Block_Widget_Grid
2929
{
30+
/**
31+
* @var string
32+
*/
33+
protected $_parentTemplate;
34+
35+
/**
36+
* Mage_Adminhtml_Block_Customer_Edit_Tab_Cart constructor.
37+
* @param array $attributes
38+
*/
3039
public function __construct($attributes= [])
3140
{
3241
parent::__construct($attributes);
@@ -58,8 +67,7 @@ protected function _prepareCollection()
5867

5968
if ($quote) {
6069
$collection = $quote->getItemsCollection(false);
61-
}
62-
else {
70+
} else {
6371
$collection = new Varien_Data_Collection();
6472
}
6573

@@ -147,14 +155,21 @@ public function getCustomer() {
147155
return Mage::registry('current_customer');
148156
}
149157

158+
/**
159+
* @return string
160+
*/
150161
public function getGridUrl()
151162
{
152-
return $this->getUrl('*/*/cart', ['_current'=>true, 'website_id' => $this->getWebsiteId()]);
163+
return $this->getUrl('*/*/cart', ['_current' => true, 'website_id' => $this->getWebsiteId()]);
153164
}
154165

166+
/**
167+
* @return string
168+
* @throws Exception
169+
*/
155170
public function getGridParentHtml()
156171
{
157-
$templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, ['_relative'=>true]);
172+
$templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, ['_relative' => true]);
158173
return $this->fetchView($templateName);
159174
}
160175

app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class Mage_Adminhtml_Block_Dashboard_Bar extends Mage_Adminhtml_Block_Dashboard_
3030
protected $_totals = [];
3131
protected $_currentCurrencyCode = null;
3232

33+
/**
34+
* @var Mage_Directory_Model_Currency
35+
*/
36+
protected $_currency;
37+
3338
protected function _construct()
3439
{
3540
parent::_construct();
@@ -43,14 +48,6 @@ protected function getTotals()
4348

4449
public function addTotal($label, $value, $isQuantity=false)
4550
{
46-
/*if (!$isQuantity) {
47-
$value = $this->format($value);
48-
$decimals = substr($value, -2);
49-
$value = substr($value, 0, -2);
50-
} else {
51-
$value = ($value != '')?$value:0;
52-
$decimals = '';
53-
}*/
5451
if (!$isQuantity) {
5552
$value = $this->format($value);
5653
}
@@ -98,7 +95,7 @@ public function getCurrency()
9895
} else if ($this->getRequest()->getParam('website')){
9996
$this->_currentCurrencyCode = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getBaseCurrency();
10097
} else if ($this->getRequest()->getParam('group')){
101-
$this->_currentCurrencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
98+
$this->_currentCurrencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
10299
} else {
103100
$this->_currentCurrencyCode = Mage::app()->getStore()->getBaseCurrency();
104101
}

app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class Mage_Adminhtml_Block_Dashboard_Graph extends Mage_Adminhtml_Block_Dashboar
104104
*/
105105
protected $_htmlId = '';
106106

107+
protected $_max;
108+
protected $_min;
109+
107110
/**
108111
* Initialize object
109112
*/
@@ -368,14 +371,14 @@ public function getChartUrl($directUrl = true)
368371

369372
$valueBuffer[] = $indexid . ":|" . $tmpstring;
370373
if (count($this->_axisLabels[$idx]) > 1) {
371-
$deltaX = 100/(count($this->_axisLabels[$idx])-1);
374+
$deltaX = 100 / (count($this->_axisLabels[$idx]) - 1);
372375
} else {
373376
$deltaX = 100;
374377
}
375378
} else if ($idx === 'y') {
376379
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
377-
if (count($yLabels)-1) {
378-
$deltaY = 100/(count($yLabels)-1);
380+
if (count($yLabels) - 1) {
381+
$deltaY = 100 / (count($yLabels) - 1);
379382
} else {
380383
$deltaY = 100;
381384
}
@@ -473,7 +476,7 @@ protected function _getPow($number)
473476
{
474477
$pow = 0;
475478
while ($number >= 10) {
476-
$number = $number/10;
479+
$number = $number / 10;
477480
$pow++;
478481
}
479482
return $pow;

app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Grid/Renderer/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Action extends Mage
3535
*/
3636
public function render(Varien_Object $row)
3737
{
38-
if($row->isValidForSend()) {
38+
if ($row->isValidForSend()) {
3939
$actions[] = [
4040
'url' => $this->getUrl('*/newsletter_queue/edit', ['template_id' => $row->getId()]),
4141
'caption' => Mage::helper('newsletter')->__('Queue Newsletter...')

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ class Mage_Adminhtml_Block_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid
5656
*/
5757
protected $_currentCurrencyCode = null;
5858

59+
/**
60+
* @var Mage_Core_Model_Locale
61+
*/
62+
protected $_locale;
63+
64+
/** @todo OM: check */
65+
protected $_filterValues;
66+
67+
/**
68+
* Mage_Adminhtml_Block_Report_Grid constructor.
69+
*/
5970
public function __construct()
6071
{
6172
parent::__construct();
@@ -185,16 +196,18 @@ protected function _prepareCollection()
185196
$this->setCollection($collection);
186197

187198
Mage::dispatchEvent('adminhtml_widget_grid_filter_collection',
188-
['collection' => $this->getCollection(), 'filter_values' => $this->_filterValues]
199+
['collection' => $this->getCollection(), 'filter_values' => $this->_filterValues]
189200
);
190201
}
191202

203+
/**
204+
* @param array $data
205+
* @return $this
206+
*/
192207
protected function _setFilterValues($data)
193208
{
194209
foreach ($data as $name => $value) {
195-
//if (isset($data[$name])) {
196-
$this->setFilter($name, $data[$name]);
197-
//}
210+
$this->setFilter($name, $data[$name]);
198211
}
199212
return $this;
200213
}
@@ -521,7 +534,7 @@ public function getExcel($filename = '')
521534
foreach ($this->_columns as $column) {
522535
$j++;
523536
if (!$column->getIsSystem()) {
524-
$row[] = ($j==1)?$this->__('Subtotal'):$column->getRowField($this->getTotals());
537+
$row[] = ($j == 1)?$this->__('Subtotal'):$column->getRowField($this->getTotals());
525538
}
526539
}
527540
$data[] = $row;

app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class Mage_Adminhtml_Block_Report_Grid_Abstract extends Mage_Adminhtml_Block_Wid
3030
protected $_storeIds = [];
3131
protected $_aggregatedColumns = null;
3232

33+
/**
34+
* Column for grid to be grouped by
35+
*
36+
* @var string
37+
*/
38+
protected $_columnGroupBy;
39+
3340
/**
3441
* Mage_Adminhtml_Block_Report_Grid_Abstract constructor.
3542
*/

0 commit comments

Comments
 (0)