Skip to content

Commit

Permalink
Replace alias methods (#1394)
Browse files Browse the repository at this point in the history
- join vs implode
- is_integer vs is_int
- ...
  • Loading branch information
sreichel authored Mar 11, 2021
1 parent 419518e commit 7526749
Show file tree
Hide file tree
Showing 74 changed files with 122 additions and 122 deletions.
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public function getStartupPageUrl()
$startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE);
$aclResource = 'admin/' . $startupPage;
if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) {
$nodePath = 'menu/' . join('/children/', explode('/', $startupPage)) . '/action';
$nodePath = 'menu/' . implode('/children/', explode('/', $startupPage)) . '/action';
$url = (string)Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode($nodePath);
if ($url) {
return $url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
}
}
}
$defText = join(', ', $defTextArr);
$defText = implode(', ', $defTextArr);
}

// default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function _prepareRates($array)
$parts = explode('.', $value);
if( count($parts) === 2 ) {
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
$array[$key][$code] = join('.', $parts);
$array[$key][$code] = implode('.', $parts);
} elseif( $value > 0 ) {
$array[$key][$code] = number_format($value, 4);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/System/Store/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getGridHtml()
*/
public function getAddNewButtonHtml()
{
return join(' ', array(
return implode(' ', array(
$this->getChildHtml('add_new_website'),
$this->getChildHtml('add_new_group'),
$this->getChildHtml('add_new_store')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function render(Varien_Object $row)
$dataArr[] = $data;
}
}
$data = join($this->getColumn()->getSeparator(), $dataArr);
$data = implode($this->getColumn()->getSeparator(), $dataArr);
// TODO run column type renderer
return $data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function getSelectedJson()
{
if($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $this->quoteEscape($selected));
return join(',', $selected);
return implode(',', $selected);
} else {
return '';
}
Expand Down Expand Up @@ -243,7 +243,7 @@ public function getGridIdsJson()
$gridIds = $this->getParentBlock()->getCollection()->getAllIds();

if(!empty($gridIds)) {
return join(",", $gridIds);
return implode(",", $gridIds);
}
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function _afterSave()
}

if ($exceptions) {
Mage::throwException(join("\n", $exceptions));
Mage::throwException(implode("\n", $exceptions));
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function _afterSave()
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);

try {
Mage::getModel('core/config_data')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function _afterSave()
}
}
if ($exceptions) {
Mage::throwException(join("\n", $exceptions));
Mage::throwException(implode("\n", $exceptions));
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function _afterSave()
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);
$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);
}
else {
$cronExprString = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function _afterSave()
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);

try {
Mage::getModel('core/config_data')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function _afterSave()
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);

try {
Mage::getModel('core/config_data')
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Backup/Model/Config/Backend/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function _afterSave()
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);
$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);
}
else {
$cronExprString = '';
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Backup/Model/Resource/Helper/Mysql4.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function _buildForeignKeysAlterTableSql($tableName, $foreignKeys)

return sprintf("ALTER TABLE %s\n %s;\n",
$this->_getReadAdapter()->quoteIdentifier($tableName),
join(",\n ", $foreignKeys)
implode(",\n ", $foreignKeys)
);
}

Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Bundle/Model/Resource/Price/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function getProducts($product = null, $lastEntityId = 0, $limit = 100)

$select->joinLeft(
array($priceTypeAlias => $priceType->getBackend()->getTable()),
join(' AND ', $joinConds),
implode(' AND ', $joinConds),
array('price_type' => $priceTypeAlias . '.value')
);

Expand Down Expand Up @@ -770,7 +770,7 @@ public function _calculateBundleSelections(

// calculate selection price
if ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
$priceIndexKey = join('-', array(
$priceIndexKey = implode('-', array(
$selection['product_id'],
$website->getId(),
$group->getId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
$applyTo = explode(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
if (!in_array('bundle', $applyTo)) {
$applyTo[] = 'bundle';
$installer->updateAttribute('catalog_product', $field, 'apply_to', join(',', $applyTo));
$installer->updateAttribute('catalog_product', $field, 'apply_to', implode(',', $applyTo));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Block/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function _prepareLayout()
}

if ($headBlock = $this->getLayout()->getBlock('head')) {
$headBlock->setTitle(join($this->getTitleSeparator(), array_reverse($title)));
$headBlock->setTitle(implode($this->getTitleSeparator(), array_reverse($title)));
}
}
return parent::_prepareLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function beforeSave($object)
if (!is_array($data)) {
$data = array();
}
$object->setData($attributeCode, join(',', $data));
$object->setData($attributeCode, implode(',', $data));
}
if (is_null($object->getData($attributeCode))) {
$object->setData($attributeCode, false);
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public function unparse()
$product->getAttributeSetId()
),
'type' => $product->getTypeId(),
'category_ids' => join(',', $product->getCategoryIds())
'category_ids' => implode(',', $product->getCategoryIds())
);

if ($this->getStore()->getCode() == Mage_Core_Model_Store::ADMIN_CODE) {
Expand All @@ -449,7 +449,7 @@ public function unparse()
$websiteCode = Mage::app()->getWebsite($websiteId)->getCode();
$websiteCodes[$websiteCode] = $websiteCode;
}
$row['websites'] = join(',', $websiteCodes);
$row['websites'] = implode(',', $websiteCodes);
} else {
$row['websites'] = $this->getStore()->getWebsite()->getCode();
if ($this->getVar('url_field')) {
Expand Down Expand Up @@ -477,7 +477,7 @@ public function unparse()
continue;
}
if (is_array($option)) {
$value = join(self::MULTI_DELIMITER, $option);
$value = implode(self::MULTI_DELIMITER, $option);
} else {
$value = $option;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function validate($object)
if (!empty($priceRow['delete'])) {
continue;
}
$compare = join('-', array_merge(
$compare = implode('-', array_merge(
array($priceRow['website_id'], $priceRow['cust_group']),
$this->_getAdditionalUniqueFields($priceRow)
));
Expand All @@ -145,7 +145,7 @@ public function validate($object)
$origGroupPrices = $object->getOrigData($attribute->getName());
foreach ($origGroupPrices as $price) {
if ($price['website_id'] == 0) {
$compare = join('-', array_merge(
$compare = implode('-', array_merge(
array($price['website_id'], $price['cust_group']),
$this->_getAdditionalUniqueFields($price)
));
Expand All @@ -165,7 +165,7 @@ public function validate($object)
continue;
}

$globalCompare = join('-', array_merge(
$globalCompare = implode('-', array_merge(
array(0, $priceRow['cust_group']),
$this->_getAdditionalUniqueFields($priceRow)
));
Expand Down Expand Up @@ -193,7 +193,7 @@ public function preparePriceData(array $priceData, $productTypeId, $websiteId)
$data = array();
$price = Mage::getSingleton('catalog/product_type')->priceFactory($productTypeId);
foreach ($priceData as $v) {
$key = join('-', array_merge(array($v['cust_group']), $this->_getAdditionalUniqueFields($v)));
$key = implode('-', array_merge(array($v['cust_group']), $this->_getAdditionalUniqueFields($v)));
if ($v['website_id'] == $websiteId) {
$data[$key] = $v;
$data[$key]['website_price'] = $v['price'];
Expand Down Expand Up @@ -280,7 +280,7 @@ public function afterSave($object)
}
foreach ($origGroupPrices as $data) {
if ($data['website_id'] > 0 || ($data['website_id'] == '0' && $isGlobal)) {
$key = join('-', array_merge(
$key = implode('-', array_merge(
array($data['website_id'], $data['cust_group']),
$this->_getAdditionalUniqueFields($data)
));
Expand Down Expand Up @@ -308,7 +308,7 @@ public function afterSave($object)
continue;
}

$key = join('-', array_merge(
$key = implode('-', array_merge(
array($data['website_id'], $data['cust_group']),
$this->_getAdditionalUniqueFields($data)
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected function _prepareOption($optionId, $store = null)
{
/** @var Mage_Catalog_Model_Product_Option $option */
$option = Mage::getModel('catalog/product_option');
if (is_string($store) || is_integer($store)) {
if (is_string($store) || is_int($store)) {
$storeId = $this->_getStoreId($store);
$option->setStoreId($storeId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public function addPathsFilter($paths)
$cond[] = $this->getResource()->getReadConnection()->quoteInto('e.path LIKE ?', "$path%");
}
if ($cond) {
$this->getSelect()->where(join(' OR ', $cond));
$this->getSelect()->where(implode(' OR ', $cond));
}
return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ public function move(array $affectedCategoryIds)
}

$stores = $this->getStoresRootCategories();
$where = join(' OR ', $pathCond);
$where = implode(' OR ', $pathCond);
$lastId = 0;
while (true) {
$select = $write->select()
Expand Down Expand Up @@ -1167,7 +1167,7 @@ protected function _prepareDataForAllFields($category, $replaceFields = array())
$idFieldName = Mage::getSingleton('catalog/category')->getIdFieldName();
foreach ($table as $column => $columnData) {
if ($column != $idFieldName || null !== $category->getData($column)) {
if (key_exists($column, $replaceFields)) {
if (array_key_exists($column, $replaceFields)) {
$value = $category->getData($replaceFields[$column]);
} else {
$value = $category->getData($column);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function addPathsFilter($paths)
$cond[] = $this->getResource()->getReadConnection()->quoteInto('main_table.path LIKE ?', "$path%");
}
if ($cond) {
$select->where(join(' OR ', $cond));
$select->where(implode(' OR ', $cond));
}
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getCount($filter)
$select
->join(
array($tableAlias => $this->getMainTable()),
join(' AND ', $conditions),
implode(' AND ', $conditions),
array('value', 'count' => new Zend_Db_Expr("COUNT({$tableAlias}.entity_id)"))
)
->group("{$tableAlias}.value");
Expand Down
18 changes: 9 additions & 9 deletions app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ protected function _preparePriceExpressionParameters($select)

Mage::dispatchEvent('catalog_prepare_price_select', $eventArgs);

$additional = join('', $response->getAdditionalCalculations());
$additional = implode('', $response->getAdditionalCalculations());
$this->_priceExpression = $table . '.min_price';
$this->_additionalPriceExpression = $additional;
$this->_catalogPreparePriceSelect = clone $select;
Expand Down Expand Up @@ -1399,7 +1399,7 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType =
foreach ($attribute as $condition) {
$sqlArr[] = $this->_getAttributeConditionSql($condition['attribute'], $condition, $joinType);
}
$conditionSql = '('.join(') OR (', $sqlArr).')';
$conditionSql = '(' . implode(') OR (', $sqlArr) . ')';
$this->getSelect()->where($conditionSql);
return $this;
}
Expand Down Expand Up @@ -1661,13 +1661,13 @@ protected function _productLimitationJoinWebsite()
if (!$joinWebsite) {
unset($fromPart['product_website']);
} else {
$fromPart['product_website']['joinCondition'] = join(' AND ', $conditions);
$fromPart['product_website']['joinCondition'] = implode(' AND ', $conditions);
}
$this->getSelect()->setPart(Zend_Db_Select::FROM, $fromPart);
} elseif ($joinWebsite) {
$this->getSelect()->join(
array('product_website' => $this->getTable('catalog/product_website')),
join(' AND ', $conditions),
implode(' AND ', $conditions),
array()
);
}
Expand Down Expand Up @@ -1716,7 +1716,7 @@ protected function _productLimitationJoinStore()
if (!isset($fromPart['store_cat_index'])) {
$this->getSelect()->joinLeft(
array('store_cat_index' => $this->getTable('catalog/category_product_index')),
join(' AND ', array(
implode(' AND ', array(
'store_cat_index.product_id = e.entity_id',
'store_cat_index.store_id = ' . $filters['store_table'] . '.store_id',
'store_cat_index.category_id=store_group_index.root_category_id'
Expand All @@ -1727,7 +1727,7 @@ protected function _productLimitationJoinStore()
// Avoid column duplication problems
Mage::getResourceHelper('core')->prepareColumnsList($this->getSelect());

$whereCond = join(' OR ', array(
$whereCond = implode(' OR ', array(
$this->getConnection()->quoteInto('cat_index.visibility IN(?)', $filters['visibility']),
$this->getConnection()->quoteInto('store_cat_index.visibility IN(?)', $filters['visibility'])
));
Expand Down Expand Up @@ -1776,7 +1776,7 @@ protected function _productLimitationPrice($joinLeft = false)
$helper = Mage::getResourceHelper('core');
$connection = $this->getConnection();
$select = $this->getSelect();
$joinCond = join(' AND ', array(
$joinCond = implode(' AND ', array(
'price_index.entity_id = e.entity_id',
$connection->quoteInto('price_index.website_id = ?', $filters['website_id']),
$connection->quoteInto('price_index.customer_group_id = ?', $filters['customer_group_id'])
Expand Down Expand Up @@ -1876,7 +1876,7 @@ protected function _applyProductLimitations()
->quoteInto('cat_index.is_parent=?', $filters['category_is_anchor']);
}

$joinCond = join(' AND ', $conditions);
$joinCond = implode(' AND ', $conditions);
$fromPart = $this->getSelect()->getPart(Zend_Db_Select::FROM);
if (isset($fromPart['cat_index'])) {
$fromPart['cat_index']['joinCondition'] = $joinCond;
Expand Down Expand Up @@ -1913,7 +1913,7 @@ protected function _applyZeroStoreProductLimitations()
'cat_pro.product_id=e.entity_id',
$this->getConnection()->quoteInto('cat_pro.category_id=?', $filters['category_id'])
);
$joinCond = join(' AND ', $conditions);
$joinCond = implode(' AND ', $conditions);

$fromPart = $this->getSelect()->getPart(Zend_Db_Select::FROM);
if (isset($fromPart['cat_pro'])) {
Expand Down
Loading

0 comments on commit 7526749

Please sign in to comment.