Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve parenthesization for union types
- Loading branch information
1 parent
85ab8cf
commit c6924aa
Showing
4 changed files
with
41 additions
and
1 deletion.
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,23 @@ | ||
<?php | ||
|
||
namespace Bug7484; | ||
|
||
/** | ||
* @template K of int|string | ||
* @template V | ||
* @param iterable<K, V> $iterable | ||
* @return iterable<K, V> | ||
*/ | ||
function changeKeyCase( | ||
iterable $iterable, | ||
int $case = CASE_LOWER, | ||
): iterable { | ||
$callable = $case === CASE_LOWER ? 'strtolower' : 'strtoupper'; | ||
foreach ($iterable as $key => $value) { | ||
if (is_string($key)) { | ||
$key = $callable($key); | ||
} | ||
|
||
yield $key => $value; | ||
} | ||
} |