From f0a8810cf50b2afdea562282f702aa098106a062 Mon Sep 17 00:00:00 2001 From: Semyon <7ionmail@gmail.com> Date: Wed, 7 Sep 2022 15:49:35 +0300 Subject: [PATCH] Fix ctype_digit assertion bug --- .../Statements/Expression/AssertionFinder.php | 2 +- tests/TypeReconciliation/ConditionalTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index 1dcc97346a9..1603d1655dd 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -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']], ]; diff --git a/tests/TypeReconciliation/ConditionalTest.php b/tests/TypeReconciliation/ConditionalTest.php index 295597be4a3..3b7d0148bd5 100644 --- a/tests/TypeReconciliation/ConditionalTest.php +++ b/tests/TypeReconciliation/ConditionalTest.php @@ -2862,6 +2862,20 @@ function bar(mixed $m): void } ', ], + 'ctypeDigitMakesStringNumericButDoesntProveOtherwise' => [ + ' [ '