Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 21, 2022
1 parent 7682bf1 commit 1aef99d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Expand Up @@ -618,6 +618,7 @@ public function dataFileAsserts(): iterable

yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-6404.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-6399.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-4357.php');
}

/**
Expand Down
26 changes: 26 additions & 0 deletions tests/PHPStan/Analyser/data/bug-4357.php
@@ -0,0 +1,26 @@
<?php

namespace Bug4357;

use function PHPStan\Testing\assertType;

class Sample {
/** @var null|array<string, string> */
private $arr = null;

public function test(): void {
if ($this->arr === null) {
return;
}

assertType('array<string, string>', $this->arr);

unset($this->arr['hello']);

assertType('array<string, string>', $this->arr);

if (count($this->arr) === 0) {
$this->arr = null;
}
}
}

0 comments on commit 1aef99d

Please sign in to comment.