From 38cb9150479b19818a86b2383544238498f0cf7c Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 2 Jun 2022 02:42:08 -0500 Subject: [PATCH] Fix Model::find method --- public/main/inc/lib/model.lib.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/public/main/inc/lib/model.lib.php b/public/main/inc/lib/model.lib.php index 6568d16d50..c49233eb91 100644 --- a/public/main/inc/lib/model.lib.php +++ b/public/main/inc/lib/model.lib.php @@ -20,24 +20,18 @@ class Model /** * Useful finder - experimental akelos like only use in notification.lib.php send function. - * - * @param string $type - * @param array $options - * - * @return array */ - public function find($type, $options = null) + public function find(string|int $type, array $options = []): array { - switch ($type) { - case 'all': - return self::get_all($options); - break; - default: - if (is_numeric($type)) { - return self::get($type); - } - break; + if ('all' === $type) { + return self::get_all($options); } + + if (is_numeric($type)) { + return self::get((int) $type); + } + + return []; } /**