Skip to content

Commit

Permalink
fixed tests for php>=8.2 and safe>=2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lemorragia committed Mar 29, 2023
1 parent c6a862d commit 31429c2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/Iterator/PhpDocumentorIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,18 @@ static function (SplFileInfo $file) {
),
RecursiveIteratorIterator::LEAVES_ONLY,
));
uasort($files, static function (SplFileInfo $a, SplFileInfo $b) {

/**
* Compatibility layer for uasort:
* @see https://www.php.net/manual/en/function.uasort.php
* - in php 8.2.0 uasort always returns true instead of bool
* - subsequently the function has been removed from thecodingmachine\safe >= 2.0
*/
$method =
function_exists('\Safe\uasort') &&
version_compare(phpversion(), "8.2.0", "<=") ? '\Safe\uasort' : '\uasort';

$method($files, static function (SplFileInfo $a, SplFileInfo $b) {
return (string) $a <=> (string) $b;
});

Expand Down

0 comments on commit 31429c2

Please sign in to comment.