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

#654 mbstring mutator doc #122

Merged
merged 1 commit into from Apr 1, 2019
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
47 changes: 47 additions & 0 deletions src/guide/mutators.md
Expand Up @@ -292,7 +292,54 @@ infection.json:
| CastString | `(string) $value;` | `$value` |

### Regex

| Name | Original | Mutated |
| :------: | :------: |:-------:|
| PregQuote | `$a = preg_quote('text');` | `$a = 'text';` |
| PregMatchMatches | `preg_match('/pattern/', $value, $matches);` | `(int) $matches = array();` |

### Extensions

| Name | Original | Mutated |
| :------: | :------: |:-------:|
| MBString | `mb_chr($code);` | `chr($code);` |
| | `mb_ord($character);` | `ord($character);` |
| | `mb_parse_str('text', $results);` | `parse_str('text', $results);` |
| | `mb_send_mail($to, $subject, $message, $headers, $parameters);` | `mail($to, $subject, $message, $headers, $parameters);` |
| | `mb_strcut('text', 0, 123, 'utf-8');` | `substr('text', 0, 123);` |
| | `mb_stripos('text', 't', 0, 'utf-8');` | `stripos('text', 't', 0);` |
| | `mb_stristr('text', 't', true, 'utf-8');` | `stristr('text', 't', true);` |
| | `mb_strlen('text', 'utf-8');` | `strlen('text');` |
| | `mb_strpos('text', 't', 0, 'utf-8');` | `strpos('text', 't', 0);` |
| | `mb_strrchr('text', 't', true, 'utf-8');` | `strrchr('text', 't', true);` |
| | `mb_strripos('text', 't', 0, 'utf-8');` | `strripos('text', 't', 0);` |
| | `mb_strrpos('text', 't', 0, 'utf-8');` | `strrpos('text', 't', 0);` |
| | `mb_strstr('text', 't', true, 'utf-8');` | `strstr('text', 't', true);` |
| | `mb_strtolower('text', 'utf-8');` | `strtolower('text');` |
| | `mb_strtoupper('text', 'utf-8');` | `strtoupper('text');` |
| | `mb_substr_count('text', 't', 'utf-8');` | `substr_count('text', 't');` |
| | `mb_substr('text', 0, 123, 'utf-8');` | `substr('text', 0, 123);` |
| | `mb_convert_case('text', $mode);` | `strtoupper('text');`, `strtolower('text');` or `ucwords('text');` depending on mode |

#### `MBString`

* `"mb_parse_str": true`: You are able to disable any of the supported mb string functions. All supported functions are enabled by default.

> Some of the functions are not supported due to complexity to convert them to standard string manipulation functions.
> Implementing them either does not make sense or creates too many false positive mutations.
> Not supported functions are `mb_ereg*`, `mb_split`, `mb_strrichr`, `mb_get_info` and similar.

infection.json:

```json
{
"mutators": {
"MBString": {
"settings": {
"mb_send_mail": false,
"mb_substr_count": false
}
}
}
}
```
6 changes: 6 additions & 0 deletions src/guide/profiles.md
Expand Up @@ -247,6 +247,12 @@ Contains the following mutators:
* [Foreach_](/guide/mutators.html#Loop)
* [For_](/guide/mutators.html#Loop)

### `@extensions`

Contains the following mutators:

* [MBString](/guide/mutators.html#Extensions)

### `@default`

This is the default profile, which currently contains **most** mutators, and is used if no mutator or profile is chosen.
Expand Down