-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathbug-11533.php
More file actions
43 lines (37 loc) · 1.04 KB
/
bug-11533.php
File metadata and controls
43 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php declare(strict_types = 1);
namespace Bug11533;
use function PHPStan\Testing\assertType;
/** @param mixed[] $param */
function hello(array $param): void
{
foreach (['need', 'field'] as $field) {
if (!isset($param[$field]) || !is_string($param[$field])) {
throw new \Exception();
}
}
assertType("non-empty-array<mixed>&hasOffsetValue('field', string)&hasOffsetValue('need', string)", $param);
}
/** @param array{need: string, field: string} $param */
function world(array $param): void
{
}
/** @param mixed[] $param */
function helloWorld(array $param): void
{
foreach (['need', 'field'] as $field) {
if (!isset($param[$field]) || !is_string($param[$field])) {
throw new \Exception();
}
}
world($param);
}
/** @param mixed[] $param */
function withKey(array $param): void
{
foreach (['need', 'field'] as $key => $field) {
if (!isset($param[$field]) || !is_string($param[$field])) {
throw new \Exception();
}
}
assertType("non-empty-array<mixed>&hasOffsetValue('field', string)&hasOffsetValue('need', string)", $param);
}