Skip to content

Commit

Permalink
Bump phpstan from 1.x to 2.1+ and remove unnecessary psalm annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Jan 10, 2025
1 parent 200c46c commit f94a017
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"friendsofphp/php-cs-fixer": "^3.53",
"jetbrains/phpstorm-attributes": "^1.0",
"phplrt/compiler": "^3.7",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^10.5|^11.0",
"rector/rector": "^1.1"
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
level: max
Expand Down
15 changes: 5 additions & 10 deletions src/Node/Literal/StringLiteralNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,8 @@ private static function renderEscapeSequences(string $body): string
*/
private static function renderHexadecimalSequences(string $body): string
{
$callee = static fn(array $matches): string
=> \chr((int) \hexdec((string) $matches[1]))
;

return @\preg_replace_callback(self::HEX_SEQUENCE_PATTERN, $callee, $body) ?? $body;
return @\preg_replace_callback(self::HEX_SEQUENCE_PATTERN, static fn(array $matches): string
=> \chr((int) \hexdec($matches[1])), $body) ?? $body;
}

/**
Expand All @@ -152,8 +149,8 @@ private static function renderHexadecimalSequences(string $body): string
*/
private static function renderUtfSequences(string $body): string
{
$callee = static function (array $matches): string {
$code = (int) \hexdec((string) $matches[1]);
return @\preg_replace_callback(self::UTF_SEQUENCE_PATTERN, static function (array $matches): string {
$code = (int) \hexdec($matches[1]);

// @phpstan-ignore-next-line : PHPStan false-positive mb_chr evaluation
if (\function_exists('\\mb_chr') && ($result = \mb_chr($code)) !== false) {
Expand All @@ -179,9 +176,7 @@ private static function renderUtfSequences(string $body): string
. \chr(0x80 | $code >> 12 & 0x3F)
. \chr(0x80 | $code >> 6 & 0x3F)
. \chr(0x80 | $code & 0x3F);
};

return @\preg_replace_callback(self::UTF_SEQUENCE_PATTERN, $callee, $body) ?? $body;
}, $body) ?? $body;
}

public function getValue(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* },
* skip: list<non-empty-string>,
* grammar: array<array-key, RuleInterface>,
* reducers: array<array-key, callable(Context, mixed): mixed>,
* reducers: array<int<0, max>|non-empty-string, callable(Context, mixed): mixed>,
* transitions?: array<array-key, mixed>
* }
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Traverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function applyToNode(Node $node): void
}

/**
* @param iterable<array-key, mixed> $nodes
* @param iterable<mixed, mixed> $nodes
*/
private function applyToIterable(iterable $nodes): void
{
Expand Down

0 comments on commit f94a017

Please sign in to comment.