Skip to content

Remove PHP type hints from methods hooked directly into WordPress add_action/add_filter#466

Merged
galbus merged 4 commits intomainfrom
s-7672-wordpress-php-type-declarations
Dec 2, 2025
Merged

Remove PHP type hints from methods hooked directly into WordPress add_action/add_filter#466
galbus merged 4 commits intomainfrom
s-7672-wordpress-php-type-declarations

Conversation

@galbus
Copy link
Copy Markdown
Contributor

@galbus galbus commented Nov 26, 2025

This pull request removes explicit type hints from method signatures across several classes in the codebase. The primary goal is to allow for greater flexibility when these methods are called, to improve compatibility with WordPress hooks and filters, which sometimes pass parameters that don't strictly match the declared types.

In a few cases, additional casting is introduced to ensure type safety within the method body.

The most important changes are:

Type Hint Removal for Compatibility:

  • Removed type hints (such as array, string, int, etc.) from public static methods in AddPlayer.php, BulkEdit.php, Settings.php, SiteHealth.php, Core.php, and Player.php, making these methods more flexible for WordPress hooks/filters. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]

Internal Type Safety Adjustments:

  • Added explicit casting to integer for $postId within methods that now accept untyped parameters, ensuring correct behavior when called with unexpected types. (onTrashPost, onDeletePost, onAddOrUpdatePost in Core.php) [1] [2] [3]

Signature Updates for Meta and Utility Methods:

  • Updated meta and utility methods to remove type hints and accept more generic parameters, such as in getLangCodeFromJsonIfEmpty and isProtectedMeta in Core.php. [1] [2]

These changes collectively make the plugin more robust and compatible with WordPress internals, which can sometimes pass parameters that don't exactly match the strict types previously declared.

@galbus galbus self-assigned this Nov 26, 2025
@galbus galbus added bug php Pull requests that update Php code labels Nov 26, 2025
@linear
Copy link
Copy Markdown

linear bot commented Nov 26, 2025

@galbus galbus merged commit 2eec4c3 into main Dec 2, 2025
4 checks passed
@galbus galbus deleted the s-7672-wordpress-php-type-declarations branch December 2, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants