Skip to content

Commit

Permalink
array_push(...) calls behaving as '$array[] = ...', $array[] = works …
Browse files Browse the repository at this point in the history
…faster than invoking functions in PHP
  • Loading branch information
lfluvisotto committed Jun 19, 2018
1 parent b8528ae commit a34c148
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ protected function orderCountryOptions(array $countryOptions)
]];
foreach ($countryOptions as $countryOption) {
if (empty($countryOption['value']) || in_array($countryOption['value'], $this->topCountryCodes)) {
array_push($headOptions, $countryOption);
$headOptions[] = $countryOption;
} else {
array_push($tailOptions, $countryOption);
$tailOptions[] = $countryOption;
}
}
return array_merge($headOptions, $tailOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ private function orderCountryOptions(array $countryOptions)
]];
foreach ($countryOptions as $countryOption) {
if (empty($countryOption['value']) || in_array($countryOption['value'], $topCountryCodes)) {
array_push($headOptions, $countryOption);
$headOptions[] = $countryOption;
} else {
array_push($tailOptions, $countryOption);
$tailOptions[] = $countryOption;
}
}
return array_merge($headOptions, $tailOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function buildMap($filePath, $packagePath, $contentType)
if (!isset($this->map[$filePath])) {
$this->map[$filePath] = [];
}
array_push($this->map[$filePath], $resolvedMapPath);
$this->map[$filePath][] = $resolvedMapPath;
$this->buildMap($resolvedMapPath, $packagePath, $contentType);
};
if ($content) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/ImportExport/Model/Report/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function createReport(
$outputCsv = $this->createOutputCsvModel($outputFileName);

$columnsName = $sourceCsv->getColNames();
array_push($columnsName, self::REPORT_ERROR_COLUMN_NAME);
$columnsName[] = self::REPORT_ERROR_COLUMN_NAME;
$outputCsv->setHeaderCols($columnsName);

foreach ($sourceCsv as $rowNum => $rowData) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Quote/Model/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ public function getErrors()
foreach ($this->getMessages() as $message) {
/* @var $error \Magento\Framework\Message\AbstractMessage */
if ($message->getType() == \Magento\Framework\Message\MessageInterface::TYPE_ERROR) {
array_push($errors, $message);
$errors[] = $message;
}
}
return $errors;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/SalesRule/Model/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public function sortItemsByPriority($items, Address $address = null)
foreach ($items as $itemKey => $itemValue) {
if ($rule->getActions()->validate($itemValue)) {
unset($items[$itemKey]);
array_push($itemsSorted, $itemValue);
$itemsSorted[] = $itemValue;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ protected function parse($filterString)
}
switch ($filterString[$position]) {
case '[':
array_push($parent, $currentElement);
$parent[] = $currentElement;
// push current field in stack and initialize current
array_push($stack, $current);
$stack[] = $current;
$current = [];
break;

Expand Down
4 changes: 2 additions & 2 deletions setup/src/Magento/Setup/Module/Dependency/Circular.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected function buildCircular($modules)
return;
}
$this->circularDependencies[$path] = $modules;
array_push($modules, array_shift($modules));
$modules[] = array_shift($modules);
$this->buildCircular($modules);
}

Expand All @@ -133,7 +133,7 @@ protected function divideByModules($circularDependencies)
$dependenciesByModule = [];
foreach ($circularDependencies as $circularDependency) {
$module = $circularDependency[0];
array_push($circularDependency, $module);
$circularDependency[] = $module;
$dependenciesByModule[$module][] = $circularDependency;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ protected function _collectEntitiesFromString($content)
$attributes = $entityNode->attributes;
$type = $attributes->getNamedItem('type');
if ($type !== null) {
array_push($output, $type->nodeValue);
$output[] = $type->nodeValue;
} else {
array_push($output, $attributes->getNamedItem('name')->nodeValue);
$output[] = $attributes->getNamedItem('name')->nodeValue;
}
}
return $output;
Expand Down Expand Up @@ -80,7 +80,7 @@ protected function _filterEntities(array $output)
$this->_handleControllerClassName($entityName);
}
if (class_exists($entityName) || interface_exists($entityName)) {
array_push($filteredEntities, $entityName . '\\Interceptor');
$filteredEntities[] = $entityName . '\\Interceptor';
}
}
return $filteredEntities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function _filterEntities(array $output)
}
if (false === $isClassExists) {
if (class_exists($entityName) || interface_exists($entityName)) {
array_push($filteredEntities, $className);
$filteredEntities[] = $className;
} else {
$this->_log->add(
\Magento\Setup\Module\Di\Compiler\Log\Log::CONFIGURATION_ERROR,
Expand Down

0 comments on commit a34c148

Please # to comment.