Skip to content

Commit

Permalink
Fix ctype_digit assertion bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffycondor committed Sep 7, 2022
1 parent cfe7fd1 commit f0a8810
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 f0a8810

Please sign in to comment.