Skip to content

Commit 06c2705

Browse files
Use stricter comparison
1 parent 5ae29e4 commit 06c2705

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/Output/StrictUnifiedDiffOutputBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private function writeDiffHunks(mixed $output, array $diff): void
155155
array_splice($diff, $i + 1, 0, [["\n\\ No newline at end of file\n", Differ::NO_LINE_END_EOF_WARNING]]);
156156
}
157157

158-
if (!count($toFind)) {
158+
if ($toFind === []) {
159159
break;
160160
}
161161
}

src/Output/UnifiedDiffOutputBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function writeDiffHunks(mixed $output, array $diff): void
103103
array_splice($diff, $i + 1, 0, [["\n\\ No newline at end of file\n", Differ::NO_LINE_END_EOF_WARNING]]);
104104
}
105105

106-
if (!count($toFind)) {
106+
if ($toFind === []) {
107107
break;
108108
}
109109
}

src/Parser.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public function parse(string $string): array
2929
{
3030
$lines = preg_split('(\r\n|\r|\n)', $string);
3131

32-
if (!empty($lines) && $lines[count($lines) - 1] === '') {
32+
if ($lines !== false &&
33+
$lines !== [] &&
34+
$lines[count($lines) - 1] === '') {
3335
array_pop($lines);
3436
}
3537

@@ -63,7 +65,7 @@ public function parse(string $string): array
6365
}
6466
}
6567

66-
if ($diff !== null && count($collected)) {
68+
if ($diff !== null && $collected !== []) {
6769
$this->parseFileDiff($diff, $collected);
6870

6971
$diffs[] = $diff;

tests/Utils/FileUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getFileContent(string $file): string
2727
sprintf(
2828
'Failed to read content of file "%s".%s',
2929
$file,
30-
$error ? ' ' . $error['message'] : '',
30+
$error !== null ? ' ' . $error['message'] : '',
3131
),
3232
);
3333
}

0 commit comments

Comments
 (0)