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

Family mb_*-functions mutators #654

Closed
sanmai opened this issue Mar 8, 2019 · 5 comments
Closed

Family mb_*-functions mutators #654

sanmai opened this issue Mar 8, 2019 · 5 comments

Comments

@sanmai
Copy link
Member

sanmai commented Mar 8, 2019

It is common to see people use multibyte string functions (like mb_strlen) instead of their common analogs (like strlen), while not writing any tests exploiting multibyte functionality.

In this situations mutators as simple as below could be of use:

- if (mb_strlen($str) < 10) {
+ if (strlen($str) < 10) {

And similar mutators for functions like mb_substr, and others.

(This mutator could simply check if a function call starts with mb_, and then replace the function name with a prefix-less function if it exists, though this may not be the best approach.)

@BackEndTea
Copy link
Member

This mutator could simply check if a function call starts with mb_, and then replace the function name with a prefix-less function if it exists, though this may not be the best approach

I'd prefer to have a map which holds mb_ function names as key, and non mb_ variants as the value, and then we simply check if the function name is a key in the map, and replace it with the value.

@maks-rafalko
Copy link
Member

Great idea.

As I understand, both your implementation suggestions mean we will have 1 mutator class that mutates N functions, right?

In this case, we need settings to be able to disable any of the function mutations.

@majkel89
Copy link
Contributor

majkel89 commented Mar 8, 2019

Funny I already have this mutator stashed on mine laptop ;-) Will create PR when I get back to home

majkel89 added a commit to majkel89/infection that referenced this issue Mar 10, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 10, 2019
@majkel89 majkel89 mentioned this issue Mar 10, 2019
3 tasks
majkel89 added a commit to majkel89/infection that referenced this issue Mar 10, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 10, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 12, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 12, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 12, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 13, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 13, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 13, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 13, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 18, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 21, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 21, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 26, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 27, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 28, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 30, 2019
majkel89 added a commit to majkel89/infection that referenced this issue Mar 30, 2019
maks-rafalko pushed a commit that referenced this issue Apr 1, 2019
* #654 mbstring mutator

* #654 mbstring mutator configuration

* #654 fix code analysis issues

* #654 update json scheme for MBString mutator

* #654 fix spaceing

* #654 remove mutants

* #654 drop ereg functions in favoure of preg functions

* #654 fix styles

* #654 drop support fro mb_ereg* functions

* #654 mutate mb_convert_case with integer mode

* #654 remove functions that cannot be easily mapped

* #654 rm mb_split from json schema

* #654 rm mb_strrichr from json schema

* #654 code style fixes

* #654 simplify MBString mutator

* #654 remove getFunctionName fx

* #654 add tests cases for capitalization

* #654 add test for calling functions via variable
@majkel89
Copy link
Contributor

majkel89 commented Apr 1, 2019

As the PR is merged do we closes the issue ?

BTW thanks for great feedback during review.

@maks-rafalko
Copy link
Member

maks-rafalko commented Apr 1, 2019

Sure, should be closed

BTW, if the Fixes #654 had been used instead of Relates to issue #654, this issue would have been closed automatically (also, the bot would have added needed labels automatically).

Thanks for adding this feature, nice contribution!

@maks-rafalko maks-rafalko added this to the 0.13.0 milestone Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants