Repository navigation
Conversation
- Trim the captured tail before testing it for empty, so a trailing space or a single-line doc block's closing `*/` no longer makes a bare annotation suppress nothing. - Reset the per-line mutator list in the line scan, so a bare annotation means all mutators instead of inheriting the list from an earlier `@pest-mutate-ignore:` line. - Add tests for both, and for an unknown mutator name still suppressing nothing. Fixes defects 1 and 2 of pestphp/pest#1942. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes defects 1 and 2 reported in pestphp/pest#1942. It is the fix offered in that issue, unchanged, with tests.
What changes
src/Support/NodeVisitor.php: the captured tail is trimmed before the empty test. Previously// @pest-mutate-ignore(with a trailing space) and/** @pest-mutate-ignore */produced a non-empty tail. That tail matched no mutator name, so the annotation suppressed nothing.src/Support/MutationGenerator.php:$mutatorsToIgnoreis reset for each annotated line. Previously, once any earlier line used the@pest-mutate-ignore:form, a later bare annotation was recorded with that earlier line's mutator list, because?? ['all']could no longer fire.The meaning of a named list is unchanged: an unknown mutator name still suppresses nothing.
Tests
Added to
tests/Unit/MutationGeneratorTest.php:@pest-mutate-ignore: IfNegatedline suppresses every mutator, rather than onlyIfNegated;With the two source changes reverted, the first three fail and the unknown-name cases still pass. Reverting
NodeVisitor.phpalone fails the first two. RevertingMutationGenerator.phpalone fails the third.The full suite on PHP 8.4, macOS, reads
3 failed, 322 passed, against3 failed, 316 passedon5.xwithout this change. The 3 failures are the same visual snapshot tests on both.composer test:typesreports the same 2 errors before and after, inAbstractFunctionCallUnwrapMutator.phpandRemoveEarlyReturn.php, which this change does not touch. Pint passes.Not in this pull request
@pest-mutate-ignoresilently suppresses nothing, or the wrong set pest#1942 (an uncheckedfile_put_contentsinto a.temp/mutationsdirectory that is never recreated) is a separate mechanism and is not fixed here. That issue therefore stays open after this merges.// @pest-mutate-ignore: Name because reasonstays inert, exactly as before. Whether to accept that form is the open question in [Bug]: [mutate]@pest-mutate-ignoresilently suppresses nothing, or the wrong set pest#1942 and is not decided here.