From 4193edde2584eb4305fa8575b07afb13aa306b47 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 12 Jul 2025 12:24:20 +0900 Subject: [PATCH] Replce array_first_key() with array_key_first(), etc. --- common/framework/Mail.php | 2 +- common/framework/Password.php | 2 +- common/framework/Router.php | 2 +- common/framework/drivers/mail/brevo.php | 8 ++++---- common/framework/drivers/mail/sendgrid.php | 4 ++-- modules/admin/tpl/config_notification.html | 2 +- modules/advanced_mailer/advanced_mailer.controller.php | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/framework/Mail.php b/common/framework/Mail.php index 72c226c95..00851a749 100644 --- a/common/framework/Mail.php +++ b/common/framework/Mail.php @@ -585,7 +585,7 @@ class Mail // Reset Message-ID in case send() is called multiple times. $random = substr(hash('sha256', mt_rand() . microtime() . getmypid()), 0, 32); $sender = $this->message->getFrom(); - $sender_email = strval(array_first_key($sender)); + $sender_email = strval(array_key_first($sender)); $id = $random . '@' . (preg_match('/^(.+)@([^@]+)$/', $sender_email, $matches) ? $matches[2] : 'swift.generated'); $this->message->getHeaders()->get('Message-ID')->setId($id); diff --git a/common/framework/Password.php b/common/framework/Password.php index 3182557fb..feb1943ec 100644 --- a/common/framework/Password.php +++ b/common/framework/Password.php @@ -112,7 +112,7 @@ class Password { unset($algos['argon2id']); } - return array_first_key($algos); + return array_key_first($algos); } /** diff --git a/common/framework/Router.php b/common/framework/Router.php index 021449f90..29931b635 100644 --- a/common/framework/Router.php +++ b/common/framework/Router.php @@ -608,7 +608,7 @@ class Router return false; } arsort($reordered_routes); - $best_route = array_first_key($reordered_routes); + $best_route = array_key_first($reordered_routes); return $best_route; } } diff --git a/common/framework/drivers/mail/brevo.php b/common/framework/drivers/mail/brevo.php index 4fe4625ff..613b0309e 100644 --- a/common/framework/drivers/mail/brevo.php +++ b/common/framework/drivers/mail/brevo.php @@ -69,7 +69,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface $from = $message->message->getFrom(); $to = $message->message->getTo(); $data = [ - 'sender' => ['email' => array_first_key($from), 'name' => array_first($from)], + 'sender' => ['email' => array_key_first($from), 'name' => array_first($from)], 'to' => array_map($format_callback, array_keys($to), array_values($to)), 'subject' => $message->message->getSubject(), 'htmlContent' => $message->message->getBody(), @@ -84,7 +84,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface } if ($reply_to = $message->message->getReplyTo()) { - $data['replyTo'] = ['email' => array_first_key($reply_to)]; + $data['replyTo'] = ['email' => array_key_first($reply_to)]; } foreach ($message->getAttachments() as $attachment) { @@ -93,7 +93,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface 'name' => $attachment->display_filename ?: $attachment->cid, ]; } - + // Prepare headers and options for Requests. $headers = [ 'api-key' => $this->_config['api_key'], @@ -103,7 +103,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface $options = [ 'timeout' => 8, ]; - + // Send the API request. $request = \Rhymix\Framework\HTTP::post(self::$_url, $data, $headers, [], $options); $status_code = $request->getStatusCode(); diff --git a/common/framework/drivers/mail/sendgrid.php b/common/framework/drivers/mail/sendgrid.php index b135c79bd..8a7d84c96 100644 --- a/common/framework/drivers/mail/sendgrid.php +++ b/common/framework/drivers/mail/sendgrid.php @@ -108,7 +108,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface $from = $message->message->getFrom(); if ($from) { - $data['from']['email'] = array_first_key($from); + $data['from']['email'] = array_key_first($from); if (array_first($from)) { $data['from']['name'] = array_first($from); @@ -119,7 +119,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface $replyTo = $message->message->getReplyTo(); if ($replyTo) { - $data['reply_to']['email'] = array_first_key($from); + $data['reply_to']['email'] = array_key_first($from); } // Set the subject. diff --git a/modules/admin/tpl/config_notification.html b/modules/admin/tpl/config_notification.html index e09062d6c..c3cc37685 100644 --- a/modules/admin/tpl/config_notification.html +++ b/modules/admin/tpl/config_notification.html @@ -220,7 +220,7 @@ {@ $conf_exists = config("sms.$driver_name.api_key")} diff --git a/modules/advanced_mailer/advanced_mailer.controller.php b/modules/advanced_mailer/advanced_mailer.controller.php index 904822dcd..11679d716 100644 --- a/modules/advanced_mailer/advanced_mailer.controller.php +++ b/modules/advanced_mailer/advanced_mailer.controller.php @@ -18,7 +18,7 @@ class Advanced_MailerController extends Advanced_Mailer $recipients = $mail->message->getTo() ?: array(); if ($recipients) { - $first_recipient = array_first_key($recipients); + $first_recipient = array_key_first($recipients); if ($exception_driver = $this->getSendingMethodForEmailAddress($first_recipient, $config)) { $driver_class = '\\Rhymix\\Framework\\Drivers\Mail\\' . $exception_driver; @@ -51,7 +51,7 @@ class Advanced_MailerController extends Advanced_Mailer else { $sender = $mail->message->getFrom(); - $original_sender_email = $sender ? array_first_key($sender) : null; + $original_sender_email = $sender ? array_key_first($sender) : null; $original_sender_name = $sender ? array_first($sender) : null; list($default_from, $default_name) = $this->getDefaultEmailIdentity(); if ($original_sender_email !== $default_from && $default_from)