Skip to content

Commit

Permalink
Fix some PHPStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbeaty committed Jul 13, 2022
1 parent 98a5a48 commit 95e498d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 46 deletions.
14 changes: 0 additions & 14 deletions app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,6 @@ protected function _prepareForm()
'class' => 'validate-digits',
));

$fieldset->addField('is_wysiwyg_enabled', 'select', array(
'name' => 'is_wysiwyg_enabled',
'label' => Mage::helper('eav')->__('Enable WYSIWYG'),
'title' => Mage::helper('eav')->__('Enable WYSIWYG'),
'values' => $yesnoSource,
));

// define field dependencies
$this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
->addFieldMap("is_wysiwyg_enabled", 'wysiwyg_enabled')
->addFieldMap("frontend_input", 'frontend_input_type')
->addFieldDependence('wysiwyg_enabled', 'frontend_input_type', 'textarea')
);

Mage::dispatchEvent("adminhtml_{$attributeObject->getEntityTypeCode()}_attribute_edit_prepare_form", array(
'form' => $form,
'attribute' => $attributeObject
Expand Down
5 changes: 3 additions & 2 deletions app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class Mage_Eav_Block_Adminhtml_Attribute_Grid extends Mage_Eav_Block_Adminhtml_A
protected function _prepareCollection()
{
if ($entity_type = Mage::registry('entity_type')) {
$collection = Mage::getResourceModel($entity_type->getEntityAttributeCollection())
->setEntityTypeFilter($entity_type->getEntityTypeId());
/** @var Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection */
$collection = Mage::getResourceModel($entity_type->getEntityAttributeCollection());
$collection->setEntityTypeFilter($entity_type->getEntityTypeId());
$this->setCollection($collection);
}
return parent::_prepareCollection();
Expand Down
33 changes: 18 additions & 15 deletions app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ public function getGroupTreeJson()
$item['allowDrop'] = true;
$item['allowDrag'] = true;

$nodeChildren = Mage::getResourceModel($entity_type->getEntityAttributeCollection())
->setEntityTypeFilter($entity_type->getEntityTypeId())
->setAttributeGroupFilter($node->getId())
->load();
/** @var Mage_Eav_Model_Entity_Attribute $nodeChildren */
$nodeChildren = Mage::getResourceModel($entity_type->getEntityAttributeCollection());
$nodeChildren->setEntityTypeFilter($entity_type->getEntityTypeId())
->setAttributeGroupFilter($node->getId())
->load();

if ($nodeChildren->getSize() > 0) {
$item['children'] = array();
Expand Down Expand Up @@ -234,22 +235,24 @@ public function getAttributeTreeJson()
/* @var $entity_type Mage_Eav_Model_Entity_Type */
$entity_type = Mage::registry('entity_type');

$collection = Mage::getResourceModel($entity_type->getEntityAttributeCollection())
->setEntityTypeFilter($entity_type->getEntityTypeId())
->setAttributeSetFilter($setId)
->load();
/** @var Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection */
$collection = Mage::getResourceModel($entity_type->getEntityAttributeCollection());
$collection->setEntityTypeFilter($entity_type->getEntityTypeId())
->setAttributeSetFilter($setId)
->load();

$attributesIds = array('0');
/* @var $item Mage_Eav_Model_Entity_Attribute */
foreach ($collection->getItems() as $item) {
$attributesIds[] = $item->getAttributeId();
}

$attributes = Mage::getResourceModel($entity_type->getEntityAttributeCollection())
->setEntityTypeFilter($entity_type->getEntityTypeId())
->setAttributesExcludeFilter($attributesIds)
->setOrder('attribute_code', 'asc')
->load();
/** @var Mage_Eav_Model_Resource_Entity_Attribute_Collection $attributes */
$attributes = Mage::getResourceModel($entity_type->getEntityAttributeCollection());
$attributes->setEntityTypeFilter($entity_type->getEntityTypeId())
->setAttributesExcludeFilter($attributesIds)
->setOrder('attribute_code', 'asc')
->load();

foreach ($attributes as $child) {
$attr = array(
Expand Down Expand Up @@ -355,7 +358,7 @@ public function getRenameButton()
/**
* Retrieve current Attribute Set object
*
* @return Mage_Eav_Model_Entity_Set
* @return Mage_Eav_Model_Entity_Attribute_Set
*/
protected function _getAttributeSet()
{
Expand Down Expand Up @@ -392,7 +395,7 @@ public function getIsCurrentSetDefault()
* Retrieve current Attribute Set object
*
* @deprecated use _getAttributeSet
* @return Mage_Eav_Model_Entity_Set
* @return Mage_Eav_Model_Entity_Attribute_Set
*/
protected function _getSetData()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ protected function _prepareForm()
'value' => '1'
));

$sets = Mage::getModel('eav/entity_attribute_set')
->getResourceCollection()
->setEntityTypeFilter(Mage::registry('entity_type')->getEntityTypeId())
/** @var Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection @collection */
$collection = Mage::getModel('eav/entity_attribute_set')
->getResourceCollection();

$sets = $collection->setEntityTypeFilter(Mage::registry('entity_type')->getEntityTypeId())
->setOrder('attribute_set_name', 'asc')
->load()
->toOptionArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
class Mage_Eav_Adminhtml_Attribute_AbstractController extends Mage_Adminhtml_Controller_Action
{

/* @var $_entityCode string */
/** @var string $_entityCode */
protected $_entityCode;

/* @var $_entityType Mage_Eav_Model_Entity_Type */
/** @var Mage_Eav_Model_Entity_Type $_entityType */
protected $_entityType;

/**
Expand Down Expand Up @@ -133,8 +133,10 @@ public function validateAction()

$attributeCode = $this->getRequest()->getParam('attribute_code');
$attributeId = $this->getRequest()->getParam('attribute_id');
$attribute = Mage::getModel($this->_entityType->getAttributeModel())
->loadByCode($this->_entityType->getEntityTypeId(), $attributeCode);

/** @var Mage_Eav_Model_Entity_Attribute $attribute */
$attribute = Mage::getModel($this->_entityType->getAttributeModel());
$attribute->loadByCode($this->_entityType->getEntityTypeId(), $attributeCode);

if ($attribute->getId() && !$attributeId) {
Mage::getSingleton('adminhtml/session')->addError(
Expand Down Expand Up @@ -183,9 +185,9 @@ public function saveAction()
$session = Mage::getSingleton('adminhtml/session');

$redirectBack = $this->getRequest()->getParam('back', false);
/* @var $model Mage_Eav_Model_Entity_Attribute */
/** @var Mage_Eav_Model_Entity_Attribute $model */
$model = Mage::getModel($this->_entityType->getAttributeModel());
/* @var $helper Mage_Eav_Helper_Data */
/** @var Mage_Eav_Helper_Data $helper */
$helper = Mage::helper('eav');

$id = $this->getRequest()->getParam('attribute_id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
class Mage_Eav_Adminhtml_Set_AbstractController extends Mage_Adminhtml_Controller_Action
{

/* @var $_entityCode string */
/** @var string $_entityCode */
protected $_entityCode;

/* @var $_entityType Mage_Eav_Model_Entity_Type */
/** @var Mage_Eav_Model_Entity_Type $_entityType */
protected $_entityType;

/**
Expand Down Expand Up @@ -111,12 +111,12 @@ public function saveAction()
$attributeSetId = $this->getRequest()->getParam('id', false);
$isNewSet = $this->getRequest()->getParam('gotoEdit', false) == '1';

/* @var $model Mage_Eav_Model_Entity_Attribute_Set */
/** @var Mage_Eav_Model_Entity_Attribute_Set $model */
$model = Mage::getModel('eav/entity_attribute_set')
->setEntityTypeId($entityTypeId);
->setEntityTypeId($entityTypeId);

/** @var $helper Mage_Adminhtml_Helper_Data */
$helper = Mage::helper('adminhtml');
/** @var Mage_Eav_Helper_Data $helper */
$helper = Mage::helper('eav');

try {
if ($isNewSet) {
Expand Down

0 comments on commit 95e498d

Please sign in to comment.