Skip to content

Commit 3a98bde

Browse files
authored
chore: provide few missing types for callbacks (#9026)
1 parent dfaa36a commit 3a98bde

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/Cache/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public static function fromJson(string $json): self
132132
$cache = new self($signature);
133133

134134
// before v3.11.1 the hashes were crc32 encoded and saved as integers
135-
// @TODO: remove the to string cast/array_map in v4.0
135+
// @TODO v4: remove the to string cast/array_map
136136
$cache->hashes = array_map(static fn ($v): string => \is_int($v) ? (string) $v : $v, $data['hashes']);
137137

138138
return $cache;

src/Fixer/Basic/NumericLiteralSeparatorFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private function formatValue(string $value): string
183183
// All other types
184184

185185
/** If its a negative value we need an offset */
186-
$negativeOffset = static fn ($v) => str_contains($v, '-') ? 1 : 0;
186+
$negativeOffset = static fn (string $v): int => str_contains($v, '-') ? 1 : 0;
187187

188188
Preg::matchAll('/([0-9-_]+)?((\.)([0-9_]*))?((e)([0-9-_]+))?/i', $value, $result);
189189

src/Fixer/Casing/IntegerLiteralCaseFixer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
5353

5454
$content = $token->getContent();
5555

56-
$newContent = Preg::replaceCallback('#^0([boxBOX])([0-9a-fA-F_]+)$#', static fn ($matches) => '0'.strtolower($matches[1]).strtoupper($matches[2]), $content);
56+
$newContent = Preg::replaceCallback(
57+
'#^0([boxBOX])([0-9a-fA-F_]+)$#',
58+
// @phpstan-ignore-next-line offsetAccess.notFound
59+
static fn (array $matches): string => '0'.strtolower($matches[1]).strtoupper($matches[2]),
60+
$content
61+
);
5762

5863
if ($content === $newContent) {
5964
continue;

src/Fixer/Internal/ConfigurableFixerTemplateFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static function ($annotation): string {
152152
);
153153
$covers = array_filter(
154154
$covers,
155-
static fn ($className): bool => !str_contains($className, '\Abstract') && str_ends_with($className, 'Fixer')
155+
static fn (string $className): bool => !str_contains($className, '\Abstract') && str_ends_with($className, 'Fixer')
156156
);
157157

158158
if (1 !== \count($covers)) {

0 commit comments

Comments
 (0)