Skip to content

Commit

Permalink
PHPStan: fixed "Access to an undefined property" (#2554)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored Sep 12, 2022
1 parent a24224d commit d033c75
Show file tree
Hide file tree
Showing 20 changed files with 280 additions and 358 deletions.
310 changes: 0 additions & 310 deletions .github/phpstan-baseline.neon

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@
*/
class Mage_Adminhtml_Block_Catalog_Category_Tab_Design extends Mage_Adminhtml_Block_Catalog_Form
{
/**
* @var Mage_Catalog_Model_Category
*/
protected $_category;

/**
* Mage_Adminhtml_Block_Catalog_Category_Tab_Design constructor.
*/
public function __construct()
{
parent::__construct();
$this->setShowGlobalIcon(true);
}

/**
* @return Mage_Catalog_Model_Category
*/
public function getCategory()
{
if (!$this->_category) {
Expand All @@ -39,6 +50,9 @@ public function getCategory()
return $this->_category;
}

/**
* @return $this
*/
public function _prepareLayout()
{
parent::_prepareLayout();
Expand Down
23 changes: 19 additions & 4 deletions app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
*/
class Mage_Adminhtml_Block_Customer_Edit_Tab_Cart extends Mage_Adminhtml_Block_Widget_Grid
{
/**
* @var string
*/
protected $_parentTemplate;

/**
* Mage_Adminhtml_Block_Customer_Edit_Tab_Cart constructor.
* @param array $attributes
*/
public function __construct($attributes= [])
{
parent::__construct($attributes);
Expand Down Expand Up @@ -58,8 +67,7 @@ protected function _prepareCollection()

if ($quote) {
$collection = $quote->getItemsCollection(false);
}
else {
} else {
$collection = new Varien_Data_Collection();
}

Expand Down Expand Up @@ -147,14 +155,21 @@ public function getCustomer() {
return Mage::registry('current_customer');
}

/**
* @return string
*/
public function getGridUrl()
{
return $this->getUrl('*/*/cart', ['_current'=>true, 'website_id' => $this->getWebsiteId()]);
return $this->getUrl('*/*/cart', ['_current' => true, 'website_id' => $this->getWebsiteId()]);
}

/**
* @return string
* @throws Exception
*/
public function getGridParentHtml()
{
$templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, ['_relative'=>true]);
$templateName = Mage::getDesign()->getTemplateFilename($this->_parentTemplate, ['_relative' => true]);
return $this->fetchView($templateName);
}

Expand Down
15 changes: 6 additions & 9 deletions app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class Mage_Adminhtml_Block_Dashboard_Bar extends Mage_Adminhtml_Block_Dashboard_
protected $_totals = [];
protected $_currentCurrencyCode = null;

/**
* @var Mage_Directory_Model_Currency
*/
protected $_currency;

protected function _construct()
{
parent::_construct();
Expand All @@ -43,14 +48,6 @@ protected function getTotals()

public function addTotal($label, $value, $isQuantity=false)
{
/*if (!$isQuantity) {
$value = $this->format($value);
$decimals = substr($value, -2);
$value = substr($value, 0, -2);
} else {
$value = ($value != '')?$value:0;
$decimals = '';
}*/
if (!$isQuantity) {
$value = $this->format($value);
}
Expand Down Expand Up @@ -98,7 +95,7 @@ public function getCurrency()
} else if ($this->getRequest()->getParam('website')){
$this->_currentCurrencyCode = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getBaseCurrency();
} else if ($this->getRequest()->getParam('group')){
$this->_currentCurrencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
$this->_currentCurrencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
} else {
$this->_currentCurrencyCode = Mage::app()->getStore()->getBaseCurrency();
}
Expand Down
11 changes: 7 additions & 4 deletions app/code/core/Mage/Adminhtml/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class Mage_Adminhtml_Block_Dashboard_Graph extends Mage_Adminhtml_Block_Dashboar
*/
protected $_htmlId = '';

protected $_max;
protected $_min;

/**
* Initialize object
*/
Expand Down Expand Up @@ -368,14 +371,14 @@ public function getChartUrl($directUrl = true)

$valueBuffer[] = $indexid . ":|" . $tmpstring;
if (count($this->_axisLabels[$idx]) > 1) {
$deltaX = 100/(count($this->_axisLabels[$idx])-1);
$deltaX = 100 / (count($this->_axisLabels[$idx]) - 1);
} else {
$deltaX = 100;
}
} else if ($idx === 'y') {
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
if (count($yLabels)-1) {
$deltaY = 100/(count($yLabels)-1);
if (count($yLabels) - 1) {
$deltaY = 100 / (count($yLabels) - 1);
} else {
$deltaY = 100;
}
Expand Down Expand Up @@ -473,7 +476,7 @@ protected function _getPow($number)
{
$pow = 0;
while ($number >= 10) {
$number = $number/10;
$number = $number / 10;
$pow++;
}
return $pow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Mage_Adminhtml_Block_Newsletter_Template_Grid_Renderer_Action extends Mage
*/
public function render(Varien_Object $row)
{
if($row->isValidForSend()) {
if ($row->isValidForSend()) {
$actions[] = [
'url' => $this->getUrl('*/newsletter_queue/edit', ['template_id' => $row->getId()]),
'caption' => Mage::helper('newsletter')->__('Queue Newsletter...')
Expand Down
23 changes: 18 additions & 5 deletions app/code/core/Mage/Adminhtml/Block/Report/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ class Mage_Adminhtml_Block_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid
*/
protected $_currentCurrencyCode = null;

/**
* @var Mage_Core_Model_Locale
*/
protected $_locale;

/** @todo OM: check */
protected $_filterValues;

/**
* Mage_Adminhtml_Block_Report_Grid constructor.
*/
public function __construct()
{
parent::__construct();
Expand Down Expand Up @@ -185,16 +196,18 @@ protected function _prepareCollection()
$this->setCollection($collection);

Mage::dispatchEvent('adminhtml_widget_grid_filter_collection',
['collection' => $this->getCollection(), 'filter_values' => $this->_filterValues]
['collection' => $this->getCollection(), 'filter_values' => $this->_filterValues]
);
}

/**
* @param array $data
* @return $this
*/
protected function _setFilterValues($data)
{
foreach ($data as $name => $value) {
//if (isset($data[$name])) {
$this->setFilter($name, $data[$name]);
//}
$this->setFilter($name, $data[$name]);
}
return $this;
}
Expand Down Expand Up @@ -521,7 +534,7 @@ public function getExcel($filename = '')
foreach ($this->_columns as $column) {
$j++;
if (!$column->getIsSystem()) {
$row[] = ($j==1)?$this->__('Subtotal'):$column->getRowField($this->getTotals());
$row[] = ($j == 1)?$this->__('Subtotal'):$column->getRowField($this->getTotals());
}
}
$data[] = $row;
Expand Down
7 changes: 7 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class Mage_Adminhtml_Block_Report_Grid_Abstract extends Mage_Adminhtml_Block_Wid
protected $_storeIds = [];
protected $_aggregatedColumns = null;

/**
* Column for grid to be grouped by
*
* @var string
*/
protected $_columnGroupBy;

/**
* Mage_Adminhtml_Block_Report_Grid_Abstract constructor.
*/
Expand Down
Loading

0 comments on commit d033c75

Please sign in to comment.