Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#597 ArrayItemRemoval doc #120

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/guide/mutators.md
Expand Up @@ -212,9 +212,40 @@ infection.json:

| Name | Original | Mutated |
| :------: | :------: |:-------:|
| ArrayItemRemoval | `[1, $a, '3']` | `[$a, '3']` *depending on configuration*
| FunctionCallRemoval | foo_bar($a) | -
| MethodCallRemoval | $this->method($var) | -

#### `ArrayItemRemoval`

Configuration options:

* `remove: first`: defines the way the mutator operates. Could be:
- `first` - remove only first element from each array
- `last` - remove only last element from each array
- `all` - remove every element one by one from each array resulting in as many mutations as total number of items in arrays.
* `limit: PHP_INT_MAX`: when `remove = all` specifies maximum number of elements that will be removed form array. Only elements at the beginning will be mutated.

> When using `all` option we advise to set the limit as well

> You should remember to exclude files containing large arrays (like configuration)
> when using `ArrayItemRemoval` mutator in `all` mode

infection.json:

```json
{
"mutators": {
"ArrayItemRemoval": {
"settings": {
"remove": "all",
"limit": 15
}
}
}
}
```

### Loop

| Name | Original | Mutated |
Expand Down
1 change: 1 addition & 0 deletions src/guide/profiles.md
Expand Up @@ -170,6 +170,7 @@ Contains the following mutators:

Contains the following mutators:

* [ArrayItemRemoval](/guide/mutators.html#Removal)
* [FunctionCallRemoval](/guide/mutators.html#Removal)
* [MethodCallRemoval](/guide/mutators.html#Removal)

Expand Down