Skip to content

Commit 59a94ce

Browse files
committed
more tests
1 parent 270c0b9 commit 59a94ce

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ private static function findTestFiles(): iterable
248248
yield __DIR__ . '/../Rules/Classes/data/bug-11591-property-tag.php';
249249
yield __DIR__ . '/../Rules/Classes/data/mixin-trait-use.php';
250250

251+
yield __DIR__ . '/../Rules/Variables/data/bug-13921.php';
251252
yield __DIR__ . '/../Rules/Arrays/data/bug-14234.php';
252253
yield __DIR__ . '/../Rules/Arrays/data/bug-11679.php';
253254
yield __DIR__ . '/../Rules/Methods/data/bug-4801.php';

tests/PHPStan/Rules/Variables/data/bug-13921.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Bug13921;
44

5+
use SimpleXMLElement;
6+
use function PHPStan\Testing\assertType;
7+
58
/** @param list<array<?string>> $x */
69
function foo(array $x): void {
710
var_dump($x[0]['bar'] ?? null);
@@ -25,3 +28,17 @@ function boo(array $x): void {
2528
var_dump($x[0]['bar'] ?? null);
2629
var_dump($x[1] ?? null);
2730
}
31+
32+
function doBar(array $array)
33+
{
34+
if (isset($array['foo'])) {
35+
assertType("mixed~null", $array['foo']);
36+
assertType("non-empty-array&hasOffsetValue('foo', mixed~null)", $array);
37+
}
38+
}
39+
40+
/** @param list<SimpleXMLElement> $x */
41+
function sooSimpleElement(array $x): void {
42+
var_dump($x[0]['bar'] ?? null);
43+
var_dump($x[0] ?? null);
44+
}

0 commit comments

Comments
 (0)