Skip to content

Commit

Permalink
Regression test for #1657
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 28, 2020
1 parent 83c1e0b commit 83d15e3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10424,6 +10424,11 @@ public function dataBug2997(): array
return $this->gatherAssertTypes(__DIR__ . '/data/bug-2997.php');
}

public function dataBug1657(): array
{
return $this->gatherAssertTypes(__DIR__ . '/data/bug-1657.php');
}

/**
* @param string $file
* @return array<string, mixed[]>
Expand Down Expand Up @@ -10609,6 +10614,7 @@ private function gatherAssertTypes(string $file): array
* @dataProvider dataBug4099
* @dataProvider dataBug3760
* @dataProvider dataBug2997
* @dataProvider dataBug1657
* @param string $assertType
* @param string $file
* @param mixed ...$args
Expand Down
23 changes: 23 additions & 0 deletions tests/PHPStan/Analyser/data/bug-1657.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Bug1657;

use function PHPStan\Analyser\assertType;

/**
* @param string|int $value
*/
function foo($value)
{
assertType('int|string', $value);
try {
assert(is_string($value));
assertType('string', $value);

} catch (\Throwable $e) {
$value = 'A';
assertType('\'A\'', $value);
}

assertType('string', $value);
};

0 comments on commit 83d15e3

Please sign in to comment.