From 75abff257a906e27bbd003f28cbfee1ac0afabb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Wed, 22 May 2024 16:49:07 +0200 Subject: [PATCH 1/3] Improve Local::has_translations --- includes/class-locale.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/includes/class-locale.php b/includes/class-locale.php index 384e4314..1fe215de 100644 --- a/includes/class-locale.php +++ b/includes/class-locale.php @@ -28,7 +28,7 @@ class Locale extends GP_Locale { /** * Array of available translations data obtained with wp_get_available_translations() for the locale. * - * @var array + * @var array|null */ public $translations; @@ -78,11 +78,7 @@ public function __construct( $locale ) { */ public function has_translations() { - if ( is_null( $this->translations ) ) { - return false; - } else { - return true; - } + return is_array( $this->translations ) && $this->translations != array(); } } From 8f8619bf3e3b249ab2294f7881e07dc504175204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Wed, 22 May 2024 16:50:10 +0200 Subject: [PATCH 2/3] Increase strictness --- includes/class-locale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-locale.php b/includes/class-locale.php index 1fe215de..69619928 100644 --- a/includes/class-locale.php +++ b/includes/class-locale.php @@ -78,7 +78,7 @@ public function __construct( $locale ) { */ public function has_translations() { - return is_array( $this->translations ) && $this->translations != array(); + return is_array( $this->translations ) && $this->translations !== array(); } } From 673959f94bf2cb645a204d84ff38041aba31c147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Wed, 22 May 2024 16:50:43 +0200 Subject: [PATCH 3/3] Hi Yoda! --- includes/class-locale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-locale.php b/includes/class-locale.php index 69619928..cb0f40fb 100644 --- a/includes/class-locale.php +++ b/includes/class-locale.php @@ -78,7 +78,7 @@ public function __construct( $locale ) { */ public function has_translations() { - return is_array( $this->translations ) && $this->translations !== array(); + return is_array( $this->translations ) && array() !== $this->translations; } }