array_splice possible fix
Publish PHP Package / docker (push) Successful in 6s Details

This commit is contained in:
Pavel Shevaev 2025-04-28 14:28:28 +03:00
parent 54cd3576d7
commit 058ab92420
1 changed files with 5 additions and 2 deletions

View File

@ -291,8 +291,10 @@ function _extract_lines_from_file(string $file_path) : array
function _show_bench(array $tasks, int $limit = 5) function _show_bench(array $tasks, int $limit = 5)
{ {
$times = array(); if(!$tasks)
return;
$times = array();
foreach($tasks as $name => $task) foreach($tasks as $name => $task)
{ {
if($task->hasRun()) if($task->hasRun())
@ -300,6 +302,7 @@ function _show_bench(array $tasks, int $limit = 5)
} }
uasort($times, fn($a, $b) => $b <=> $a); uasort($times, fn($a, $b) => $b <=> $a);
if(count($times) > $limit)
array_splice($times, $limit); array_splice($times, $limit);
if(!$times) if(!$times)