From 31d159778d0dfcccc42ac590022912a736d7d6d4 Mon Sep 17 00:00:00 2001 From: "Leandro F. L" Date: Thu, 14 Jun 2018 22:05:45 +0200 Subject: [PATCH] array_push(...) calls behaving as '$array[] = ...', $array[] = works faster than invoking functions in PHP --- .../Magento/Checkout/Block/Checkout/AttributeMerger.php | 4 ++-- .../Checkout/Block/Checkout/DirectoryDataProcessor.php | 4 ++-- .../Magento/Deploy/Package/Processor/PreProcessor/Less.php | 2 +- app/code/Magento/ImportExport/Model/Report/Csv.php | 2 +- app/code/Magento/Quote/Model/Quote.php | 2 +- app/code/Magento/SalesRule/Model/Validator.php | 2 +- .../Magento/Framework/Webapi/Rest/Response/FieldsFilter.php | 4 ++-- setup/src/Magento/Setup/Module/Dependency/Circular.php | 4 ++-- .../Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php | 6 +++--- .../src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php index d93475a4744ca..de996bed02439 100644 --- a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php +++ b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php @@ -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); diff --git a/app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php b/app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php index 1d5bb5bb07d81..587dd06d89106 100644 --- a/app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php @@ -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); diff --git a/app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php b/app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php index 8a464ca4bc627..b5fe0c78640e5 100644 --- a/app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php +++ b/app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php @@ -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) { diff --git a/app/code/Magento/ImportExport/Model/Report/Csv.php b/app/code/Magento/ImportExport/Model/Report/Csv.php index 86c68d7c4df77..7279092265cbb 100644 --- a/app/code/Magento/ImportExport/Model/Report/Csv.php +++ b/app/code/Magento/ImportExport/Model/Report/Csv.php @@ -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) { diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index dca9aa36fb25d..dcadcde292500 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -2022,7 +2022,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; diff --git a/app/code/Magento/SalesRule/Model/Validator.php b/app/code/Magento/SalesRule/Model/Validator.php index 197b7366a8b8d..201df99aa5187 100644 --- a/app/code/Magento/SalesRule/Model/Validator.php +++ b/app/code/Magento/SalesRule/Model/Validator.php @@ -508,7 +508,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; } } } diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php b/lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php index 9b50b45a9215c..87be46c111545 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Response/FieldsFilter.php @@ -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; diff --git a/setup/src/Magento/Setup/Module/Dependency/Circular.php b/setup/src/Magento/Setup/Module/Dependency/Circular.php index 8f5bd8716f650..a10d2752fa410 100644 --- a/setup/src/Magento/Setup/Module/Dependency/Circular.php +++ b/setup/src/Magento/Setup/Module/Dependency/Circular.php @@ -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); } @@ -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; } diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php index e88ca9197096a..75c6e1144e8d2 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlInterceptorScanner.php @@ -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; @@ -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; diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php index 6a798f3226570..39d764cc32ce8 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/XmlScanner.php @@ -72,7 +72,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,