Repository navigation
Conversation
theofidry
commented
Nov 4, 2026
| ```php | ||
| class Example | ||
| { | ||
| /** @infection-ignore ArrayItemRemoval, FalseValue */ |
Member
Author
There was a problem hiding this comment.
Suggested change
| /** @infection-ignore ArrayItemRemoval, FalseValue */ | |
| // @infection-ignore ArrayItemRemoval, FalseValue |
theofidry
commented
Nov 4, 2026
theofidry
left a comment
Member
Author
There was a problem hiding this comment.
not too happy with the result tbh... But I think I need a deeper review of the whole page
theofidry
added a commit
to infection/infection
that referenced
this pull request
Nov 5, 2026
## Description
When only one mutator produces unwanted mutations,
`@infection-ignore-all` also excludes mutations users want to keep. The
new `@infection-ignore` annotation lets users name the mutators to
exclude:
```php
class Example
{
/** @infection-ignore ArrayItemRemoval, FalseValue */
public function values(): array
{
return [false, true];
}
}
```
The annotation applies to the annotated code and everything nested
inside it. Nested annotations add to the inherited exclusions. Ordinary
comments work too:
```php
/** @infection-ignore ArrayItemRemoval */
class Example
{
public function values(): array
{
// @infection-ignore FalseValue
$defaults = [false, true];
return [false, true];
}
}
```
`ArrayItemRemoval` is excluded throughout the class. `FalseValue` is
excluded only in the assignment to `$defaults`; it can still mutate the
`false` in the return statement. `TrueValue` remains enabled in both
statements.
An annotation on an array item doesn't exclude `ArrayItemRemoval`,
because that mutator targets the array itself. The same annotation on
the return statement covers the array and excludes the mutation:
```php
class Example
{
public function itemAnnotation(): array
{
return [
// @infection-ignore ArrayItemRemoval
false,
]; // ArrayItemRemoval can still produce [].
}
public function statementAnnotation(): array
{
// @infection-ignore ArrayItemRemoval
return [false]; // ArrayItemRemoval is excluded here.
}
}
```
**Names are exact and case-sensitive**. Warnings for unknown names and
empty lists include the source file and the annotated node's line
number. Built-in mutator names are recognised even when disabled, along
with configured custom mutator names.
As with `@infection-ignore-all`, excluded mutations aren't generated and
don't contribute to the `Ignored` result count.
## Changes
- Introduce `ExcludeIgnoredMutatorsVisitor` to attach ignored mutator
names to nodes during AST enrichment.
- Adapt `NodeMutationGenerator` to filter out each node's ignored
mutators.
- Clarify in the nomenclature that these exclusions apply during
mutation generation, after node eligibility has been determined.
## Documentation
See infection/infection.github.io#7.
## Related issues
Closes #2291.
Member
Author
|
Actually could add a post for it too |
This branch has not been deployed
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.
See infection/infection#3717.
Generated with Codex. I would not review it yet as there is still some questions about the syntax or what is possible.