Skip to content

Array short syntax #16880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
28 changes: 13 additions & 15 deletions setup/src/Magento/Setup/Module/Di/Code/Reader/FileScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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];
}
}

Expand Down Expand Up @@ -246,22 +244,22 @@ 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,
'lineStart' => $tokens[$tokenIndex][2],
'lineEnd' => null,
'includeType' => $includeTypes[$tokens[$tokenIndex][0]],
'path' => '',
);
];

// start processing with next token
if ($MACRO_TOKEN_ADVANCE() === false) {
Expand Down Expand Up @@ -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,
Expand All @@ -306,7 +304,7 @@ protected function scan()
'uses' => $this->getUsesNoScan($namespace),
'name' => null,
'shortName' => null,
);
];

$classBraceCount = 0;

Expand Down