-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArrayType - use getIterableKeyType, it preserves array-key
- Loading branch information
1 parent
fc4e589
commit d5bf23b
Showing
8 changed files
with
70 additions
and
12 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
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
53 changes: 53 additions & 0 deletions
53
tests/PHPStan/Rules/Variables/data/benevolent-array-key.php
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,53 @@ | ||
<?php | ||
|
||
namespace ParamOutBenevolentArrayKey; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param array<mixed> $matches | ||
* @param-out array<int|string, list<string>> $matches | ||
*/ | ||
public static function matchAllStrictGroups(array &$matches): int | ||
{ | ||
$result = self::matchAll($matches); | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @param array<mixed> $matches | ||
* @param-out array<list<string>> $matches | ||
*/ | ||
public static function matchAll(array &$matches): int | ||
{ | ||
$matches = [['foo']]; | ||
|
||
return 1; | ||
} | ||
} | ||
|
||
class HelloWorld2 | ||
{ | ||
/** | ||
* @param array<mixed> $matches | ||
* @param-out array<list<string>> $matches | ||
*/ | ||
public static function matchAllStrictGroups(array &$matches): int | ||
{ | ||
$result = self::matchAll($matches); | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* @param array<mixed> $matches | ||
* @param-out array<int|string, list<string>> $matches | ||
*/ | ||
public static function matchAll(array &$matches): int | ||
{ | ||
$matches = [['foo']]; | ||
|
||
return 1; | ||
} | ||
} |