Skip to content

Commit

Permalink
Use array_is_list() function when available
Browse files Browse the repository at this point in the history
Suggested by Alexander M. Turek <me@derrabus.de> in #4818 (review)
  • Loading branch information
sebastianbergmann committed Dec 18, 2021
1 parent 3d90cfe commit 71f5074
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Framework/Constraint/Traversable/ArrayIsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace PHPUnit\Framework\Constraint;

use function array_is_list;
use function is_array;

/**
Expand All @@ -34,6 +35,11 @@ protected function matches(mixed $other): bool
return false;
}

if (function_exists('array_is_list')) {
return array_is_list($other);
}

// @todo Remove this code once we require PHP >= 8.1
if ($other === []) {
return true;
}
Expand Down

0 comments on commit 71f5074

Please sign in to comment.