Skip to content

Commit

Permalink
Phpstan: fixed return types (docs only) (#2636)
Browse files Browse the repository at this point in the history
* Fixed "should return string but returns false"

* Fixed "should return XYZ but returns false"

* Fixed "should return array but returns null"

* Fixed "should return string but returns null"

* Fixed "should return int but returns null"

* Fixed "should return bool but returns"

* Fixed docs (see comments)

* Fixed "should return array"

* Update app/code/core/Mage/Adminhtml/Block/Widget/Grid/Massaction/Abstract.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Update app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Update app/code/core/Mage/Tag/Model/Resource/Tag.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Update app/code/core/Mage/Customer/Block/Form/Register.php

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>

* Added module names to helper(#2617)

* Get catalog search result collection from engine (#2634)

* Add PHP dependencies security check workflow (#2639)

* [security-workflow] Fixed cron syntax (#2640)

* Added OpenMage Contributors Copyright (#2295)

* Added ddev snippets to docs (#2575)

* Improve dev/openmage/install.sh script for newer versions of Docker - no longer requires separate compose.

* Only run workflows when relevant files change (#2641)

* Add back notification popup severity icons URL (#2633)

* Reduce reprocessed jpeg file size by defaulting quality to 85% (#2629)

* Fixed issue #475.

* Removed <frontend_type>text</frontend_type> as it is the default.

* Fixed bug on users not able to modify image quality in backend if deprecated config exists.

* Fixed bug on incorrect check if image quality was not set in backend.

* Improved note in system.xml.

* Prevented editing of a non-editable order (#2632)

* Fix dev/openmage/install.sh script setting permissions on var directory.

* Allowed automatic full invoice from API (#2393)

* Add check if array key isset before using it (#2649)

* Fixed phpstan-baseline.neon

* Fixed phpstan-baseline.neon (updated dev tools)

* Revert "Fixed phpstan-baseline.neon"

This reverts commit 3c82e76.

* Fixed getRegion()

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
Co-authored-by: Mohamed ELIDRISSI <67818913+elidrissidev@users.noreply.github.com>
Co-authored-by: Justin Beaty <51970393+justinbeaty@users.noreply.github.com>
Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
Co-authored-by: luigifab <31816829+luigifab@users.noreply.github.com>
Co-authored-by: Przemysław Piotrowski <przemyslaw.p@deligo.pl>
  • Loading branch information
7 people committed Oct 17, 2022
1 parent cc6317a commit 15f83af
Show file tree
Hide file tree
Showing 85 changed files with 469 additions and 675 deletions.
424 changes: 7 additions & 417 deletions .github/phpstan-baseline.neon

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Grid_Filter_Inventory extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
{
/**
* @return array
*/
protected function _getOptions()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price extends Varien_Data_Form_Element_Text
{
/**
* @param array $attributes
*/
public function __construct($attributes= [])
{
parent::__construct($attributes);
$this->addClass('validate-zero-or-greater');
}

/**
* @return string
* @throws Mage_Core_Model_Store_Exception
*/
public function getAfterElementHtml()
{
$html = parent::getAfterElementHtml();
Expand Down Expand Up @@ -61,13 +68,21 @@ public function getAfterElementHtml()
return $html;
}

/**
* @param $attribute
* @return string
*/
protected function _getTaxObservingCode($attribute)
{
$spanId = "dynamic-tax-{$attribute->getAttributeCode()}";

return "<script type='text/javascript'>if (dynamicTaxes == undefined) var dynamicTaxes = new Array(); dynamicTaxes[dynamicTaxes.length]='{$attribute->getAttributeCode()}'</script>";
}

/**
* @param null $index
* @return string|null
*/
public function getEscapedValue($index=null)
{
$value = $this->getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function __construct()
parent::__construct();
}

/**
* @return array
*/
protected function _getOptions()
{
$result = [];
Expand All @@ -53,9 +56,12 @@ protected function _getOptions()
return $result;
}

/**
* @return array|null
*/
public function getCondition()
{
if(is_null($this->getValue())) {
if (is_null($this->getValue())) {
return null;
}

Expand Down
62 changes: 52 additions & 10 deletions app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Adminhtml_Block_Customer_Edit_Tab_View
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface
class Mage_Adminhtml_Block_Customer_Edit_Tab_View extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
/**
* @var Mage_Customer_Model_Customer
*/
protected $_customer;

protected $_customerLog;

/**
* @return Mage_Customer_Model_Customer
*/
public function getCustomer()
{
if (!$this->_customer) {
Expand All @@ -42,6 +46,9 @@ public function getCustomer()
return $this->_customer;
}

/**
* @return string|void
*/
public function getGroupName()
{
if ($groupId = $this->getCustomer()->getGroupId()) {
Expand All @@ -68,20 +75,26 @@ public function getCustomerLog()
/**
* Get customer creation date
*
* @return string
* @return string|null
*/
public function getCreateDate()
{
if ( ! $this->getCustomer()->getCreatedAt()) {
if (! $this->getCustomer()->getCreatedAt()) {
return null;
}
return $this->_getCoreHelper()->formatDate($this->getCustomer()->getCreatedAt(),
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
return $this->_getCoreHelper()->formatDate(
$this->getCustomer()->getCreatedAt(),
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM,
true
);
}

/**
* @return string|null
*/
public function getStoreCreateDate()
{
if ( ! $this->getCustomer()->getCreatedAt()) {
if (! $this->getCustomer()->getCreatedAt()) {
return null;
}
$date = Mage::app()->getLocale()->storeDate(
Expand Down Expand Up @@ -112,6 +125,9 @@ public function getLastLoginDate()
return Mage::helper('customer')->__('Never');
}

/**
* @return string
*/
public function getStoreLastLoginDate()
{
if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
Expand All @@ -131,6 +147,9 @@ public function getStoreLastLoginDateTimezone()
->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
}

/**
* @return string
*/
public function getCurrentStatus()
{
$log = $this->getCustomerLog();
Expand All @@ -142,6 +161,9 @@ public function getCurrentStatus()
return Mage::helper('customer')->__('Online');
}

/**
* @return string
*/
public function getIsConfirmedStatus()
{
$this->getCustomer();
Expand All @@ -164,38 +186,55 @@ public function getStoreId()
return $this->getCustomer()->getStoreId();
}

/**
* @return string
*/
public function getBillingAddressHtml()
{
$html = '';
if ($address = $this->getCustomer()->getPrimaryBillingAddress()) {
$html = $address->format('html');
}
else {
} else {
$html = Mage::helper('customer')->__('The customer does not have default billing address.');
}
return $html;
}

/**
* @return string
*/
public function getAccordionHtml()
{
return $this->getChildHtml('accordion');
}

/**
* @return string
*/
public function getSalesHtml()
{
return $this->getChildHtml('sales');
}

/**
* @return string
*/
public function getTabLabel()
{
return Mage::helper('customer')->__('Customer View');
}

/**
* @return string
*/
public function getTabTitle()
{
return Mage::helper('customer')->__('Customer View');
}

/**
* @return bool
*/
public function canShowTab()
{
if (Mage::registry('current_customer')->getId()) {
Expand All @@ -204,6 +243,9 @@ public function canShowTab()
return false;
}

/**
* @return bool
*/
public function isHidden()
{
if (Mage::registry('current_customer')->getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ protected function _drawElementHtml($element, array $attributes, $closed = true)
/**
* Return escaped value
*
* @param int $index
* @return string
* @param string|null $index
* @return false|string
*/
public function getEscapedValue($index = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected function _getPreviewHtml()

/**
* Return Image URL
* @return string
* @return string|false
*/
protected function _getPreviewUrl()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,28 @@
*/
class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Filter_Website extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
{
/**
* @var Mage_Core_Model_Resource_Website_Collection
*/
protected $_websiteCollection = null;

/**
* @return array[]
*/
protected function _getOptions()
{
$result = $this->getCollection()->toOptionArray();
array_unshift($result, ['label'=>null, 'value'=>null]);
return $result;
}

/**
* @return Mage_Core_Model_Resource_Website_Collection
* @throws Mage_Core_Exception
*/
public function getCollection()
{
if(is_null($this->_websiteCollection)) {
if (is_null($this->_websiteCollection)) {
$this->_websiteCollection = Mage::getResourceModel('core/website_collection')
->load();
}
Expand All @@ -49,11 +59,14 @@ public function getCollection()
return $this->_websiteCollection;
}

/**
* @return array|null
* @throws Mage_Core_Exception
*/
public function getCondition()
{

$id = $this->getValue();
if(!$id) {
if (!$id) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
class Mage_Adminhtml_Block_Review_Grid_Filter_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
{
/**
* @return array
*/
protected function _getOptions()
{
return [
Expand All @@ -38,6 +41,9 @@ protected function _getOptions()
];
}

/**
* @return int
*/
public function getCondition()
{
if ($this->getValue() == 1) {
Expand Down
Loading

0 comments on commit 15f83af

Please sign in to comment.