-
Notifications
You must be signed in to change notification settings - Fork 574
Expand file tree
/
Copy pathbug-10349.php
More file actions
34 lines (26 loc) · 910 Bytes
/
bug-10349.php
File metadata and controls
34 lines (26 loc) · 910 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
28
29
30
31
32
33
34
<?php declare(strict_types = 1);
namespace Bug10349Nsrt;
use function PHPStan\Testing\assertType;
class Foo
{
/**
* @param array<string, array<string, bool|float|int|string>> $expected
*/
public function testTypePreservationAfterErrorAssignOp(array $expected, int $ptr, string $key): void
{
assertType('array<string, array<string, bool|float|int|string>>', $expected);
$expected[$key]['number-1'] += $ptr;
// After += with ErrorType result, the array type should be preserved
assertType('bool|float|int|string', $expected[$key]['number-2']);
}
/**
* @param array<string, bool|float|int|string> $arr
*/
public function testSimpleArrayTypePreservation(array $arr, int $ptr): void
{
assertType('bool|float|int|string', $arr['a']);
$arr['a'] += $ptr;
// After += with ErrorType result, sibling keys should keep their type
assertType('bool|float|int|string', $arr['b']);
}
}