From 57177db7885bf8da60e02ad181e70315208be1fa Mon Sep 17 00:00:00 2001 From: Leandro Ferraz Luvisotto Date: Tue, 17 Jul 2018 14:52:49 +0200 Subject: [PATCH] Array short syntax --- .../Catalog/Test/Unit/Model/ProductTest.php | 4 +-- .../Test/Unit/Model/ProductTest.php | 2 +- .../Module/Di/Code/Reader/FileScanner.php | 28 +++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index a2e9a8e5060cc..483283e777118 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -631,11 +631,11 @@ public function testReindex($productChanged, $isScheduled, $productFlatCount, $c */ public function getProductReindexProvider() { - return array( + return [ 'set 1' => [true, false, 1, 1], 'set 2' => [true, true, 1, 0], 'set 3' => [false, false, 1, 0] - ); + ]; } public function testPriceReindexCallback() diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php index 346ef3ecb9647..ec5eedacf730b 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php @@ -324,7 +324,7 @@ public function testGetProductLinks() $reflectionOfExtension = new \ReflectionClass(\Magento\Catalog\Api\Data\ProductLinkExtension::class); $method = $reflectionOfExtension->getMethod('setData'); $method->setAccessible(true); - $method->invokeArgs($groupExtension, array('qty', 1)); + $method->invokeArgs($groupExtension, ['qty', 1]); $outputGroupLink = $this->objectManagerHelper->getObject(\Magento\Catalog\Model\ProductLink\Link::class); $outputGroupLink->setProductSku("Simple Product 1"); diff --git a/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php index 2aea6a4dbc304..dd1e662ee168f 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php @@ -92,7 +92,7 @@ protected function scan() $MACRO_DOC_COMMENT_VALIDATE = function () use (&$docCommentIndex) { static $validTrailingTokens = null; if ($validTrailingTokens === null) { - $validTrailingTokens = array(T_WHITESPACE, T_FINAL, T_ABSTRACT, T_INTERFACE, T_CLASS, T_FUNCTION); + $validTrailingTokens = [T_WHITESPACE, T_FINAL, T_ABSTRACT, T_INTERFACE, T_CLASS, T_FUNCTION]; } if ($docCommentIndex !== false && !in_array($this->tokenType, $validTrailingTokens)) { $docCommentIndex = false; @@ -134,14 +134,14 @@ protected function scan() case T_NAMESPACE: - $infos[$infoIndex] = array( + $infos[$infoIndex] = [ 'type' => 'namespace', 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(), 'tokenEnd' => null, 'lineStart' => $token[2], 'lineEnd' => null, 'namespace' => null, - ); + ]; // start processing with next token if ($MACRO_TOKEN_ADVANCE() === false) { @@ -179,16 +179,15 @@ protected function scan() case T_USE: - $infos[$infoIndex] = array( + $infos[$infoIndex] = [ 'type' => 'use', 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(), 'tokenEnd' => null, 'lineStart' => $tokens[$tokenIndex][2], 'lineEnd' => null, 'namespace' => $namespace, - 'statements' => array(0 => array('use' => null, - 'as' => null)), - ); + 'statements' => [0 => ['use' => null, 'as' => null]], + ]; $useStatementIndex = 0; $useAsContext = false; @@ -206,8 +205,7 @@ protected function scan() } elseif ($tokenContent === ',') { $useAsContext = false; $useStatementIndex++; - $infos[$infoIndex]['statements'][$useStatementIndex] = array('use' => null, - 'as' => null); + $infos[$infoIndex]['statements'][$useStatementIndex] = ['use' => null, 'as' => null]; } } @@ -246,14 +244,14 @@ protected function scan() case T_REQUIRE_ONCE: // Static for performance - static $includeTypes = array( + static $includeTypes = [ T_INCLUDE => 'include', T_INCLUDE_ONCE => 'include_once', T_REQUIRE => 'require', T_REQUIRE_ONCE => 'require_once' - ); + ]; - $infos[$infoIndex] = array( + $infos[$infoIndex] = [ 'type' => 'include', 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(), 'tokenEnd' => null, @@ -261,7 +259,7 @@ protected function scan() 'lineEnd' => null, 'includeType' => $includeTypes[$tokens[$tokenIndex][0]], 'path' => '', - ); + ]; // start processing with next token if ($MACRO_TOKEN_ADVANCE() === false) { @@ -296,7 +294,7 @@ protected function scan() case T_INTERFACE: case T_TRAIT: - $infos[$infoIndex] = array( + $infos[$infoIndex] = [ 'type' => ($this->tokenType === T_FUNCTION) ? 'function' : 'class', 'tokenStart' => $MACRO_TOKEN_LOGICAL_START_INDEX(), 'tokenEnd' => null, @@ -306,7 +304,7 @@ protected function scan() 'uses' => $this->getUsesNoScan($namespace), 'name' => null, 'shortName' => null, - ); + ]; $classBraceCount = 0;