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

Add a few more count esque functions to not decrement against #640

Merged
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
9 changes: 8 additions & 1 deletion src/Mutator/Number/DecrementInteger.php
Expand Up @@ -44,7 +44,14 @@
*/
final class DecrementInteger extends Mutator
{
private const COUNT_NAMES = ['count', 'sizeof'];
private const COUNT_NAMES = [
'count',
'grapheme_strlen',
'iconv_strlen',
'mb_strlen',
'sizeof',
'strlen',
];

/**
* Decrements an integer by 1
Expand Down
45 changes: 45 additions & 0 deletions tests/Mutator/Number/DecrementIntegerTest.php
Expand Up @@ -334,6 +334,51 @@ public function provideMutationCases(): array
<?php

$foo = 1;
PHP
],
'It does not decrement zero when it is being compared as identical with result of grapheme_strlen()' => [
<<<'PHP'
<?php

if (grapheme_strlen($a) === 0) {
echo 'bar';
}
PHP
],
'It does not decrement zero when it is being compared as identical with result of iconv_strlen()' => [
<<<'PHP'
<?php

if (iconv_strlen($a) === 0) {
echo 'bar';
}
PHP
],
'It does not decrement zero when it is being compared as identical with result of mb_strlen()' => [
<<<'PHP'
<?php

if (mb_strlen($a) === 0) {
echo 'bar';
}
PHP
],
'It does not decrement zero when it is being compared as identical with result of sizeof()' => [
<<<'PHP'
<?php

if (sizeof($a) === 0) {
echo 'bar';
}
PHP
],
'It does not decrement zero when it is being compared as identical with result of strlen()' => [
<<<'PHP'
<?php

if (strlen($a) === 0) {
echo 'bar';
}
PHP
],
];
Expand Down