Skip to content

Commit 83d15e3

Browse files
committed
Regression test for #1657
1 parent 83c1e0b commit 83d15e3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10424,6 +10424,11 @@ public function dataBug2997(): array
1042410424
return $this->gatherAssertTypes(__DIR__ . '/data/bug-2997.php');
1042510425
}
1042610426

10427+
public function dataBug1657(): array
10428+
{
10429+
return $this->gatherAssertTypes(__DIR__ . '/data/bug-1657.php');
10430+
}
10431+
1042710432
/**
1042810433
* @param string $file
1042910434
* @return array<string, mixed[]>
@@ -10609,6 +10614,7 @@ private function gatherAssertTypes(string $file): array
1060910614
* @dataProvider dataBug4099
1061010615
* @dataProvider dataBug3760
1061110616
* @dataProvider dataBug2997
10617+
* @dataProvider dataBug1657
1061210618
* @param string $assertType
1061310619
* @param string $file
1061410620
* @param mixed ...$args
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Bug1657;
4+
5+
use function PHPStan\Analyser\assertType;
6+
7+
/**
8+
* @param string|int $value
9+
*/
10+
function foo($value)
11+
{
12+
assertType('int|string', $value);
13+
try {
14+
assert(is_string($value));
15+
assertType('string', $value);
16+
17+
} catch (\Throwable $e) {
18+
$value = 'A';
19+
assertType('\'A\'', $value);
20+
}
21+
22+
assertType('string', $value);
23+
};

0 commit comments

Comments
 (0)