Skip to content

Commit ee6e0ef

Browse files
staabmondrejmirtes
authored andcommitted
Added regression test
1 parent 4a8d584 commit ee6e0ef

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

tests/PHPStan/Rules/Functions/ReturnTypeRuleTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,16 @@ public function testBug11549(): void
322322
$this->analyse([__DIR__ . '/data/bug-11549.php'], []);
323323
}
324324

325+
public function testBug11301(): void
326+
{
327+
$this->checkExplicitMixed = true;
328+
$this->checkNullables = true;
329+
$this->analyse([__DIR__ . '/data/bug-11301.php'], [
330+
[
331+
'Function Bug11301\cString() should return array<string, string> but returns array<int, string>.',
332+
35,
333+
],
334+
]);
335+
}
336+
325337
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Bug11301;
4+
5+
/**
6+
* @return array<int, string>
7+
*/
8+
function cInt(): array
9+
{
10+
$a = ['12345'];
11+
$b = ['abc'];
12+
13+
return array_combine($a, $b);
14+
}
15+
16+
/**
17+
* @return array<int, string>
18+
*/
19+
function cInt2(): array
20+
{
21+
$a = ['12345', 123];
22+
$b = ['abc', 'def'];
23+
24+
return array_combine($a, $b);
25+
}
26+
27+
/**
28+
* @return array<string, string>
29+
*/
30+
function cString(): array
31+
{
32+
$a = ['12345'];
33+
$b = ['abc'];
34+
35+
return array_combine($a, $b);
36+
}
37+
38+
39+
/**
40+
* @return array<int|string, string>
41+
*/
42+
function cString2(): array
43+
{
44+
$a = ['12345', 123, 'a'];
45+
$b = ['abc', 'def', 'xy'];
46+
47+
return array_combine($a, $b);
48+
}

0 commit comments

Comments
 (0)