Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Dec 9, 2025

This addresses the following PHPStan level 6 issues:

 ------ --------------------------------------------------------------------------------------------------------------- 
  Line   class-wp-script-modules.php                                                                                    
 ------ --------------------------------------------------------------------------------------------------------------- 
  122    Method WP_Script_Modules::register() has parameter $args with no value type specified in iterable type array.       
         🪪  missingType.iterableValue                                                                                       
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                          
         at src/wp-includes/class-wp-script-modules.php:122                                                                  
  294    Method WP_Script_Modules::enqueue() has parameter $args with no value type specified in iterable type array.        
         🪪  missingType.iterableValue                                                                                       
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                          
         at src/wp-includes/class-wp-script-modules.php:294                                                                  
  540    Method WP_Script_Modules::get_import_map() return type has no value type specified in iterable type array.          
         🪪  missingType.iterableValue                                                                                       
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                          
         at src/wp-includes/class-wp-script-modules.php:540                                                                  
  561    Method WP_Script_Modules::get_marked_for_enqueue() return type has no value type specified in iterable type array.  
         🪪  missingType.iterableValue                                                                                       
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                          
         at src/wp-includes/class-wp-script-modules.php:561                                                                  
  582    Method WP_Script_Modules::get_dependencies() return type has no value type specified in iterable type array.        
         🪪  missingType.iterableValue                                                                                       
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                          
         at src/wp-includes/class-wp-script-modules.php:582   

 ------ --------------------------------------------------------------------------------------------------------------- 
  Line   script-modules.php                                                                                             
 ------ --------------------------------------------------------------------------------------------------------------- 
  71     Function wp_register_script_module() has parameter $args with no value type specified in iterable type array.  
         🪪  missingType.iterableValue                                                                                  
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                     
         at src/wp-includes/script-modules.php:71                                                                       
  115    Function wp_enqueue_script_module() has parameter $args with no value type specified in iterable type array.   
         🪪  missingType.iterableValue                                                                                  
         💡  See: https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-iterable-type                     
         at src/wp-includes/script-modules.php:115                                                                      

Trac ticket: https://core.trac.wordpress.org/ticket/64238

Gemini summary:

The changes observed in src/wp-includes/class-wp-script-modules.php and src/wp-includes/script-modules.php are focused on enhancing PHPDoc type hints. Specifically, array type declarations have been refined using PHPStan's PHPDoc Types, which aligns perfectly with the WordPress coding standards outlined in GEMINI.md regarding PHPStan Level 10 compliance.

Specific observations:

  • PHPDoc Type Hinting: The array type declarations for $deps and $args parameters have been updated to array<string|array> and array<string, string|bool> respectively. This provides more precise information about the expected structure of these arrays, which is a significant improvement for static analysis.
  • Return Type Hinting: Similarly, the return types for get_import_map(), get_marked_for_enqueue(), and get_dependencies() methods have been updated with detailed array shapes, such as array<string, array<string, string>> and array<string, array<string, mixed>>. This greatly improves the clarity and maintainability of the code.
  • @since Tags: All @since tags are correctly present and reflect the versions 6.5.0 and 6.9.0 where the changes (or parameters) were introduced.
  • PHP 7.2 Compatibility: Since these modifications are strictly within PHPDoc comments and do not alter the underlying PHP syntax, there are no concerns regarding compatibility with PHP 7.2.
  • Test Files: No files within the tests directory were modified, so the requirement to check for @ticket tags 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.

@github-actions
Copy link

github-actions bot commented Dec 9, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter westonruter changed the title Improve specificity of phpdoc types in WP_Script_Module Improve specificity of phpdoc types in WP_Script_Modules Dec 9, 2025
@westonruter westonruter changed the title Improve specificity of phpdoc types in WP_Script_Modules Improve specificity of phpdoc types in WP_Script_Modules and functions in script-modules.php Dec 9, 2025
@github-actions
Copy link

github-actions bot commented Dec 9, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

pento pushed a commit that referenced this pull request Dec 9, 2025
…-modules.php` functions.

Developed in #10614

Follow-up to [61358].

See #64238.


git-svn-id: https://develop.svn.wordpress.org/trunk@61362 602fd350-edb4-49c9-b593-d223f7449a82
@westonruter
Copy link
Member Author

Committed in r61362.

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