Skip to content

Commit

Permalink
Fix issues indentifed by PHPStan 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 17, 2024
1 parent 443a549 commit eb23806
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 16 deletions.
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ parameters:
paths:
- src
- tests
ignoreErrors:
-
message: '#Method SebastianBergmann\\Diff\\Differ::calculateEstimatedFootprint\(\) never returns float so it can be removed from the return type\.#'
path: src/Differ.php
6 changes: 0 additions & 6 deletions src/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ public function lines(): array
*/
public function setLines(array $lines): void
{
foreach ($lines as $line) {
if (!$line instanceof Line) {
throw new InvalidArgumentException;
}
}

$this->lines = $lines;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Differ.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private function selectLcsImplementation(array $from, array $to): LongestCommonS
return new TimeEfficientLongestCommonSubsequenceCalculator;
}

private function calculateEstimatedFootprint(array $from, array $to): float|int
private function calculateEstimatedFootprint(array $from, array $to): int
{
$itemSize = PHP_INT_SIZE === 4 ? 76 : 144;

Expand Down
1 change: 0 additions & 1 deletion tests/LongestCommonSubsequenceTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public function testStrictTypeCalculate(): void
{
$diff = $this->implementation->calculate(['5'], ['05']);

$this->assertIsArray($diff);
$this->assertCount(0, $diff);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use function file_put_contents;
use function implode;
use function is_array;
use function is_string;
use function preg_replace;
use function preg_split;
use function realpath;
Expand Down Expand Up @@ -58,9 +57,9 @@ public static function provideDiffWithLineNumbers(): array
{
return array_filter(
UnifiedDiffOutputBuilderDataProvider::provideDiffWithLineNumbers(),
static function ($key)
static function (string $key)
{
return !is_string($key) || !str_contains($key, 'non_patch_compat');
return !str_contains($key, 'non_patch_compat');
},
ARRAY_FILTER_USE_KEY,
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Utils/UnifiedDiffAssertTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private function unifiedDiffAssertHeaderDate(string $date, string $message): voi
$matches,
);

if (1 !== $match || count($matches) < 4) {
if (1 !== $match) {
throw new UnexpectedValueException(sprintf('Date of header line does not match expected pattern, got "%s". %s', $date, $message));
}

Expand Down

0 comments on commit eb23806

Please sign in to comment.