diff --git a/src/Rules/Comparison/ImpossibleCheckTypeHelper.php b/src/Rules/Comparison/ImpossibleCheckTypeHelper.php index 39a4da06bd..884bd834f8 100644 --- a/src/Rules/Comparison/ImpossibleCheckTypeHelper.php +++ b/src/Rules/Comparison/ImpossibleCheckTypeHelper.php @@ -343,7 +343,7 @@ public function getArgumentsDescription( return ''; } - $descriptions = array_map(fn (Arg $arg): string => ($this->treatPhpDocTypesAsCertain ? $scope->getType($arg->value) : $scope->getNativeType($arg->value))->describe(VerbosityLevel::value()), $args); + $descriptions = array_map(fn (Arg $arg): string => ($this->treatPhpDocTypesAsCertain ? $scope->getType($arg->value) : $scope->getNativeType($arg->value))->describe(VerbosityLevel::precise()), $args); if (count($descriptions) < 3) { return sprintf(' with %s', implode(' and ', $descriptions)); diff --git a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php index 16529f3a74..b71616c2b1 100644 --- a/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php +++ b/tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php @@ -146,15 +146,15 @@ public function testImpossibleCheckTypeFunctionCall(): void 367, ], [ - 'Call to function is_string() with mixed will always evaluate to false.', + 'Call to function is_string() with mixed~string will always evaluate to false.', 561, ], [ - 'Call to function is_callable() with mixed will always evaluate to false.', + 'Call to function is_callable() with mixed~callable() will always evaluate to false.', 572, ], [ - 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExists\' and \'testWithStringFirst…\' will always evaluate to true.', + 'Call to function method_exists() with \'CheckTypeFunctionCall\\\\MethodExists\' and \'testWithStringFirstArgument\' will always evaluate to true.', 586, ], [ @@ -330,11 +330,11 @@ public function testImpossibleCheckTypeFunctionCallWithoutAlwaysTrue(): void 367, ], [ - 'Call to function is_string() with mixed will always evaluate to false.', + 'Call to function is_string() with mixed~string will always evaluate to false.', 561, ], [ - 'Call to function is_callable() with mixed will always evaluate to false.', + 'Call to function is_callable() with mixed~callable() will always evaluate to false.', 572, ], [ @@ -1102,4 +1102,16 @@ public function testAlwaysTruePregMatch(): void $this->analyse([__DIR__ . '/data/always-true-preg-match.php'], []); } + public function testBug11799(): void + { + $this->checkAlwaysTrueCheckTypeFunctionCall = true; + $this->treatPhpDocTypesAsCertain = true; + $this->analyse([__DIR__ . '/data/bug-11799.php'], [ + [ + "Call to function in_array() with arguments lowercase-string, array{'publishDate', 'approvedAt', 'allowedValues'} and true will always evaluate to false.", + 11, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Comparison/data/bug-11799.php b/tests/PHPStan/Rules/Comparison/data/bug-11799.php new file mode 100644 index 0000000000..9d2b2168b8 --- /dev/null +++ b/tests/PHPStan/Rules/Comparison/data/bug-11799.php @@ -0,0 +1,16 @@ +