Skip to content

Commit a34c148

Browse files
committed
array_push(...) calls behaving as '$array[] = ...', $array[] = works faster than invoking functions in PHP
1 parent b8528ae commit a34c148

File tree

10 files changed

+16
-16
lines changed

10 files changed

+16
-16
lines changed

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ protected function orderCountryOptions(array $countryOptions)
394394
]];
395395
foreach ($countryOptions as $countryOption) {
396396
if (empty($countryOption['value']) || in_array($countryOption['value'], $this->topCountryCodes)) {
397-
array_push($headOptions, $countryOption);
397+
$headOptions[] = $countryOption;
398398
} else {
399-
array_push($tailOptions, $countryOption);
399+
$tailOptions[] = $countryOption;
400400
}
401401
}
402402
return array_merge($headOptions, $tailOptions);

app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ private function orderCountryOptions(array $countryOptions)
141141
]];
142142
foreach ($countryOptions as $countryOption) {
143143
if (empty($countryOption['value']) || in_array($countryOption['value'], $topCountryCodes)) {
144-
array_push($headOptions, $countryOption);
144+
$headOptions[] = $countryOption;
145145
} else {
146-
array_push($tailOptions, $countryOption);
146+
$tailOptions[] = $countryOption;
147147
}
148148
}
149149
return array_merge($headOptions, $tailOptions);

app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function buildMap($filePath, $packagePath, $contentType)
188188
if (!isset($this->map[$filePath])) {
189189
$this->map[$filePath] = [];
190190
}
191-
array_push($this->map[$filePath], $resolvedMapPath);
191+
$this->map[$filePath][] = $resolvedMapPath;
192192
$this->buildMap($resolvedMapPath, $packagePath, $contentType);
193193
};
194194
if ($content) {

app/code/Magento/ImportExport/Model/Report/Csv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function createReport(
7777
$outputCsv = $this->createOutputCsvModel($outputFileName);
7878

7979
$columnsName = $sourceCsv->getColNames();
80-
array_push($columnsName, self::REPORT_ERROR_COLUMN_NAME);
80+
$columnsName[] = self::REPORT_ERROR_COLUMN_NAME;
8181
$outputCsv->setHeaderCols($columnsName);
8282

8383
foreach ($sourceCsv as $rowNum => $rowData) {

app/code/Magento/Quote/Model/Quote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ public function getErrors()
20212021
foreach ($this->getMessages() as $message) {
20222022
/* @var $error \Magento\Framework\Message\AbstractMessage */
20232023
if ($message->getType() == \Magento\Framework\Message\MessageInterface::TYPE_ERROR) {
2024-
array_push($errors, $message);
2024+
$errors[] = $message;
20252025
}
20262026
}
20272027
return $errors;

app/code/Magento/SalesRule/Model/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ public function sortItemsByPriority($items, Address $address = null)
506506
foreach ($items as $itemKey => $itemValue) {
507507
if ($rule->getActions()->validate($itemValue)) {
508508
unset($items[$itemKey]);
509-
array_push($itemsSorted, $itemValue);
509+
$itemsSorted[] = $itemValue;
510510
}
511511
}
512512
}

lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ protected function parse($filterString)
106106
}
107107
switch ($filterString[$position]) {
108108
case '[':
109-
array_push($parent, $currentElement);
109+
$parent[] = $currentElement;
110110
// push current field in stack and initialize current
111-
array_push($stack, $current);
111+
$stack[] = $current;
112112
$current = [];
113113
break;
114114

setup/src/Magento/Setup/Module/Dependency/Circular.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected function buildCircular($modules)
118118
return;
119119
}
120120
$this->circularDependencies[$path] = $modules;
121-
array_push($modules, array_shift($modules));
121+
$modules[] = array_shift($modules);
122122
$this->buildCircular($modules);
123123
}
124124

@@ -133,7 +133,7 @@ protected function divideByModules($circularDependencies)
133133
$dependenciesByModule = [];
134134
foreach ($circularDependencies as $circularDependency) {
135135
$module = $circularDependency[0];
136-
array_push($circularDependency, $module);
136+
$circularDependency[] = $module;
137137
$dependenciesByModule[$module][] = $circularDependency;
138138
}
139139

setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ protected function _collectEntitiesFromString($content)
4242
$attributes = $entityNode->attributes;
4343
$type = $attributes->getNamedItem('type');
4444
if ($type !== null) {
45-
array_push($output, $type->nodeValue);
45+
$output[] = $type->nodeValue;
4646
} else {
47-
array_push($output, $attributes->getNamedItem('name')->nodeValue);
47+
$output[] = $attributes->getNamedItem('name')->nodeValue;
4848
}
4949
}
5050
return $output;
@@ -80,7 +80,7 @@ protected function _filterEntities(array $output)
8080
$this->_handleControllerClassName($entityName);
8181
}
8282
if (class_exists($entityName) || interface_exists($entityName)) {
83-
array_push($filteredEntities, $entityName . '\\Interceptor');
83+
$filteredEntities[] = $entityName . '\\Interceptor';
8484
}
8585
}
8686
return $filteredEntities;

setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function _filterEntities(array $output)
104104
}
105105
if (false === $isClassExists) {
106106
if (class_exists($entityName) || interface_exists($entityName)) {
107-
array_push($filteredEntities, $className);
107+
$filteredEntities[] = $className;
108108
} else {
109109
$this->_log->add(
110110
\Magento\Setup\Module\Di\Compiler\Log\Log::CONFIGURATION_ERROR,

0 commit comments

Comments
 (0)