Skip to content

Commit 665aa3a

Browse files
authored
Fix PHPStan 2.2 sealed array shape violations (#62)
PHPStan 2.2 enforces sealed array shapes more strictly, surfacing two existing type mismatches: - readExistingErrors() declared a return type without 'identifier', but delegated to decodeBaseline() which includes it. Strip the key so the runtime shape matches the declared type. - SplitterTest::getSampleErrors() declared its ignoreErrors as array{0: ...} (sealed, single index) but returned a list of 4 entries. Co-Authored-By: Claude Code
1 parent 9a70348 commit 665aa3a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/BaselineSplitter.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,20 @@ private function readExistingErrors(
164164
}
165165

166166
try {
167-
return $handler->decodeBaseline($filePath);
167+
$decoded = $handler->decodeBaseline($filePath);
168168

169169
} catch (ErrorException $e) {
170170
return null;
171171
}
172+
173+
$errors = [];
174+
175+
foreach ($decoded as $error) {
176+
unset($error['identifier']);
177+
$errors[] = $error;
178+
}
179+
180+
return $errors;
172181
}
173182

174183
/**

tests/SplitterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public function testOnlyFilesWithMatchingExtensionAreDeleted(): void
467467
}
468468

469469
/**
470-
* @return array{parameters: array{ignoreErrors: array{0: array{message?: string, rawMessage?: string, count: int, path: string, identifier?: string}}}}
470+
* @return array{parameters: array{ignoreErrors: list<array{message?: string, rawMessage?: string, count: int, path: string, identifier?: string}>}}
471471
*/
472472
private function getSampleErrors(): array
473473
{

0 commit comments

Comments
 (0)