Update psalm types (#267) #1072
Annotations
20 warnings
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L106
Escaped Mutant for Mutator "DecrementInteger":
--- Original
+++ New
@@ @@
$this->tokenStack->push($token[0]);
/** @psalm-var SqlToken */
$this->currentToken = $this->tokenStack->top();
- $length = 0;
+ $length = -1;
while (!$this->isEof()) {
if ($this->isWhitespace($length) || $this->isComment($length)) {
$this->addTokenFromBuffer();
|
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L127
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
$this->buffer .= $this->substring(1);
$this->advance(1);
}
- $this->addTokenFromBuffer();
+
if ($token->getHasChildren() && $token[-1] instanceof SqlToken && !$token[-1]->getHasChildren()) {
unset($token[-1]);
}
|
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L281
Escaped Mutant for Mutator "ConcatOperandRemoval":
--- Original
+++ New
@@ @@
return '';
}
$cacheKey = $offset . ',' . $length;
- if (!isset($this->substrings[$cacheKey . ',1'])) {
+ if (!isset($this->substrings[',1'])) {
$this->substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8');
}
if (!$caseSensitive && !isset($this->substrings[$cacheKey . ',0'])) {
|
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L282
Escaped Mutant for Mutator "MBString":
--- Original
+++ New
@@ @@
}
$cacheKey = $offset . ',' . $length;
if (!isset($this->substrings[$cacheKey . ',1'])) {
- $this->substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8');
+ $this->substrings[$cacheKey . ',1'] = substr($this->sql, $offset, $length);
}
if (!$caseSensitive && !isset($this->substrings[$cacheKey . ',0'])) {
$this->substrings[$cacheKey . ',0'] = mb_strtoupper($this->substrings[$cacheKey . ',1'], 'UTF-8');
|
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L285
Escaped Mutant for Mutator "LogicalAnd":
--- Original
+++ New
@@ @@
if (!isset($this->substrings[$cacheKey . ',1'])) {
$this->substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8');
}
- if (!$caseSensitive && !isset($this->substrings[$cacheKey . ',0'])) {
+ if (!$caseSensitive || !isset($this->substrings[$cacheKey . ',0'])) {
$this->substrings[$cacheKey . ',0'] = mb_strtoupper($this->substrings[$cacheKey . ',1'], 'UTF-8');
}
return $this->substrings[$cacheKey . ',' . (int) $caseSensitive];
|
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L443
Escaped Mutant for Mutator "LessThanOrEqualTo":
--- Original
+++ New
@@ @@
*/
private function advance(int $length) : void
{
- if ($length <= 0) {
+ if ($length < 0) {
throw new InvalidArgumentException('Length must be greater than 0.');
}
$this->offset += $length;
|
PHP 8-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L456
Escaped Mutant for Mutator "GreaterThanOrEqualTo":
--- Original
+++ New
@@ @@
*/
private function isEof() : bool
{
- return $this->offset >= $this->length;
+ return $this->offset > $this->length;
}
}
|
PHP 8-sqlite-ubuntu-latest:
src/Column.php#L38
Escaped Mutant for Mutator "MatchArmRemoval":
--- Original
+++ New
@@ @@
public function asString() : string
{
$format = match ($this->getTypeCategory()) {
- self::TYPE_CATEGORY_PK => '{type}{check}{append}',
self::TYPE_CATEGORY_NUMERIC => '{type}{length}{unsigned}{notnull}{unique}{check}{default}{append}',
self::TYPE_CATEGORY_UUID => '{type}{notnull}{unique}{default}{check}{comment}{append}',
self::TYPE_CATEGORY_UUID_PK => '{type}{notnull}{default}{check}{comment}{append}',
|
PHP 8-sqlite-ubuntu-latest:
src/Column.php#L38
Escaped Mutant for Mutator "MatchArmRemoval":
--- Original
+++ New
@@ @@
$format = match ($this->getTypeCategory()) {
self::TYPE_CATEGORY_PK => '{type}{check}{append}',
self::TYPE_CATEGORY_NUMERIC => '{type}{length}{unsigned}{notnull}{unique}{check}{default}{append}',
- self::TYPE_CATEGORY_UUID => '{type}{notnull}{unique}{default}{check}{comment}{append}',
self::TYPE_CATEGORY_UUID_PK => '{type}{notnull}{default}{check}{comment}{append}',
default => '{type}{length}{notnull}{unique}{check}{default}{append}',
};
|
PHP 8-sqlite-ubuntu-latest:
src/Column.php#L38
Escaped Mutant for Mutator "MatchArmRemoval":
--- Original
+++ New
@@ @@
self::TYPE_CATEGORY_PK => '{type}{check}{append}',
self::TYPE_CATEGORY_NUMERIC => '{type}{length}{unsigned}{notnull}{unique}{check}{default}{append}',
self::TYPE_CATEGORY_UUID => '{type}{notnull}{unique}{default}{check}{comment}{append}',
- self::TYPE_CATEGORY_UUID_PK => '{type}{notnull}{default}{check}{comment}{append}',
default => '{type}{length}{notnull}{unique}{check}{default}{append}',
};
return $this->buildCompleteString($format);
}
}
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L127
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
$this->buffer .= $this->substring(1);
$this->advance(1);
}
- $this->addTokenFromBuffer();
+
if ($token->getHasChildren() && $token[-1] instanceof SqlToken && !$token[-1]->getHasChildren()) {
unset($token[-1]);
}
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L306
Escaped Mutant for Mutator "Plus":
--- Original
+++ New
@@ @@
if ($offset === null) {
$offset = $this->offset;
}
- if ($offset + mb_strlen($string, 'UTF-8') > $this->length) {
+ if ($offset - mb_strlen($string, 'UTF-8') > $this->length) {
return $this->length;
}
$afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8');
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L306
Escaped Mutant for Mutator "GreaterThan":
--- Original
+++ New
@@ @@
if ($offset === null) {
$offset = $this->offset;
}
- if ($offset + mb_strlen($string, 'UTF-8') > $this->length) {
+ if ($offset + mb_strlen($string, 'UTF-8') >= $this->length) {
return $this->length;
}
$afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8');
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L310
Escaped Mutant for Mutator "MBString":
--- Original
+++ New
@@ @@
if ($offset + mb_strlen($string, 'UTF-8') > $this->length) {
return $this->length;
}
- $afterIndexOf = mb_strpos($this->sql, $string, $offset, 'UTF-8');
+ $afterIndexOf = strpos($this->sql, $string, $offset);
if ($afterIndexOf === false) {
$afterIndexOf = $this->length;
} else {
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L315
Escaped Mutant for Mutator "MBString":
--- Original
+++ New
@@ @@
if ($afterIndexOf === false) {
$afterIndexOf = $this->length;
} else {
- $afterIndexOf += mb_strlen($string, 'UTF-8');
+ $afterIndexOf += strlen($string);
}
return $afterIndexOf;
}
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L333
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
if (!$isIdentifier && !$isStringLiteral) {
return false;
}
- $this->addTokenFromBuffer();
+
$this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length);
return true;
}
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L336
Escaped Mutant for Mutator "Ternary":
--- Original
+++ New
@@ @@
return false;
}
$this->addTokenFromBuffer();
- $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length);
+ $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_STRING_LITERAL : SqlToken::TYPE_IDENTIFIER)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length);
return true;
}
/**
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L337
Escaped Mutant for Mutator "Ternary":
--- Original
+++ New
@@ @@
return false;
}
$this->addTokenFromBuffer();
- $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length);
+ $this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $this->substring($length) : $content)->startOffset($this->offset)->endOffset($this->offset + $length);
return true;
}
/**
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L341
Escaped Mutant for Mutator "TrueValue":
--- Original
+++ New
@@ @@
}
$this->addTokenFromBuffer();
$this->currentToken[] = (new SqlToken())->type($isIdentifier ? SqlToken::TYPE_IDENTIFIER : SqlToken::TYPE_STRING_LITERAL)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length);
- return true;
+ return false;
}
/**
* Determines whether there is an operator at the current offset and adds it to the token children.
|
PHP 8.1-sqlite-ubuntu-latest:
src/AbstractTokenizer.php#L359
Escaped Mutant for Mutator "Ternary":
--- Original
+++ New
@@ @@
$this->addTokenFromBuffer();
switch ($this->substring($length)) {
case '(':
- $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $content : $this->substring($length))->startOffset($this->offset)->endOffset($this->offset + $length);
+ $this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_OPERATOR)->content(is_string($content) ? $this->substring($length) : $content)->startOffset($this->offset)->endOffset($this->offset + $length);
$this->currentToken[] = (new SqlToken())->type(SqlToken::TYPE_PARENTHESIS);
if ($this->currentToken[-1] !== null) {
$this->tokenStack->push($this->currentToken[-1]);
|