#40 replace instances of array_push with $array[]
This commit is contained in:
Родитель
f92c52c581
Коммит
5f39f02ee8
|
@ -31,7 +31,7 @@ class Lexer implements ITokenStreamProvider {
|
|||
|
||||
do {
|
||||
$token = $this->scanNextToken();
|
||||
array_push($tokensArray, $token);
|
||||
$tokensArray[] = $token;
|
||||
} while ($token->kind != TokenKind::EndOfFileToken);
|
||||
|
||||
return $tokensArray;
|
||||
|
|
|
@ -34,6 +34,6 @@ class DelimitedList extends Node {
|
|||
if (!isset($this->children)) {
|
||||
$this->children = array();
|
||||
}
|
||||
array_push($this->children, $node);
|
||||
$this->children[] = $node;
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ class Utilities {
|
|||
$newlinePos = -1;
|
||||
while ($newlinePos = strpos($text, "\n", $newlinePos + 1)) {
|
||||
if ($newlinePos < $pos) {
|
||||
array_push($newlinePositions, $newlinePos);
|
||||
$newlinePositions[] = $newlinePos;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -23,11 +23,11 @@ file_put_contents($argv[1] . ".ast", json_encode($sourceFile, JSON_PRETTY_PRINT)
|
|||
$diagnostics = Utilities::getDiagnostics($sourceFile);
|
||||
$diagnosticsAsLineCol = [];
|
||||
foreach ($diagnostics as $diagnostic) {
|
||||
array_push($diagnosticsAsLineCol, [
|
||||
$diagnosticsAsLineCol[] = [
|
||||
"error" => $diagnostic->kind,
|
||||
"message" => $diagnostic->message,
|
||||
"range" => Utilities::getRangeFromPosition($diagnostic->start, $diagnostic->length, $contents)
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
//echo $argv[1];
|
||||
|
|
|
@ -41,7 +41,7 @@ PHP;
|
|||
|
||||
public function testRootNodeIsScript() {
|
||||
$treeElements = iterator_to_array(self::$sourceFileNode->getDescendantNodes(), false);
|
||||
array_push($treeElements, self::$sourceFileNode);
|
||||
$treeElements[] = self::$sourceFileNode;
|
||||
|
||||
foreach($treeElements as $element) {
|
||||
$this->assertInstanceOf(SourceFileNode::class, $element->getRoot());
|
||||
|
@ -50,7 +50,7 @@ PHP;
|
|||
|
||||
public function testFileContentsRetrievableFromAnyNode() {
|
||||
$treeElements = iterator_to_array(self::$sourceFileNode->getDescendantNodes(), false);
|
||||
array_push($treeElements, self::$sourceFileNode);
|
||||
$treeElements[] = self::$sourceFileNode;
|
||||
|
||||
foreach($treeElements as $element) {
|
||||
$this->assertEquals(self::FILE_CONTENTS, $element->getFileContents());
|
||||
|
|
|
@ -39,7 +39,7 @@ class ParserInvariantsTest extends LexerInvariantsTest {
|
|||
$tokensArray = array();
|
||||
foreach ($sourceFileNode->getDescendantNodesAndTokens() as $child) {
|
||||
if ($child instanceof \PhpParser\Token) {
|
||||
array_push($tokensArray, $child);
|
||||
$tokensArray[] = $child;
|
||||
}
|
||||
}
|
||||
$testFiles[basename($filename)] = [$filename, $tokensArray];
|
||||
|
@ -77,7 +77,7 @@ class ParserInvariantsTest extends LexerInvariantsTest {
|
|||
*/
|
||||
public function testEveryNodeSpanIsSumOfChildSpans($filename, Node $sourceFileNode) {
|
||||
$treeElements = iterator_to_array($sourceFileNode->getDescendantNodesAndTokens(), false);
|
||||
array_push($treeElements, $sourceFileNode);
|
||||
$treeElements[] = $sourceFileNode;
|
||||
|
||||
foreach ($treeElements as $element) {
|
||||
if ($element instanceof Node) {
|
||||
|
@ -116,7 +116,7 @@ class ParserInvariantsTest extends LexerInvariantsTest {
|
|||
*/
|
||||
public function testEachChildHasExactlyOneParent($filename, Node $sourceFileNode) {
|
||||
$allTreeElements = iterator_to_array($sourceFileNode->getDescendantNodesAndTokens(), false);
|
||||
array_push($allTreeElements, $sourceFileNode);
|
||||
$allTreeElements[] = $sourceFileNode;
|
||||
|
||||
foreach ($sourceFileNode->getDescendantNodesAndTokens() as $childWithParent) {
|
||||
$count = 0;
|
||||
|
@ -139,7 +139,7 @@ class ParserInvariantsTest extends LexerInvariantsTest {
|
|||
*/
|
||||
public function testEveryChildIsNodeOrTokenType($filename, Node $sourceFileNode) {
|
||||
$treeElements = iterator_to_array($sourceFileNode->getDescendantNodesAndTokens(), false);
|
||||
array_push($treeElements, $sourceFileNode);
|
||||
$treeElements[] = $sourceFileNode;
|
||||
|
||||
foreach ($sourceFileNode->getDescendantNodes() as $descendant) {
|
||||
foreach ($descendant->getChildNodesAndTokens() as $child) {
|
||||
|
@ -165,7 +165,7 @@ class ParserInvariantsTest extends LexerInvariantsTest {
|
|||
*/
|
||||
public function testRootNodeIsNeverAChild($filename, Node $sourceFileNode) {
|
||||
$treeElements = iterator_to_array($sourceFileNode->getDescendantNodesAndTokens(), false);
|
||||
array_push($treeElements, $sourceFileNode);
|
||||
$treeElements[] = $sourceFileNode;
|
||||
|
||||
foreach($treeElements as $element) {
|
||||
if ($element instanceof Node) {
|
||||
|
@ -181,7 +181,7 @@ class ParserInvariantsTest extends LexerInvariantsTest {
|
|||
*/
|
||||
public function testEveryNodeHasAKind($filename, Node $sourceFileNode) {
|
||||
$treeElements = iterator_to_array($sourceFileNode->getDescendantNodes(), false);
|
||||
array_push($treeElements, $sourceFileNode);
|
||||
$treeElements[] = $sourceFileNode;
|
||||
|
||||
foreach($treeElements as $element) {
|
||||
$this->assertNotNull(
|
||||
|
|
Загрузка…
Ссылка в новой задаче