From 4923157aea84a28c7f8a0db8daccbc31011ac56f Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Wed, 13 May 2026 12:28:32 +0200 Subject: [PATCH] Weak typing fixed --- includes/MslsAdminIcon.php | 70 +++++++----------------------- includes/MslsAdminIconTaxonomy.php | 13 ++---- 2 files changed, 20 insertions(+), 63 deletions(-) diff --git a/includes/MslsAdminIcon.php b/includes/MslsAdminIcon.php index c45c850e2..1245c5dce 100644 --- a/includes/MslsAdminIcon.php +++ b/includes/MslsAdminIcon.php @@ -13,55 +13,17 @@ */ class MslsAdminIcon { - /** - * @var string - */ - protected $icon_type = 'action'; - - /** - * @var string - */ - protected $language; - - /** - * @var string - */ - public $origin_language; - - /** - * @var string - */ - protected $src; - - /** - * @var string - */ - protected $href; - - /** - * @var int - */ - protected $blog_id; - - /** - * @var string - */ - protected $type; - - /** - * @var string - */ - protected $path = 'post-new.php'; - - /** - * The current object ID - * - * @var int - */ - protected $id; - - const TYPE_FLAG = 'flag'; - + protected string $icon_type = 'action'; + protected string $language; + public string $origin_language; + protected string $src; + protected string $href; + protected int $blog_id; + protected string $type; + protected string $path = 'post-new.php'; + protected int $id; + + const TYPE_FLAG = 'flag'; const TYPE_LABEL = 'label'; /** @@ -70,7 +32,7 @@ class MslsAdminIcon { * @param string $type */ public function __construct( ?string $type = null ) { - $this->type = $type; + $this->type = $type ?? ''; $this->set_path(); } @@ -158,7 +120,7 @@ public function set_src( string $src ): MslsAdminIcon { * @return MslsAdminIcon */ public function set_href( int $id ): MslsAdminIcon { - $this->href = get_edit_post_link( $id ); + $this->href = get_edit_post_link( $id ) ?? ''; return $this; } @@ -227,8 +189,8 @@ public function get_a(): string { * @return bool */ protected function should_quick_create(): bool { - return null !== $this->id - && null !== $this->origin_language + return 0 !== $this->id + && '' !== $this->origin_language && msls_options()->activate_quick_create; } @@ -298,7 +260,7 @@ public function get_icon(): string { public function get_edit_new(): string { $path = $this->path; - if ( null !== $this->id && null !== $this->origin_language ) { + if ( 0 !== $this->id && '' !== $this->origin_language ) { $path = add_query_arg( array( 'msls_id' => $this->id, diff --git a/includes/MslsAdminIconTaxonomy.php b/includes/MslsAdminIconTaxonomy.php index 40efaca16..0850631ec 100644 --- a/includes/MslsAdminIconTaxonomy.php +++ b/includes/MslsAdminIconTaxonomy.php @@ -9,12 +9,7 @@ */ class MslsAdminIconTaxonomy extends MslsAdminIcon { - /** - * Path - * - * @var string - */ - protected $path = 'edit-tags.php'; + protected string $path = 'edit-tags.php'; /** * Set href @@ -27,7 +22,7 @@ class MslsAdminIconTaxonomy extends MslsAdminIcon { public function set_href( int $id ): MslsAdminIcon { $object_type = MslsTaxonomy::instance()->get_post_type(); - $this->href = get_edit_term_link( $id, $this->type, $object_type ); + $this->href = get_edit_term_link( $id, $this->type, $object_type ) ?? ''; return $this; } @@ -38,9 +33,9 @@ public function set_href( int $id ): MslsAdminIcon { * @return MslsAdminIconTaxonomy */ public function set_path(): MslsAdminIcon { - $args = array( 'taxonomy' => $this->type ); - $post_type = MslsTaxonomy::instance()->get_post_type(); + $args = array( 'taxonomy' => $this->type ); + $post_type = MslsTaxonomy::instance()->get_post_type(); if ( '' !== $post_type ) { $args['post_type'] = $post_type; }