Skip to content

Commit 899fa4e

Browse files
staabmondrejmirtes
authored andcommitted
resources may be opened or closed
we cannot differentiate based on the 'resource' type between opened or closed resources
1 parent e0f2c89 commit 899fa4e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/Type/Php/TypeSpecifyingFunctionsDynamicReturnTypeExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
5151
'is_iterable',
5252
'is_null',
5353
'is_object',
54-
'is_resource',
5554
'is_scalar',
5655
'is_string',
5756
'is_subclass_of',

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ public function dataFileAsserts(): iterable
994994
yield from $this->gatherAssertTypes(__DIR__ . '/data/loose-comparisons.php');
995995
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7563.php');
996996
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7764.php');
997+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5845.php');
997998
}
998999

9991000
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Bug5845;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class A
8+
{
9+
/**
10+
* @param resource $resource
11+
*/
12+
public static function foo($resource): void
13+
{
14+
assertType('bool', is_resource($resource));
15+
$type = is_resource($resource) ? get_resource_type($resource) : 'closed';
16+
}
17+
}

0 commit comments

Comments
 (0)