-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed inferring return type coming from array_map
- Loading branch information
1 parent
d97ddee
commit ea7e0ac
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Bug4587; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public function a(): void | ||
{ | ||
/** @var list<array{a: int}> $results */ | ||
$results = []; | ||
|
||
$type = array_map(static function (array $result): array { | ||
assertType('array(\'a\' => int)', $result); | ||
return $result; | ||
}, $results); | ||
|
||
assertType('array<int, array(\'a\' => int)>', $type); | ||
} | ||
|
||
public function b(): void | ||
{ | ||
/** @var list<array{a: int}> $results */ | ||
$results = []; | ||
|
||
$type = array_map(static function (array $result): array { | ||
assertType('array(\'a\' => int)', $result); | ||
$result['a'] = (string) $result['a']; | ||
assertType('array(\'a\' => string&numeric)', $result); | ||
|
||
return $result; | ||
}, $results); | ||
|
||
assertType('array<int, array(\'a\' => string&numeric)>', $type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters