Skip to content

Commit 080658c

Browse files
committed
Few more asserts
1 parent 3a8e1d9 commit 080658c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/PHPStan/Analyser/data/enum-in-array.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ public function testNegative3(): void
9696
public function testNegative4(MyEnum $enum, array $array): void
9797
{
9898
if (!in_array($enum, $array, true)) {
99+
assertType('MyEnum', $enum);
99100
assertType('array<null>', $array);
100101
} else {
102+
assertType('MyEnum', $enum);
101103
assertType('non-empty-array<MyEnum|null>', $array);
102104
}
103105
}
@@ -107,25 +109,26 @@ public function testNegative4(MyEnum $enum, array $array): void
107109
class InArrayEnum
108110
{
109111

110-
/** @var list<MyEnum> */
111-
private array $list = [];
112-
113-
public function testPositive(MyEnum $enum): void
112+
/** @param list<MyEnum> $list */
113+
public function testPositive(MyEnum $enum, array $list): void
114114
{
115-
if (in_array($enum, $this->list, true)) {
115+
if (in_array($enum, $list, true)) {
116116
return;
117117
}
118118

119119
assertType(MyEnum::class, $enum);
120+
assertType('list<*NEVER*>&list<MyEnum>', $list);
120121
}
121122

122-
public function testNegative(MyEnum $enum): void
123+
/** @param list<MyEnum> $list */
124+
public function testNegative(MyEnum $enum, array $list): void
123125
{
124-
if (!in_array($enum, $this->list, true)) {
126+
if (!in_array($enum, $list, true)) {
125127
return;
126128
}
127129

128130
assertType(MyEnum::class, $enum);
131+
assertType('non-empty-list<MyEnum>', $list);
129132
}
130133

131134
}

0 commit comments

Comments
 (0)