Skip to content

Commit dc172ca

Browse files
committed
Regression tests
Closes phpstan/phpstan#13978
1 parent 0ebbd41 commit dc172ca

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,18 @@ public function testBug9573(): void
12571257
$this->assertNoErrors($errors);
12581258
}
12591259

1260+
public function testBug13978(): void
1261+
{
1262+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13978.php');
1263+
$this->assertNoErrors($errors);
1264+
}
1265+
1266+
public function testDiscussion13979(): void
1267+
{
1268+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13979.php');
1269+
$this->assertNoErrors($errors);
1270+
}
1271+
12601272
public function testBug9039(): void
12611273
{
12621274
$errors = $this->runAnalyse(__DIR__ . '/data/bug-9039.php');
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Bug13978;
4+
5+
/**
6+
*
7+
* @param array{
8+
* key1: int
9+
* } $item
10+
*
11+
* @param-out array{
12+
* key1: int
13+
* }|array{
14+
* key2: float
15+
* } $item
16+
*
17+
*/
18+
function example(array &$item): void
19+
{
20+
if (!empty($item["key1"])) {
21+
$item['key2'] = 1.00;
22+
unset($item["key1"]);
23+
}
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Bug13979;
4+
5+
/**
6+
* @param array<string, mixed> $bar
7+
* @param-out array<string, mixed>|null $bar
8+
*/
9+
function foo(array &$bar): void {
10+
if ($bar === []) {
11+
$bar = null;
12+
}
13+
}

0 commit comments

Comments
 (0)