Improve specificity of phpdoc types in WP_Script_Modules and functions in script-modules.php
#10614
+104
−104
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses the following PHPStan level 6 issues:
Trac ticket: https://core.trac.wordpress.org/ticket/64238
Gemini summary:
The changes observed in
src/wp-includes/class-wp-script-modules.phpandsrc/wp-includes/script-modules.phpare focused on enhancing PHPDoc type hints. Specifically,arraytype declarations have been refined using PHPStan's PHPDoc Types, which aligns perfectly with the WordPress coding standards outlined inGEMINI.mdregarding PHPStan Level 10 compliance.Specific observations:
arraytype declarations for$depsand$argsparameters have been updated toarray<string|array>andarray<string, string|bool>respectively. This provides more precise information about the expected structure of these arrays, which is a significant improvement for static analysis.get_import_map(),get_marked_for_enqueue(), andget_dependencies()methods have been updated with detailedarrayshapes, such asarray<string, array<string, string>>andarray<string, array<string, mixed>>. This greatly improves the clarity and maintainability of the code.@sinceTags: All@sincetags are correctly present and reflect the versions6.5.0and6.9.0where the changes (or parameters) were introduced.testsdirectory were modified, so the requirement to check for@tickettags is not applicable here.Overall:
The changes are well-aligned with the project's stated coding standards, specifically regarding the use of PHPStan's PHPDoc types. The increased type specificity will benefit static analysis, code understanding, and future maintenance. The changes are precise and introduce no regressions or compatibility issues.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.