Skip to content

Commit fac4b0a

Browse files
committed
Regression tests
Closes phpstan/phpstan#11709 Closes phpstan/phpstan#9524
1 parent 7688d7f commit fac4b0a

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,16 @@ public function testBug11640(): void
14551455
$this->assertNoErrors($errors);
14561456
}
14571457

1458+
public function testBug11709(): void
1459+
{
1460+
if (PHP_VERSION_ID < 80000) {
1461+
$this->markTestSkipped('Test requires PHP 8.0.');
1462+
}
1463+
1464+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-11709.php');
1465+
$this->assertNoErrors($errors);
1466+
}
1467+
14581468
/**
14591469
* @param string[]|null $allAnalysedFiles
14601470
* @return Error[]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Bug11709;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @phpstan-template T
9+
* @param ($value is array ? array<T> : mixed) $value
10+
* @phpstan-assert array<string, T> $value
11+
*/
12+
function isArrayWithStringKeys(mixed $value): void
13+
{
14+
if (!is_array($value)) {
15+
throw new \Exception('Not an array');
16+
}
17+
18+
foreach (array_keys($value) as $key) {
19+
if (!is_string($key)) {
20+
throw new \Exception('Non-string key');
21+
}
22+
}
23+
}
24+
25+
function ($m): void {
26+
isArrayWithStringKeys($m);
27+
assertType('array<string, mixed>', $m);
28+
};

tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,4 +808,10 @@ public function testBug10165(): void
808808
$this->analyse([__DIR__ . '/data/bug-10165.php'], []);
809809
}
810810

811+
public function testBug9524(): void
812+
{
813+
$this->phpVersionId = PHP_VERSION_ID;
814+
$this->analyse([__DIR__ . '/data/bug-9524.php'], []);
815+
}
816+
811817
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Bug9524;
4+
5+
class MysqlConnection extends \mysqli
6+
{
7+
public function change_user($user, $password, $database): bool
8+
{
9+
return false;
10+
}
11+
}

0 commit comments

Comments
 (0)