Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/PHPStan/Rules/Functions/ReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,16 @@ public function testBug11549(): void
$this->analyse([__DIR__ . '/data/bug-11549.php'], []);
}

public function testBug11301(): void
{
$this->checkExplicitMixed = true;
$this->checkNullables = true;
$this->analyse([__DIR__ . '/data/bug-11301.php'], [
[
'Function Bug11301\cString() should return array<string, string> but returns array<int, string>.',
35,
],
]);
}

}
48 changes: 48 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-11301.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Bug11301;

/**
* @return array<int, string>
*/
function cInt(): array
{
$a = ['12345'];
$b = ['abc'];

return array_combine($a, $b);
}

/**
* @return array<int, string>
*/
function cInt2(): array
{
$a = ['12345', 123];
$b = ['abc', 'def'];

return array_combine($a, $b);
}

/**
* @return array<string, string>
*/
function cString(): array
{
$a = ['12345'];
$b = ['abc'];

return array_combine($a, $b);
}


/**
* @return array<int|string, string>
*/
function cString2(): array
{
$a = ['12345', 123, 'a'];
$b = ['abc', 'def', 'xy'];

return array_combine($a, $b);
}
Loading