Skip to content

Commit 6c8c67d

Browse files
committed
more tests
1 parent 59a94ce commit 6c8c67d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

tests/PHPStan/Rules/Variables/NullCoalesceRuleTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ public function testBug14213(): void
364364

365365
public function testBug13921(): void
366366
{
367-
$this->analyse([__DIR__ . '/data/bug-13921.php'], []);
367+
$this->analyse([__DIR__ . '/data/bug-13921.php'], [
368+
[
369+
'Offset 0 on non-empty-list<array<string|null>> on left side of ?? always exists and is not nullable.',
370+
17
371+
]
372+
]);
368373
}
369374

370375
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ function foo(array $x): void {
1111
var_dump($x[0] ?? null);
1212
}
1313

14+
/** @param non-empty-list<array<?string>> $x */
15+
function nonEmptyFoo(array $x): void {
16+
var_dump($x[0]['bar'] ?? null);
17+
var_dump($x[0] ?? null);
18+
}
19+
1420
/** @param list<array<?string>> $x */
1521
function bar(array $x): void {
1622
var_dump($x[0] ?? null);

0 commit comments

Comments
 (0)