Skip to content

Commit

Permalink
PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbeaty committed Nov 24, 2024
1 parent c2f2f84 commit 2b5c4d0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 153 deletions.
160 changes: 23 additions & 137 deletions .phpstan.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,6 @@ parameters:
count: 1
path: app/code/core/Mage/Adminhtml/controllers/Catalog/Product/Action/AttributeController.php

-
message: '#^Ternary operator condition is always true\.$#'
identifier: ternary.alwaysTrue
count: 1
path: app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php

-
message: '#^Method Mage_Adminhtml_Controller_Action\:\:_setForcedFormKeyActions\(\) invoked with 2 parameters, 1 required\.$#'
identifier: arguments.count
Expand Down Expand Up @@ -2467,34 +2461,22 @@ parameters:
path: app/code/core/Mage/Customer/Block/Account/Navigation.php

-
message: '#^Method Mage_Customer_Block_Address_Edit\:\:getCountryId\(\) should return int but returns string\.$#'
identifier: return.type
count: 1
path: app/code/core/Mage/Customer/Block/Address/Edit.php

-
message: '#^Return type \(int\) of method Mage_Customer_Block_Address_Edit\:\:getCountryId\(\) should be compatible with return type \(string\) of method Mage_Directory_Block_Data\:\:getCountryId\(\)$#'
identifier: method.childReturnType
count: 1
path: app/code/core/Mage/Customer/Block/Address/Edit.php

-
message: '#^Method Mage_Customer_Block_Form_Register\:\:getCountryId\(\) should return int but returns string\.$#'
message: '#^Method Mage_Customer_Block_Newsletter\:\:getAction\(\) should return Mage_Core_Controller_Varien_Action but returns string\.$#'
identifier: return.type
count: 1
path: app/code/core/Mage/Customer/Block/Form/Register.php
path: app/code/core/Mage/Customer/Block/Newsletter.php

-
message: '#^Return type \(int\) of method Mage_Customer_Block_Form_Register\:\:getCountryId\(\) should be compatible with return type \(string\) of method Mage_Directory_Block_Data\:\:getCountryId\(\)$#'
identifier: method.childReturnType
count: 1
path: app/code/core/Mage/Customer/Block/Form/Register.php
message: '#^Method Mage_Eav_Model_Entity_Attribute_Source_Interface\:\:getAllOptions\(\) invoked with 1 parameter, 0 required\.$#'
identifier: arguments.count
count: 2
path: app/code/core/Mage/Customer/Helper/Address.php

-
message: '#^Method Mage_Customer_Block_Newsletter\:\:getAction\(\) should return Mage_Core_Controller_Varien_Action but returns string\.$#'
identifier: return.type
count: 1
path: app/code/core/Mage/Customer/Block/Newsletter.php
message: '#^Method Mage_Eav_Model_Entity_Attribute_Source_Interface\:\:getAllOptions\(\) invoked with 1 parameter, 0 required\.$#'
identifier: arguments.count
count: 2
path: app/code/core/Mage/Customer/Helper/Data.php

-
message: '#^Property Mage_Customer_Helper_Data\:\:\$_customer \(Mage_Customer_Model_Customer\) in empty\(\) is not falsy\.$#'
Expand Down Expand Up @@ -4830,24 +4812,6 @@ parameters:
count: 19
path: app/design/adminhtml/default/default/template/catalog/category/widget/tree.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 2
path: app/design/adminhtml/default/default/template/catalog/product/attribute/new/created.phtml

-
message: '#^Call to protected method _getHeader\(\) of class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main\.$#'
identifier: method.protected
count: 1
path: app/design/adminhtml/default/default/template/catalog/product/attribute/set/main.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 5
path: app/design/adminhtml/default/default/template/catalog/product/attribute/set/toolbar/add.phtml

-
message: '#^Call to protected method _getHeader\(\) of class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Main\.$#'
identifier: method.protected
Expand Down Expand Up @@ -5004,6 +4968,18 @@ parameters:
count: 63
path: app/design/adminhtml/default/default/template/downloadable/sales/order/view/items/renderer/downloadable.phtml

-
message: '#^Call to protected method _getHeader\(\) of class Mage_Eav_Block_Adminhtml_Attribute_Set_Add\.$#'
identifier: method.protected
count: 1
path: app/design/adminhtml/default/default/template/eav/attribute/set/add.phtml

-
message: '#^Call to protected method _getHeader\(\) of class Mage_Eav_Block_Adminhtml_Attribute_Set_Edit\.$#'
identifier: method.protected
count: 1
path: app/design/adminhtml/default/default/template/eav/attribute/set/edit.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -6306,12 +6282,6 @@ parameters:
count: 10
path: app/design/frontend/base/default/template/checkout/multishipping/success.phtml

-
message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#'
identifier: method.nonObject
count: 4
path: app/design/frontend/base/default/template/checkout/onepage/billing.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
Expand Down Expand Up @@ -6576,42 +6546,6 @@ parameters:
count: 4
path: app/design/frontend/base/default/template/customer/balance.phtml

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 1
path: app/design/frontend/base/default/template/customer/form/address.phtml

-
message: '#^Variable \$address might not be defined\.$#'
identifier: variable.undefined
count: 2
path: app/design/frontend/base/default/template/customer/form/address.phtml

-
message: '#^Variable \$countries might not be defined\.$#'
identifier: variable.undefined
count: 1
path: app/design/frontend/base/default/template/customer/form/address.phtml

-
message: '#^Variable \$data might not be defined\.$#'
identifier: variable.undefined
count: 12
path: app/design/frontend/base/default/template/customer/form/address.phtml

-
message: '#^Variable \$primaryTypes might not be defined\.$#'
identifier: variable.undefined
count: 1
path: app/design/frontend/base/default/template/customer/form/address.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 50
path: app/design/frontend/base/default/template/customer/form/address.phtml

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
Expand All @@ -6633,7 +6567,7 @@ parameters:
-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 36
count: 23
path: app/design/frontend/base/default/template/customer/form/edit.phtml

-
Expand All @@ -6648,12 +6582,6 @@ parameters:
count: 16
path: app/design/frontend/base/default/template/customer/form/newsletter.phtml

-
message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#'
identifier: method.nonObject
count: 3
path: app/design/frontend/base/default/template/customer/form/register.phtml

-
message: '#^PHPDoc tag @var contains unresolvable type\.$#'
identifier: varTag.unresolvableType
Expand Down Expand Up @@ -7572,42 +7500,6 @@ parameters:
count: 3
path: app/design/frontend/rwd/default/template/customer/account/navigation.phtml

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
count: 1
path: app/design/frontend/rwd/default/template/customer/form/address.phtml

-
message: '#^Variable \$address might not be defined\.$#'
identifier: variable.undefined
count: 2
path: app/design/frontend/rwd/default/template/customer/form/address.phtml

-
message: '#^Variable \$countries might not be defined\.$#'
identifier: variable.undefined
count: 1
path: app/design/frontend/rwd/default/template/customer/form/address.phtml

-
message: '#^Variable \$data might not be defined\.$#'
identifier: variable.undefined
count: 12
path: app/design/frontend/rwd/default/template/customer/form/address.phtml

-
message: '#^Variable \$primaryTypes might not be defined\.$#'
identifier: variable.undefined
count: 1
path: app/design/frontend/rwd/default/template/customer/form/address.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 51
path: app/design/frontend/rwd/default/template/customer/form/address.phtml

-
message: '#^Variable \$action might not be defined\.$#'
identifier: variable.undefined
Expand All @@ -7626,12 +7518,6 @@ parameters:
count: 13
path: app/design/frontend/rwd/default/template/customer/form/confirmation.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
count: 36
path: app/design/frontend/rwd/default/template/customer/form/edit.phtml

-
message: '#^Variable \$this might not be defined\.$#'
identifier: variable.undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function preDispatch()

// For backwards compatibility set camelCase registry key with type id
Mage::register('entityType', $this->entityType->getEntityTypeId());

return $this;
}

#[\Override]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
/** @var Mage_Eav_Model_Entity_Attribute $_attribute */
/** @var ?Mage_Eav_Model_Entity_Attribute $_attribute */
protected $_attribute = null;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
/** @var Mage_Eav_Model_Entity_Attribute $_attribute */
/** @var ?Mage_Eav_Model_Entity_Attribute $_attribute */
protected $_attribute = null;

public function __construct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public function __construct()

/**
* Check "Use default" checkbox display availability
*
* @return bool
*/
protected function canDisplayUseDefault()
public function canDisplayUseDefault(): bool
{
$attributeObject = $this->getElement()->getForm()->getDataObject();
if ($attributeObject->getWebsite() && (int)$attributeObject->getWebsite()->getId()) {
Expand All @@ -40,10 +38,8 @@ protected function canDisplayUseDefault()

/**
* Check default value usage fact
*
* @return bool
*/
protected function usedDefault()
public function usedDefault(): bool
{
$field = $this->getElement()->getId();
if (str_starts_with($field, 'default_value')) {
Expand All @@ -55,10 +51,8 @@ protected function usedDefault()

/**
* Disable field in default value using case
*
* @return $this
*/
public function checkFieldDisable()
public function checkFieldDisable(): self
{
if ($this->canDisplayUseDefault() && $this->usedDefault()) {
$this->getElement()->setDisabled(true);
Expand All @@ -70,10 +64,8 @@ public function checkFieldDisable()
* Retrieve label of attribute scope
*
* GLOBAL | WEBSITE
*
* @return string
*/
protected function getScopeLabel()
public function getScopeLabel(): string
{
$html = '';
if (Mage::app()->isSingleStoreMode()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function getGroupTree(): array
->setSortOrder()
->load();

/** @var Mage_Eav_Model_Entity_Attribute_Group $node */
/** @var Mage_Eav_Model_Entity_Attribute_Group $group */
foreach ($groups as $group) {
$item = [];
$item['text'] = $group->getAttributeGroupName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
* @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/

/** @var Mage_Adminhtml_Block_Website_Switcher $this */
?>
<?php /* @var $this Mage_Core_Block_Template */ ?>
<?php if ($websites = $this->getWebsites()): ?>
<p class="switcher"><label for="website_switcher"><?= $this->escapeHtml($this->getLabel()) ?></label>
<select name="website_switcher" id="website_switcher" onchange="return switchWebsite(this);">
Expand Down

0 comments on commit 2b5c4d0

Please sign in to comment.