Skip to content

Commit 1aef99d

Browse files
committed
Regression test
Closes phpstan/phpstan#4357
1 parent 7682bf1 commit 1aef99d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ public function dataFileAsserts(): iterable
618618

619619
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-6404.php');
620620
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-6399.php');
621+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-4357.php');
621622
}
622623

623624
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Bug4357;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class Sample {
8+
/** @var null|array<string, string> */
9+
private $arr = null;
10+
11+
public function test(): void {
12+
if ($this->arr === null) {
13+
return;
14+
}
15+
16+
assertType('array<string, string>', $this->arr);
17+
18+
unset($this->arr['hello']);
19+
20+
assertType('array<string, string>', $this->arr);
21+
22+
if (count($this->arr) === 0) {
23+
$this->arr = null;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)