Skip to content

Commit 167f9a3

Browse files
committed
Test array_find_key with pipe operator
1 parent d0ae37e commit 167f9a3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/PHPStan/Analyser/nsrt/pipe-operator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,15 @@ public function testGenerics(): void
246246
assertType('int', 'foo' |> $this->doConditional(...) |> $this->doGenerics(...));
247247
}
248248

249+
public function testArrayFindKey(): void
250+
{
251+
$result = ['foo' => 1, 'bar' => null, 'buz' => ''] |> (fn($subject) => array_find_key($subject, function ($value, $key) {
252+
assertType("array{value: 1|''|null, key: 'bar'|'buz'|'foo'}", compact('value', 'key'));
253+
254+
return is_int($value);
255+
}));
256+
257+
assertType("'bar'|'buz'|'foo'|null", $result);
258+
}
259+
249260
}

0 commit comments

Comments
 (0)