2 // This is like array_intersect_key_coercion.php but the left container is
3 // larger than the right and has holes, so we can test the other
4 // array_intersect_key code path
6 function nextBit(inout
int $x): bool {
12 function testOne(int $case): void
{
13 $left = nextBit(inout
$case) ? Map
{} : dict
[];
14 $right = nextBit(inout
$case) ? Map
{} : dict
[];
15 $left['hole1'] = true;
16 if (nextBit(inout
$case)) $left['a'] = 'a';
17 $left['hole2'] = true;
18 if (nextBit(inout
$case)) $left[1] = 'i';
19 $left['hole3'] = true;
20 if (nextBit(inout
$case)) $left['1'] = 's';
21 unset($left['hole1']);
22 unset($left['hole2']);
23 unset($left['hole3']);
24 if (nextBit(inout
$case)) $right['a'] = 'x';
25 if (nextBit(inout
$case)) $right[1] = 'y';
26 if (nextBit(inout
$case)) $right['1'] = 'z';
29 if (count($left) === 0 ||
count($right) === 0) return;
31 $left['junk1'] = true;
33 $left['junk3'] = true;
35 $res = array_intersect_key($left, $right);
37 $left is Map
<_
> ?
'm' : 'd',
38 isset($left['a']) ?
'a' : ' ',
39 isset($left[1]) ?
'i' : ' ',
40 isset($left['1']) ?
's' : ' ',
42 $right is Map
<_
> ?
'm' : 'd',
43 isset($right['a']) ?
'a' : ' ',
44 isset($right[1]) ?
'i' : ' ',
45 isset($right['1']) ?
's' : ' ',
54 function main(): void
{
55 for ($i = 0; $i < 256; $i++
) testOne($i);