From c43c2a4941a8ec2e2e4a570c713ba84e8400aac2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 22 Dec 2023 10:15:30 +0100 Subject: [PATCH] more tests --- .../CacheInterfaceGetDynamicReturnTypeExtension.php | 1 + tests/Type/Symfony/data/cache.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Type/Symfony/CacheInterfaceGetDynamicReturnTypeExtension.php b/src/Type/Symfony/CacheInterfaceGetDynamicReturnTypeExtension.php index 82ab3c2c..8c6754c0 100644 --- a/src/Type/Symfony/CacheInterfaceGetDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/CacheInterfaceGetDynamicReturnTypeExtension.php @@ -42,6 +42,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method if ($returnType->isConstantScalarValue()->yes()) { return $returnType->generalize(GeneralizePrecision::lessSpecific()); } + return $returnType; } return null; diff --git a/tests/Type/Symfony/data/cache.php b/tests/Type/Symfony/data/cache.php index 6b0728d4..58069a09 100644 --- a/tests/Type/Symfony/data/cache.php +++ b/tests/Type/Symfony/data/cache.php @@ -12,6 +12,15 @@ function testCacheCallable(\Symfony\Contracts\Cache\CacheInterface $cache): voi assertType('string', $result); }; +/** + * @param callable():string $fn + */ +function testNonScalarCacheCallable(\Symfony\Contracts\Cache\CacheInterface $cache, callable $fn): void { + $result = $cache->get('foo', $fn); + + assertType('string', $result); +}; + /** * @param \Symfony\Contracts\Cache\CallbackInterface<\stdClass> $cb */