misc: replace regex-based type parser with character-based one #772
Annotations
10 warnings
src/Type/Parser/LexingParser.php#L45
Escaped Mutant for Mutator "NotIdentical":
--- Original
+++ New
@@ @@
continue;
}
if ($char === '"' || $char === "'") {
- if ($current !== null) {
+ if ($current === null) {
$symbols[] = $current;
$current = null;
}
|
src/Type/Parser/LexingParser.php#L58
Escaped Mutant for Mutator "GreaterThan":
--- Original
+++ New
@@ @@
}
if (in_array($char, $separators, true)) {
$count = count($symbols);
- if ($char === ':' && $current === null && $count > 0 && $symbols[$count - 1] === ':') {
+ if ($char === ':' && $current === null && $count >= 0 && $symbols[$count - 1] === ':') {
$symbols[$count - 1] = '::';
continue;
}
|
src/Type/Parser/LexingParser.php#L99
Escaped Mutant for Mutator "Continue_":
--- Original
+++ New
@@ @@
{
foreach ($symbols as $key => $symbol) {
if (!str_contains($symbol, "@anonymous\x00")) {
- continue;
+ break;
}
if (count($symbols) >= $key + 3) {
$symbols[$key] = $symbol . $symbols[$key + 1] . $symbols[$key + 2];
|
src/Type/Parser/LexingParser.php#L102
Escaped Mutant for Mutator "DecrementInteger":
--- Original
+++ New
@@ @@
if (!str_contains($symbol, "@anonymous\x00")) {
continue;
}
- if (count($symbols) >= $key + 3) {
+ if (count($symbols) >= $key + 2) {
$symbols[$key] = $symbol . $symbols[$key + 1] . $symbols[$key + 2];
}
array_splice($symbols, $key + 1, 2);
|
src/Type/Parser/LexingParser.php#L102
Escaped Mutant for Mutator "Plus":
--- Original
+++ New
@@ @@
if (!str_contains($symbol, "@anonymous\x00")) {
continue;
}
- if (count($symbols) >= $key + 3) {
+ if (count($symbols) >= $key - 3) {
$symbols[$key] = $symbol . $symbols[$key + 1] . $symbols[$key + 2];
}
array_splice($symbols, $key + 1, 2);
|
src/Utility/Reflection/DocParser.php#L77
Escaped Mutant for Mutator "CastString":
--- Original
+++ New
@@ @@
$types = [];
preg_match_all('/@(phpstan|psalm)-type\\s+(?<name>[a-zA-Z]\\w*)\\s*=?\\s*(?<type>.*)/', $doc, $matches);
foreach ($matches['name'] as $key => $name) {
- $types[(string) $name] = self::findType($matches['type'][$key]);
+ $types[$name] = self::findType($matches['type'][$key]);
}
return $types;
}
|
src/Utility/Reflection/DocParser.php#L106
Escaped Mutant for Mutator "ArrayOneItem":
--- Original
+++ New
@@ @@
$class = $matches['class'][$key];
$types[$class][] = $name;
}
- return $types;
+ return count($types) > 1 ? array_slice($types, 0, 1, true) : $types;
}
/**
* @param ReflectionClass<object> $reflection
|
src/Utility/Reflection/DocParser.php#L123
Escaped Mutant for Mutator "UnwrapArrayMap":
--- Original
+++ New
@@ @@
return [];
}
preg_match_all('/@(phpstan-|psalm-)?extends\\s+(?<type>.+)/', $doc, $matches);
- return array_map(static fn(string $type): string => self::findType($type), $matches['type']);
+ return $matches['type'];
}
private static function annotationType(string $string, string $annotation, bool $left = true) : ?string
{
|
src/Utility/Reflection/DocParser.php#L129
Escaped Mutant for Mutator "TrueValue":
--- Original
+++ New
@@ @@
preg_match_all('/@(phpstan-|psalm-)?extends\\s+(?<type>.+)/', $doc, $matches);
return array_map(static fn(string $type): string => self::findType($type), $matches['type']);
}
- private static function annotationType(string $string, string $annotation, bool $left = true) : ?string
+ private static function annotationType(string $string, string $annotation, bool $left = false) : ?string
{
foreach (["@phpstan-{$annotation}", "@psalm-{$annotation}", "@{$annotation}"] as $case) {
$pos = $left ? strpos($string, $case) : strrpos($string, $case);
|
src/Utility/Reflection/DocParser.php#L161
Escaped Mutant for Mutator "NotIdentical":
--- Original
+++ New
@@ @@
$delimiters = [];
$mustBe = [];
foreach (str_split($string) as $char) {
- if ($mustBe !== [] && $char !== ' ') {
+ if ($mustBe !== [] && $char === ' ') {
if (!in_array($char, $mustBe, true)) {
break;
}
|
The logs for this run have expired and are no longer available.
Loading