Skip to content

Commit

Permalink
#654 mbstring mutator doc (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
majkel89 authored and maks-rafalko committed Apr 1, 2019
1 parent 458dfb2 commit fbc2db3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
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

0 comments on commit fbc2db3

Please sign in to comment.