Skip to content

Commit

Permalink
Add a few more count esque functions to not decrement against (#640)
Browse files Browse the repository at this point in the history
* Add a few more count esque functions

They dont need decrementing for the same reason as count functions.

* Wrap COUNT_NAMES

* Add test cases for new comparisons
  • Loading branch information
BackEndTea authored and maks-rafalko committed Mar 9, 2019
1 parent a8d9923 commit 46c0533
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Mutator/Number/DecrementInteger.php
Expand Up @@ -43,7 +43,14 @@
*/
final class DecrementInteger extends AbstractNumberMutator
{
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 @@ -320,6 +320,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

0 comments on commit 46c0533

Please sign in to comment.