Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5d33443

Browse files
Add regression tests
1 parent c65f834 commit 5d33443

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

‎tests/PHPStan/Analyser/AnalyserIntegrationTest.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,18 @@ public function testBug7248(): void
835835
$this->assertNoErrors($errors);
836836
}
837837

838+
public function testBug6653(): void
839+
{
840+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-6653.php');
841+
$this->assertNoErrors($errors);
842+
}
843+
844+
public function testBug5592(): void
845+
{
846+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-5592.php');
847+
$this->assertNoErrors($errors);
848+
}
849+
838850
/**
839851
* @param string[]|null $allAnalysedFiles
840852
* @return Error[]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug5592;
4+
5+
/**
6+
* @param \Ds\Map<\Ds\Hashable, numeric-string> $map
7+
* @return numeric-string
8+
*/
9+
function mapGet(\Ds\Map $map, \Ds\Hashable $key): string
10+
{
11+
return $map->get($key, '0');
12+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug6653;
4+
5+
class HelloWorld
6+
{
7+
/**
8+
* @return array<string, int>|false
9+
*/
10+
public function sayHello()
11+
{
12+
$test = $this->getTest();
13+
return $this->filterEvent('sayHello', $test);
14+
}
15+
16+
/**
17+
* @template TValue of mixed
18+
* @param TValue $value
19+
* @return TValue
20+
*/
21+
private function filterEvent(string $eventName, $value)
22+
{
23+
// do event
24+
return $value;
25+
}
26+
27+
/**
28+
* @return array<string, int>|false
29+
*/
30+
private function getTest()
31+
{
32+
$failure = random_int(0, PHP_INT_MAX) % 2 ? true : false;
33+
if ($failure === true) {
34+
return false;
35+
}
36+
return ['foo' => 123];
37+
}
38+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /