Skip to content
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

Add native property types in Parser #529

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
10 changes: 3 additions & 7 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,24 +354,20 @@

/**
* The list of tokens that are parsed.
*
* @var TokensList|null
*/
public $list;
public TokensList|null $list = null;

/**
* List of statements parsed.
*
* @var Statement[]
*/
public $statements = [];
public array $statements = [];

/**
* The number of opened brackets.
*
* @var int
*/
public $brackets = 0;
public int $brackets = 0;

/**
* @param string|UtfString|TokensList|null $list the list of tokens to be parsed
Expand All @@ -379,14 +375,14 @@
*/
public function __construct(string|UtfString|TokensList|null $list = null, bool $strict = false)
{
if (Context::$keywords === []) {

Check warning on line 378 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "Identical": --- Original +++ New @@ @@ */ public function __construct(string|UtfString|TokensList|null $list = null, bool $strict = false) { - if (Context::$keywords === []) { + if (Context::$keywords !== []) { Context::load(); } if (is_string($list) || $list instanceof UtfString) {
Context::load();
}

if (is_string($list) || ($list instanceof UtfString)) {

Check warning on line 382 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if (Context::$keywords === []) { Context::load(); } - if (is_string($list) || $list instanceof UtfString) { + if (is_string($list) || false) { $lexer = new Lexer($list, $strict); $this->list = $lexer->list; } elseif ($list instanceof TokensList) {
$lexer = new Lexer($list, $strict);
$this->list = $lexer->list;
} elseif ($list instanceof TokensList) {

Check warning on line 385 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if (is_string($list) || $list instanceof UtfString) { $lexer = new Lexer($list, $strict); $this->list = $lexer->list; - } elseif ($list instanceof TokensList) { + } elseif (true) { $this->list = $list; } $this->strict = $strict;
$this->list = $list;
}

Expand Down Expand Up @@ -447,7 +443,7 @@

// `DELIMITER` is not an actual statement and it requires
// special handling.
if (($token->type === TokenType::None) && (strtoupper($token->token) === 'DELIMITER')) {

Check warning on line 446 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "UnwrapStrToUpper": --- Original +++ New @@ @@ $token = $list->tokens[$list->idx]; // `DELIMITER` is not an actual statement and it requires // special handling. - if ($token->type === TokenType::None && strtoupper($token->token) === 'DELIMITER') { + if ($token->type === TokenType::None && $token->token === 'DELIMITER') { // Skipping to the end of this statement. $list->getNextOfType(TokenType::Delimiter); $prevLastIdx = $list->idx;
// Skipping to the end of this statement.
$list->getNextOfType(TokenType::Delimiter);
$prevLastIdx = $list->idx;
Expand Down Expand Up @@ -548,8 +544,8 @@
// Handles unions.
if (
! empty($unionType)
&& ($lastStatement instanceof SelectStatement)

Check warning on line 547 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ $statement->last = $list->idx; $prevLastIdx = $list->idx; // Handles unions. - if (!empty($unionType) && $lastStatement instanceof SelectStatement && $statement instanceof SelectStatement) { + if (!empty($unionType) && true && $statement instanceof SelectStatement) { /* * This SELECT statement. *
&& ($statement instanceof SelectStatement)

Check warning on line 548 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ $statement->last = $list->idx; $prevLastIdx = $list->idx; // Handles unions. - if (!empty($unionType) && $lastStatement instanceof SelectStatement && $statement instanceof SelectStatement) { + if (!empty($unionType) && $lastStatement instanceof SelectStatement && true) { /* * This SELECT statement. *
) {
/*
* This SELECT statement.
Expand Down Expand Up @@ -581,7 +577,7 @@
$unionType = false;

// Validate clause order
$statement->validateClauseOrder($this, $list);

Check warning on line 580 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ // union ends. $lastStatement->last = $statement->last; $unionType = false; - // Validate clause order - $statement->validateClauseOrder($this, $list); + continue; } // Handles transactions.
continue;
}

Expand All @@ -607,7 +603,7 @@
}

// Validate clause order
$statement->validateClauseOrder($this, $list);

Check warning on line 606 in src/Parser.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.1

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } $lastTransaction = null; } - // Validate clause order - $statement->validateClauseOrder($this, $list); + continue; } // Validate clause order
continue;
}

Expand Down
Loading