From 45f803109aa7a9aefe6dd86278d25f78600e1ce2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Aug 2022 21:50:49 +0200 Subject: [PATCH] resources may be opened or closed we cannot differentiate based on the 'resource' type between opened or closed resources --- ...fyingFunctionsDynamicReturnTypeExtension.php | 1 - .../PHPStan/Analyser/NodeScopeResolverTest.php | 1 + tests/PHPStan/Analyser/data/bug-5845.php | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/PHPStan/Analyser/data/bug-5845.php diff --git a/src/Type/Php/TypeSpecifyingFunctionsDynamicReturnTypeExtension.php b/src/Type/Php/TypeSpecifyingFunctionsDynamicReturnTypeExtension.php index 08eaf84e5b..628dfa7be6 100644 --- a/src/Type/Php/TypeSpecifyingFunctionsDynamicReturnTypeExtension.php +++ b/src/Type/Php/TypeSpecifyingFunctionsDynamicReturnTypeExtension.php @@ -51,7 +51,6 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo 'is_iterable', 'is_null', 'is_object', - 'is_resource', 'is_scalar', 'is_string', 'is_subclass_of', diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index f750b19132..53944695a7 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -994,6 +994,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/loose-comparisons.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7563.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7764.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5845.php'); } /** diff --git a/tests/PHPStan/Analyser/data/bug-5845.php b/tests/PHPStan/Analyser/data/bug-5845.php new file mode 100644 index 0000000000..a5ceeaa53f --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-5845.php @@ -0,0 +1,17 @@ +