From 253416e8111486ff717b6b35bd11f1b9ce231e9c Mon Sep 17 00:00:00 2001 From: Samran Asif Date: Tue, 22 Sep 2026 10:02:31 +0500 Subject: [PATCH 1/2] fix: support LF line endings for @pest-mutate-ignore annotations on Windows Signed-off-by: Samran Asif --- src/Support/MutationGenerator.php | 3 ++- tests/Unit/MutationGeneratorTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Support/MutationGenerator.php b/src/Support/MutationGenerator.php index cebc859..1f241ef 100644 --- a/src/Support/MutationGenerator.php +++ b/src/Support/MutationGenerator.php @@ -45,7 +45,8 @@ public function generate( } $mutatorsToIgnoreByLine = []; - foreach (explode(PHP_EOL, $contents) as $lineNumber => $line) { + $lines = preg_split('/\R/', $contents) ?: []; + foreach ($lines as $lineNumber => $line) { if (str_contains($line, '@pest-mutate-ignore')) { if (Str::after($line, '@pest-mutate-ignore:') !== $line) { $mutatorsToIgnore = explode(',', Str::after($line, '@pest-mutate-ignore:')); diff --git a/tests/Unit/MutationGeneratorTest.php b/tests/Unit/MutationGeneratorTest.php index 79c67ed..84e94b0 100644 --- a/tests/Unit/MutationGeneratorTest.php +++ b/tests/Unit/MutationGeneratorTest.php @@ -151,6 +151,16 @@ classesToMutate: $classes, ->{0}->mutator->toBe(IfNegated::class); }); +it('ignores lines with the ignore annotation when file has LF line endings', function (): void { + $code = " \$b) { // @pest-mutate-ignore: GreaterOrEqualToGreater\n \$a = \$b;\n}\n"; + + $mutations = ($this->generate)($code, [GreaterOrEqualToGreater::class, IfNegated::class]); + + expect($mutations) + ->toHaveCount(1) + ->{0}->mutator->toBe(IfNegated::class); +}); + it('ignores lines with the ignore annotation for multiple mutators', function (): void { $mutations = ($this->generate)(<<<'PHP' Date: Fri, 30 Oct 2026 05:13:59 -0700 Subject: [PATCH 2/2] test: use >= instead of > in LF ignore test to target GreaterOrEqualToGreater Signed-off-by: Samran Asif --- tests/Unit/MutationGeneratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/MutationGeneratorTest.php b/tests/Unit/MutationGeneratorTest.php index 84e94b0..d5a9b30 100644 --- a/tests/Unit/MutationGeneratorTest.php +++ b/tests/Unit/MutationGeneratorTest.php @@ -152,7 +152,7 @@ classesToMutate: $classes, }); it('ignores lines with the ignore annotation when file has LF line endings', function (): void { - $code = " \$b) { // @pest-mutate-ignore: GreaterOrEqualToGreater\n \$a = \$b;\n}\n"; + $code = "= \$b) { // @pest-mutate-ignore: GreaterOrEqualToGreater\n \$a = \$b;\n}\n"; $mutations = ($this->generate)($code, [GreaterOrEqualToGreater::class, IfNegated::class]);