Skip to content

Fix weak typing#630

Merged
lloc merged 1 commit into
masterfrom
fix/weak_typing
May 13, 2026
Merged

Fix weak typing#630
lloc merged 1 commit into
masterfrom
fix/weak_typing

Conversation

@lloc
Copy link
Copy Markdown
Owner

@lloc lloc commented May 13, 2026

No description provided.

@lloc lloc merged commit 79a9b12 into master May 13, 2026
3 of 4 checks passed
@lloc lloc deleted the fix/weak_typing branch May 13, 2026 11:16
@github-actions
Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
24 0 24

⚠️ Warnings (24)

📁 includes/MslsCustomFilter.php (1 warning)
📍 Line 🔖 Check 💬 Message
86 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
📁 includes/MslsRestApi.php (1 warning)
📍 Line 🔖 Check 💬 Message
405 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
📁 includes/MslsTranslationPickerTable.php (1 warning)
📍 Line 🔖 Check 💬 Message
180 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
📁 includes/MslsWidget.php (1 warning)
📍 Line 🔖 Check 💬 Message
58 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATIVE_CONTENT_HOOK".
📁 includes/MslsAdmin.php (2 warnings)
📍 Line 🔖 Check 💬 Message
247 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_REGISTER_ACTION".
347 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ACTION_PREFIX . $section".
📁 includes/Map/HrefLang.php (1 warning)
📍 Line 🔖 Check 💬 Message
69 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_HEAD_HREFLANG_HOOK".
📁 includes/MslsBlog.php (3 warnings)
📍 Line 🔖 Check 💬 Message
143 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_PERMALINK_HOOK".
147 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_PERMALINK_HOOK".
201 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK".
📁 includes/Component/Input/Select.php (1 warning)
📍 Line 🔖 Check 💬 Message
39 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::RENDER_FILTER".
📁 includes/MslsPostTagClassic.php (2 warnings)
📍 Line 🔖 Check 💬 Message
39 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ADD_INPUT_ACTION".
71 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_EDIT_INPUT_ACTION".
📁 includes/MslsMain.php (1 warning)
📍 Line 🔖 Check 💬 Message
143 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_SAVE_ACTION".
📁 includes/MslsPostTag.php (2 warnings)
📍 Line 🔖 Check 💬 Message
136 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ADD_INPUT_ACTION".
171 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_EDIT_INPUT_ACTION".
📁 includes/MslsOutput.php (6 warnings)
📍 Line 🔖 Check 💬 Message
96 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_HOOK".
125 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATE_LINKS_HOOK".
141 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATE_LINKS_DEFAULT_HOOK".
144 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_ALTERNATE_LINKS_ARR_HOOK".
157 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_NO_TRANSLATION_FOUND_HOOK".
188 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_GET_TAGS_HOOK".
📁 includes/ContentImport/ContentImporter.php (2 warnings)
📍 Line 🔖 Check 💬 Message
295 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_BEFORE_IMPORT_ACTION".
356 WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "self::MSLS_AFTER_IMPORT_ACTION".

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances type safety and code robustness by introducing return type hints, initializing class properties, and implementing stricter validation for WordPress objects such as WP_Post_Type and WP_Term. The review feedback identifies a potential warning when accessing the rewrite property as an array and recommends adding an explicit array type hint to the __call magic method for consistency.

Comment thread includes/MslsAdmin.php
Comment on lines +437 to +438
$rewrite = $pt_object ? $pt_object->rewrite : array();
$value = $rewrite['slug'] ?? '';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The rewrite property of a WP_Post_Type object can be false if rewrites are disabled. In that case, $rewrite would be assigned false, and attempting to access $rewrite['slug'] would result in a warning: "Cannot use a scalar value as an array".

To handle this correctly, you should check if $rewrite is an array before trying to access an element from it.

$rewrite   = $pt_object ? $pt_object->rewrite : null;
		$value     = is_array( $rewrite ) ? ( $rewrite['slug'] ?? '' ) : '';

Comment thread includes/MslsAdmin.php
* @return mixed
*/
public function __call( $method, $args ) {
public function __call( string $method, $args ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the PHP documentation for the __call magic method, the second argument should be an array of the arguments passed to the method. It's good practice to type-hint it as array for better code clarity and robustness, especially in a PR focused on strengthening types.

public function __call( string $method, array $args ) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant