forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-11533.php
More file actions
27 lines (23 loc) · 767 Bytes
/
bug-11533.php
File metadata and controls
27 lines (23 loc) · 767 Bytes
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
<?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<string, mixed> $data */
function helloWithArrayKeyExists(array $data): void
{
foreach (['name', 'email'] as $key) {
if (!array_key_exists($key, $data) || !is_string($data[$key])) {
throw new \Exception();
}
}
assertType("non-empty-array<string, mixed>&hasOffsetValue('email', string)&hasOffsetValue('name', string)", $data);
}