Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use short array syntax #2458

Merged
merged 1 commit into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Acl/Role/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function addParent($role, $parents)
}

if (!is_array($parents)) {
$parents = array($parents);
$parents = [$parents];
}
foreach ($parents as $parent) {
try {
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Admin/Model/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function _construct()
*/
public function validate()
{
$errors = array();
$errors = [];

if (!Zend_Validate::is($this->getBlockName(), 'NotEmpty')) {
$errors[] = Mage::helper('adminhtml')->__('Block Name is required field.');
Expand All @@ -58,11 +58,11 @@ public function validate()
if (in_array($this->getBlockName(), $disallowedBlockNames)) {
$errors[] = Mage::helper('adminhtml')->__('Block Name is disallowed.');
}
if (!Zend_Validate::is($this->getBlockName(), 'Regex', array('/^[-_a-zA-Z0-9]+\/[-_a-zA-Z0-9\/]+$/'))) {
if (!Zend_Validate::is($this->getBlockName(), 'Regex', ['/^[-_a-zA-Z0-9]+\/[-_a-zA-Z0-9\/]+$/'])) {
$errors[] = Mage::helper('adminhtml')->__('Block Name is incorrect.');
}

if (!in_array($this->getIsAllowed(), array('0', '1'))) {
if (!in_array($this->getIsAllowed(), ['0', '1'])) {
$errors[] = Mage::helper('adminhtml')->__('Is Allowed is required field.');
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct()
Mage::app()->saveCache(
$adminhtmlConfig->getXmlString(),
$this->getCacheId(),
array(Mage_Core_Model_Config::CACHE_TAG)
[Mage_Core_Model_Config::CACHE_TAG]
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function actionPreDispatchAdmin($observer)
$user = $session->getUser();

$requestedActionName = strtolower($request->getActionName());
$openActions = array(
$openActions = [
'forgotpassword',
'resetpassword',
'resetpasswordpost',
'logout',
'refresh' // captcha refresh
);
];
if (in_array($requestedActionName, $openActions)) {
$request->setDispatched(true);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Redirectpolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Mage_Admin_Model_Redirectpolicy
/**
* @param array $parameters array('urlModel' => object)
*/
public function __construct($parameters = array())
public function __construct($parameters = [])
{
$this->_urlModel = (!empty($parameters['urlModel'])) ?
$parameters['urlModel'] : Mage::getModel('adminhtml/url');
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Admin/Model/Resource/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public function loadAcl()
$this->loadRoles($acl, $rolesArr);

$select = $adapter->select()
->from(array('r' => $ruleTable))
->from(['r' => $ruleTable])
->joinLeft(
array('a' => $assertTable),
['a' => $assertTable],
'a.assert_id = r.assert_id',
array('assert_type', 'assert_data')
['assert_type', 'assert_data']
);

$rulesArr = $adapter->fetchAll($select);
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Admin/Model/Resource/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Mage_Admin_Model_Resource_Block extends Mage_Core_Model_Resource_Db_Abstra
*
* @var array
*/
protected $disallowedBlockNames = array('install/end');
protected $disallowedBlockNames = ['install/end'];

/**
* Define main table
Expand Down Expand Up @@ -69,17 +69,17 @@ protected function _generateCache()
{
/** @var Mage_Admin_Model_Resource_Block_Collection $collection */
$collection = Mage::getResourceModel('admin/block_collection');
$collection->addFieldToFilter('is_allowed', array('eq' => 1));
$collection->addFieldToFilter('is_allowed', ['eq' => 1]);
$disallowedBlockNames = $this->getDisallowedBlockNames();
if (is_array($disallowedBlockNames) && count($disallowedBlockNames) > 0) {
$collection->addFieldToFilter('block_name', array('nin' => $disallowedBlockNames));
$collection->addFieldToFilter('block_name', ['nin' => $disallowedBlockNames]);
}
$data = $collection->getColumnValues('block_name');
$data = array_flip($data);
Mage::app()->saveCache(
Mage::helper('core')->jsonEncode($data),
self::CACHE_ID,
array(Mage_Core_Model_App::CACHE_TAG)
[Mage_Core_Model_App::CACHE_TAG]
);
}

Expand Down
22 changes: 11 additions & 11 deletions app/code/core/Mage/Admin/Model/Resource/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ protected function _beforeSave(Mage_Core_Model_Abstract $role)

if ($role->getPid() > 0) {
$select = $this->_getReadAdapter()->select()
->from($this->getMainTable(), array('tree_level'))
->from($this->getMainTable(), ['tree_level'])
->where("{$this->getIdFieldName()} = :pid");

$binds = array(
$binds = [
'pid' => (int) $role->getPid(),
);
];

$treeLevel = $this->_getReadAdapter()->fetchOne($select, $binds);
} else {
Expand All @@ -99,7 +99,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $role)
$this->_updateRoleUsersAcl($role);
Mage::app()->getCache()->clean(
Zend_Cache::CLEANING_MODE_MATCHING_TAG,
array(Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS)
[Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS]
);
return $this;
}
Expand All @@ -116,12 +116,12 @@ protected function _afterDelete(Mage_Core_Model_Abstract $role)

$adapter->delete(
$this->getMainTable(),
array('parent_id = ?' => (int) $role->getId())
['parent_id = ?' => (int) $role->getId()]
);

$adapter->delete(
$this->_ruleTable,
array('role_id = ?' => (int) $role->getId())
['role_id = ?' => (int) $role->getId()]
);

return $this;
Expand All @@ -137,13 +137,13 @@ public function getRoleUsers(Mage_Admin_Model_Roles $role)
{
$read = $this->_getReadAdapter();

$binds = array(
$binds = [
'role_id' => $role->getId(),
'role_type' => 'U'
);
];

$select = $read->select()
->from($this->getMainTable(), array('user_id'))
->from($this->getMainTable(), ['user_id'])
->where('parent_id = :role_id')
->where('role_type = :role_type')
->where('user_id > 0');
Expand All @@ -164,8 +164,8 @@ private function _updateRoleUsersAcl(Mage_Admin_Model_Roles $role)
$rowsCount = 0;

if (count($users)) {
$bind = array('reload_acl_flag' => 1);
$where = array('user_id IN(?)' => $users);
$bind = ['reload_acl_flag' => 1];
$where = ['user_id IN(?)' => $users];
$rowsCount = $write->update($this->_usersTable, $bind, $where);
}

Expand Down
10 changes: 5 additions & 5 deletions app/code/core/Mage/Admin/Model/Resource/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,25 @@ public function saveRel(Mage_Admin_Model_Rules $rule)
$adapter->beginTransaction();
$roleId = $rule->getRoleId();

$condition = array(
$condition = [
'role_id = ?' => (int) $roleId,
);
];

$adapter->delete($this->getMainTable(), $condition);

$postedResources = $rule->getResources();
if ($postedResources) {
$row = array(
$row = [
'role_type' => 'G',
'resource_id' => 'all',
'privileges' => '', // not used yet
'assert_id' => 0,
'role_id' => $roleId,
'permission' => 'allow'
);
];

// If all was selected save it only and nothing else.
if ($postedResources === array('all')) {
if ($postedResources === ['all']) {
$insertData = $this->_prepareDataForTable(new Varien_Object($row), $this->getMainTable());

$adapter->insert($this->getMainTable(), $insertData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function addSortByLength()
*/
public function getResourcesPermissionsArray()
{
$resourcesPermissionsArray = array();
$resourcesPermissionsArray = [];
foreach ($this as $item) {
$resourcesPermissionsArray[$item->getResourceId()] = $item->getPermission();
}
Expand Down
Loading