Skip to content

Commit f94a017

Browse files
committed
Bump phpstan from 1.x to 2.1+ and remove unnecessary psalm annotations
1 parent 200c46c commit f94a017

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"friendsofphp/php-cs-fixer": "^3.53",
2424
"jetbrains/phpstorm-attributes": "^1.0",
2525
"phplrt/compiler": "^3.7",
26-
"phpstan/phpstan": "^2.0",
27-
"phpstan/phpstan-deprecation-rules": "^2.0",
26+
"phpstan/phpstan": "^2.1",
2827
"phpstan/phpstan-strict-rules": "^2.0",
2928
"phpunit/phpunit": "^10.5|^11.0",
3029
"rector/rector": "^1.1"

phpstan.neon

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
includes:
22
- phar://phpstan.phar/conf/bleedingEdge.neon
3-
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
43
- vendor/phpstan/phpstan-strict-rules/rules.neon
54
parameters:
65
level: max

src/Node/Literal/StringLiteralNode.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,8 @@ private static function renderEscapeSequences(string $body): string
137137
*/
138138
private static function renderHexadecimalSequences(string $body): string
139139
{
140-
$callee = static fn(array $matches): string
141-
=> \chr((int) \hexdec((string) $matches[1]))
142-
;
143-
144-
return @\preg_replace_callback(self::HEX_SEQUENCE_PATTERN, $callee, $body) ?? $body;
140+
return @\preg_replace_callback(self::HEX_SEQUENCE_PATTERN, static fn(array $matches): string
141+
=> \chr((int) \hexdec($matches[1])), $body) ?? $body;
145142
}
146143

147144
/**
@@ -152,8 +149,8 @@ private static function renderHexadecimalSequences(string $body): string
152149
*/
153150
private static function renderUtfSequences(string $body): string
154151
{
155-
$callee = static function (array $matches): string {
156-
$code = (int) \hexdec((string) $matches[1]);
152+
return @\preg_replace_callback(self::UTF_SEQUENCE_PATTERN, static function (array $matches): string {
153+
$code = (int) \hexdec($matches[1]);
157154

158155
// @phpstan-ignore-next-line : PHPStan false-positive mb_chr evaluation
159156
if (\function_exists('\\mb_chr') && ($result = \mb_chr($code)) !== false) {
@@ -179,9 +176,7 @@ private static function renderUtfSequences(string $body): string
179176
. \chr(0x80 | $code >> 12 & 0x3F)
180177
. \chr(0x80 | $code >> 6 & 0x3F)
181178
. \chr(0x80 | $code & 0x3F);
182-
};
183-
184-
return @\preg_replace_callback(self::UTF_SEQUENCE_PATTERN, $callee, $body) ?? $body;
179+
}, $body) ?? $body;
185180
}
186181

187182
public function getValue(): string

src/Parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* },
3838
* skip: list<non-empty-string>,
3939
* grammar: array<array-key, RuleInterface>,
40-
* reducers: array<array-key, callable(Context, mixed): mixed>,
40+
* reducers: array<int<0, max>|non-empty-string, callable(Context, mixed): mixed>,
4141
* transitions?: array<array-key, mixed>
4242
* }
4343
*/

src/Traverser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private function applyToNode(Node $node): void
112112
}
113113

114114
/**
115-
* @param iterable<array-key, mixed> $nodes
115+
* @param iterable<mixed, mixed> $nodes
116116
*/
117117
private function applyToIterable(iterable $nodes): void
118118
{

0 commit comments

Comments
 (0)