PHP 8.5 compat. fixes

This commit is contained in:
Aleksander Machniak 2025-07-13 13:17:30 +02:00
parent ba60aa8637
commit 060fc95672
3 changed files with 13 additions and 13 deletions

View File

@ -54,7 +54,7 @@ class rcmail_action_mail_import extends rcmail_action
if (empty($filepath)) {
continue;
}
} elseif (!in_array($mtype_primary, ['text', 'message'])) {
} elseif (!in_array($mtype_primary, ['text', 'message']) && $ctype != 'application/mbox') {
continue;
}

View File

@ -283,24 +283,26 @@ function array_keys_recursive($array)
return $keys;
}
/**
/*
* Get first element from an array
*
* @param array $array Input array
*
* @return mixed First element if found, Null otherwise
*/
function array_first($array)
{
// @phpstan-ignore-next-line
if (is_array($array) && !empty($array)) {
reset($array);
foreach ($array as $element) {
return $element;
if (!function_exists('array_first')) {
function array_first($array)
{
// @phpstan-ignore-next-line
if (is_array($array) && !empty($array)) {
reset($array);
foreach ($array as $element) {
return $element;
}
}
}
return null;
return null;
}
}
/**

View File

@ -165,8 +165,6 @@ class BootstrapTest extends TestCase
public function test_array_first()
{
$this->assertNull(array_first([]));
$this->assertNull(array_first(false));
$this->assertNull(array_first('test'));
$this->assertSame('test', array_first(['test']));
$input = ['test1', 'test2'];