Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Skip sort/ksort on TernaryFalseExpressionToIfRector (#…
…5703) * Create array_helper.php.inc * [CodeQuality] Skip sort/ksort on TernaryFalseExpressionToIfRector * fix --------- Co-authored-by: Adamo Crespi <hello@aerendir.me>
- Loading branch information
1 parent
c14f8d4
commit 3d02e3e
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...uality/Rector/Expression/TernaryFalseExpressionToIfRector/Fixture/skip_sort_ksort.php.inc
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,21 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Expression\TernaryFalseExpressionToIfRector\Fixture; | ||
|
||
class SkipSortKsort | ||
{ | ||
public static function mksort(array &$array): void | ||
{ | ||
$keys = array_keys($array); | ||
$isIndexedArray = array_reduce($keys, static fn ($result, $item): bool => $result && is_numeric($item), true); | ||
$isIndexedArray | ||
? sort($array) | ||
: ksort($array); | ||
|
||
foreach ($array as &$value) { | ||
if (is_array($value)) { | ||
self::mksort($value); | ||
} | ||
} | ||
} | ||
} |
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