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

Define context keywords relying on Token constants #568

Closed
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
1,141 changes: 880 additions & 261 deletions src/Contexts/ContextMariaDb100000.php

Large diffs are not rendered by default.

694 changes: 385 additions & 309 deletions src/Contexts/ContextMariaDb100100.php

Large diffs are not rendered by default.

622 changes: 312 additions & 310 deletions src/Contexts/ContextMariaDb100200.php

Large diffs are not rendered by default.

622 changes: 312 additions & 310 deletions src/Contexts/ContextMariaDb100300.php

Large diffs are not rendered by default.

621 changes: 311 additions & 310 deletions src/Contexts/ContextMariaDb100400.php

Large diffs are not rendered by default.

622 changes: 312 additions & 310 deletions src/Contexts/ContextMariaDb100500.php

Large diffs are not rendered by default.

621 changes: 311 additions & 310 deletions src/Contexts/ContextMariaDb100600.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb100700.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb100800.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb100900.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb101000.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb101100.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb110000.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb110100.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb110200.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb110300.php

Large diffs are not rendered by default.

1,373 changes: 1,063 additions & 310 deletions src/Contexts/ContextMariaDb110400.php

Large diffs are not rendered by default.

1,018 changes: 786 additions & 232 deletions src/Contexts/ContextMySql50000.php

Large diffs are not rendered by default.

1,123 changes: 868 additions & 255 deletions src/Contexts/ContextMySql50100.php

Large diffs are not rendered by default.

1,139 changes: 879 additions & 260 deletions src/Contexts/ContextMySql50500.php

Large diffs are not rendered by default.

1,268 changes: 982 additions & 286 deletions src/Contexts/ContextMySql50600.php

Large diffs are not rendered by default.

1,365 changes: 1,056 additions & 309 deletions src/Contexts/ContextMySql50700.php

Large diffs are not rendered by default.

952 changes: 642 additions & 310 deletions src/Contexts/ContextMySql80000.php

Large diffs are not rendered by default.

878 changes: 568 additions & 310 deletions src/Contexts/ContextMySql80100.php

Large diffs are not rendered by default.

841 changes: 531 additions & 310 deletions src/Contexts/ContextMySql80200.php

Large diffs are not rendered by default.

741 changes: 431 additions & 310 deletions src/Contexts/ContextMySql80300.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// Flags that describe the tokens in more detail.
// All keywords must have flag 1 so `Context::isKeyword` method doesn't
// require strict comparison.
public const FLAG_KEYWORD = 1;
public const FLAG_KEYWORD_RESERVED = 2;
public const FLAG_KEYWORD_COMPOSED = 4;
public const FLAG_KEYWORD_DATA_TYPE = 8;
Expand Down Expand Up @@ -113,7 +114,7 @@
*
* If no processing can be done it will return the initial string.
*/
public function extract(): bool|float|int|string

Check warning on line 117 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ * * If no processing can be done it will return the initial string. */ - public function extract() : bool|float|int|string + protected function extract() : bool|float|int|string { switch ($this->type) { case TokenType::Keyword:
{
switch ($this->type) {
case TokenType::Keyword:
Expand All @@ -135,14 +136,14 @@
case TokenType::Number:
$ret = str_replace('--', '', $this->token); // e.g. ---42 === -42
if ($this->flags & self::FLAG_NUMBER_HEX) {
$ret = str_replace(['-', '+'], '', $this->token);

Check warning on line 139 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ $ret = str_replace('--', '', $this->token); // e.g. ---42 === -42 if ($this->flags & self::FLAG_NUMBER_HEX) { - $ret = str_replace(['-', '+'], '', $this->token); + $ret = str_replace(['+'], '', $this->token); if ($this->flags & self::FLAG_NUMBER_NEGATIVE) { $ret = -hexdec($ret); } else {

Check warning on line 139 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "UnwrapStrReplace": --- Original +++ New @@ @@ $ret = str_replace('--', '', $this->token); // e.g. ---42 === -42 if ($this->flags & self::FLAG_NUMBER_HEX) { - $ret = str_replace(['-', '+'], '', $this->token); + $ret = $this->token; if ($this->flags & self::FLAG_NUMBER_NEGATIVE) { $ret = -hexdec($ret); } else {
if ($this->flags & self::FLAG_NUMBER_NEGATIVE) {
$ret = -hexdec($ret);
} else {
$ret = hexdec($ret);
}
} elseif (($this->flags & self::FLAG_NUMBER_APPROXIMATE) || ($this->flags & self::FLAG_NUMBER_FLOAT)) {
$ret = (float) $ret;

Check warning on line 146 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "CastFloat": --- Original +++ New @@ @@ $ret = hexdec($ret); } } elseif ($this->flags & self::FLAG_NUMBER_APPROXIMATE || $this->flags & self::FLAG_NUMBER_FLOAT) { - $ret = (float) $ret; + $ret = $ret; } elseif (!($this->flags & self::FLAG_NUMBER_BINARY)) { $ret = (int) $ret; }
} elseif (! ($this->flags & self::FLAG_NUMBER_BINARY)) {
$ret = (int) $ret;
}
Expand All @@ -152,11 +153,11 @@
case TokenType::String:
// Trims quotes.
$str = $this->token;
$str = mb_substr($str, 1, -1, 'UTF-8');

Check warning on line 156 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "MBString": --- Original +++ New @@ @@ case TokenType::String: // Trims quotes. $str = $this->token; - $str = mb_substr($str, 1, -1, 'UTF-8'); + $str = substr($str, 1, -1); // Removes surrounding quotes. $quote = $this->token[0]; $str = str_replace($quote . $quote, $quote, $str);

// Removes surrounding quotes.
$quote = $this->token[0];
$str = str_replace($quote . $quote, $quote, $str);

Check warning on line 160 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ $str = mb_substr($str, 1, -1, 'UTF-8'); // Removes surrounding quotes. $quote = $this->token[0]; - $str = str_replace($quote . $quote, $quote, $str); + $str = str_replace($quote, $quote, $str); // Finally unescapes the string. // // `stripcslashes` replaces escape sequences with their

Check warning on line 160 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ $str = mb_substr($str, 1, -1, 'UTF-8'); // Removes surrounding quotes. $quote = $this->token[0]; - $str = str_replace($quote . $quote, $quote, $str); + $str = str_replace($quote, $quote, $str); // Finally unescapes the string. // // `stripcslashes` replaces escape sequences with their

Check warning on line 160 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "UnwrapStrReplace": --- Original +++ New @@ @@ $str = mb_substr($str, 1, -1, 'UTF-8'); // Removes surrounding quotes. $quote = $this->token[0]; - $str = str_replace($quote . $quote, $quote, $str); + $str = $str; // Finally unescapes the string. // // `stripcslashes` replaces escape sequences with their

// Finally unescapes the string.
//
Expand All @@ -176,9 +177,9 @@
if (isset($str[0]) && ($str[0] === '@')) {
// `mb_strlen($str)` must be used instead of `null` because
// in PHP 5.3- the `null` parameter isn't handled correctly.
$str = mb_substr(

Check warning on line 180 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "MBString": --- Original +++ New @@ @@ if (isset($str[0]) && $str[0] === '@') { // `mb_strlen($str)` must be used instead of `null` because // in PHP 5.3- the `null` parameter isn't handled correctly. - $str = mb_substr($str, !empty($str[1]) && $str[1] === '@' ? 2 : 1, mb_strlen($str), 'UTF-8'); + $str = substr($str, !empty($str[1]) && $str[1] === '@' ? 2 : 1, mb_strlen($str)); } if (isset($str[0]) && $str[0] === ':') { $str = mb_substr($str, 1, mb_strlen($str), 'UTF-8');
$str,
! empty($str[1]) && ($str[1] === '@') ? 2 : 1,

Check warning on line 182 in src/Token.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ if (isset($str[0]) && $str[0] === '@') { // `mb_strlen($str)` must be used instead of `null` because // in PHP 5.3- the `null` parameter isn't handled correctly. - $str = mb_substr($str, !empty($str[1]) && $str[1] === '@' ? 2 : 1, mb_strlen($str), 'UTF-8'); + $str = mb_substr($str, !empty($str[2]) && $str[1] === '@' ? 2 : 1, mb_strlen($str), 'UTF-8'); } if (isset($str[0]) && $str[0] === ':') { $str = mb_substr($str, 1, mb_strlen($str), 'UTF-8');
mb_strlen($str),
'UTF-8',
);
Expand Down
Loading