Skip to content

Commit

Permalink
Merge pull request #8466 from fluffycondor/ctype-digit-asserts-not-al…
Browse files Browse the repository at this point in the history
…l-numeric-strings

Fix ctype_digit assertion bug
  • Loading branch information
AndrolGenhald committed Sep 7, 2022
2 parents cfe7fd1 + f0a8810 commit 18f285f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -103,7 +103,7 @@ class AssertionFinder
'is_scalar' => ['scalar', [Type::class, 'getScalar']],
'is_iterable' => ['iterable'],
'is_countable' => ['countable'],
'ctype_digit' => ['numeric-string', [Type::class, 'getNumericString']],
'ctype_digit' => ['=numeric-string', [Type::class, 'getNumericString']],
'ctype_lower' => ['non-empty-lowercase-string', [Type::class, 'getNonEmptyLowercaseString']],
];

Expand Down
14 changes: 14 additions & 0 deletions tests/TypeReconciliation/ConditionalTest.php
Expand Up @@ -2862,6 +2862,20 @@ function bar(mixed $m): void
}
',
],
'ctypeDigitMakesStringNumericButDoesntProveOtherwise' => [
'<?php
function bar(string $m): void
{
if (is_numeric($m)) {
if (ctype_digit($m)) {
echo "I\'m an all-digit numeric-string";
} else {
echo "I\'m not an all-digit numeric-string";
}
}
}
',
],
'SKIPPED-ctypeDigitNarrowsIntToARange' => [
'<?php
$int = rand(-1000, 1000);
Expand Down

0 comments on commit 18f285f

Please sign in to comment.