mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Merge pull request #6089 from orklah/getTypeResourceClosed
Fix usage of gettype in a switch with closed resource
This commit is contained in:
commit
09b01677c0
@ -2381,7 +2381,15 @@ class AssertionFinder
|
||||
}
|
||||
} else {
|
||||
if ($var_name && $var_type) {
|
||||
$if_types[$var_name] = [['!' . $var_type]];
|
||||
if ($var_type === 'class@anonymous') {
|
||||
$if_types[$var_name] = [['!=object']];
|
||||
} elseif ($var_type === 'resource (closed)') {
|
||||
$if_types[$var_name] = [['!closed-resource']];
|
||||
} elseif (substr($var_type, 0, 10) === 'resource (') {
|
||||
$if_types[$var_name] = [['!=resource']];
|
||||
} else {
|
||||
$if_types[$var_name] = [['!' . $var_type]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3054,7 +3062,15 @@ class AssertionFinder
|
||||
}
|
||||
} else {
|
||||
if ($var_name && $var_type) {
|
||||
$if_types[$var_name] = [[$var_type]];
|
||||
if ($var_type === 'class@anonymous') {
|
||||
$if_types[$var_name] = [['=object']];
|
||||
} elseif ($var_type === 'resource (closed)') {
|
||||
$if_types[$var_name] = [['closed-resource']];
|
||||
} elseif (substr($var_type, 0, 10) === 'resource (') {
|
||||
$if_types[$var_name] = [['=resource']];
|
||||
} else {
|
||||
$if_types[$var_name] = [[$var_type]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,6 +792,15 @@ class FunctionCallTest extends TestCase
|
||||
if ($t === "object") {}
|
||||
}',
|
||||
],
|
||||
'getTypeSwitchClosedResource' => [
|
||||
'<?php
|
||||
$data = "foo";
|
||||
switch (gettype($data)) {
|
||||
case "resource (closed)":
|
||||
case "unknown type":
|
||||
return "foo";
|
||||
}',
|
||||
],
|
||||
'functionResolutionInNamespace' => [
|
||||
'<?php
|
||||
namespace Foo;
|
||||
|
Loading…
Reference in New Issue
Block a user