Skip to content

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Dec 14, 2025

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

This fixes the following PHPStan issues for level 8 compliance:

 ------ -------------------------------------------------------------------------------------------------------- 
  Line   functions.wp-scripts.php                                                                                
 ------ -------------------------------------------------------------------------------------------------------- 
  144    Parameter #1 $string of function trim expects string, string|null given.                                
         🪪  argument.type                                                                                       
         at src/wp-includes/functions.wp-scripts.php:144                                                         
  181    Function wp_register_script() 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/functions.wp-scripts.php:181                                                         
  230    Function wp_localize_script() has parameter $l10n 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/functions.wp-scripts.php:230                                                         
  366    Function wp_enqueue_script() 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/functions.wp-scripts.php:366                                                         
 ------ -------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------------------------------------ 
  Line   functions.wp-styles.php                                                                                                             
 ------ ------------------------------------------------------------------------------------------------------------------------------------ 
  44     Function wp_print_styles() has parameter $handles 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/functions.wp-styles.php:44                                                                                       
  68     Parameter #1 $handles of method WP_Dependencies::do_items() expects array<string>|string|false, array|bool|non-empty-string given.  
         🪪  argument.type                                                                                                                   
         at src/wp-includes/functions.wp-styles.php:68                                                                                       
  101    Parameter #1 $string of function trim expects string, string|null given.                                                            
         🪪  argument.type                                                                                                                   
         at src/wp-includes/functions.wp-styles.php:101                                                                                      
 ------ ------------------------------------------------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  Line   script-loader.php                                                                                                                                                             
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 
  133    Offset                                                                                                                                                                        
         0|1|2|3|4|5|6|7|8|9|10|11|12|'lodash'|'moment'|'react'|'react-dom'|'react-jsx-runtime'|'regenerator-runtime'|'wp-polyfill'|'wp-polyfill-dom-rect'|'wp-polyfill-element…'|'wp  
         -polyfill-fetch'|'wp-polyfill-formdata'|'wp-polyfill-inert'|'wp-polyfill-node…'|'wp-polyfill-object…'|'wp-polyfill-url' might not exist on array{react: '18.3.1.1',           
         react-dom: '18.3.1.1', react-jsx-runtime: '18.3.1', regenerator-runtime: '0.14.1', moment: '2.30.1', lodash: '4.17.21', wp-polyfill-fetch: '3.6.20', wp-polyfill-formdata:    
         '4.0.10', ...}.                                                                                                                                                               
         🪪  offsetAccess.notFound                                                                                                                                                     
         at src/wp-includes/script-loader.php:133                                                                                                                                      
  135    Parameter #1 $handle of method WP_Dependencies::add() expects string, int|string given.                                                                                       
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:135                                                                                                                                      
  191    Parameter #1 $haystack of function str_starts_with expects string, string|false given.                                                                                        
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:191                                                                                                                                      
  191    Parameter #2 $subject of function preg_match expects string, string|false given.                                                                                              
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:191                                                                                                                                      
  700    Variable $wp_version might not be defined.                                                                                                                                    
         🪪  variable.undefined                                                                                                                                                        
         at src/wp-includes/script-loader.php:700                                                                                                                                      
  1089   Parameter #1 $string of function strtolower expects string, string|false given.                                                                                               
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:1089                                                                                                                                     
  1564   Variable $wp_version might not be defined.                                                                                                                                    
         🪪  variable.undefined                                                                                                                                                        
         at src/wp-includes/script-loader.php:1564                                                                                                                                     
  1608   Parameter #2 $src of method WP_Dependencies::add() expects string|false, true given.                                                                                          
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:1608                                                                                                                                     
  1907   Parameter #2 $offset of function array_splice expects int, int|string given.                                                                                                  
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:1907                                                                                                                                     
  2083   Function wp_style_loader_src() should return string|false but returns string|null.                                                                                            
         🪪  return.type                                                                                                                                                               
         at src/wp-includes/script-loader.php:2083                                                                                                                                     
  2357   Function print_late_styles() 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/script-loader.php:2357                                                                                                                                     
  2514   Function wp_filter_out_block_nodes() has parameter $nodes 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-loader.php:2514                                                                                                                                     
  2514   Function wp_filter_out_block_nodes() 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/script-loader.php:2514                                                                                                                                     
  2875   Function wp_sanitize_script_attributes() has parameter $attributes 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-loader.php:2875                                                                                                                                     
  2907   Function wp_get_script_tag() has parameter $attributes 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-loader.php:2907                                                                                                                                     
  2939   Function wp_print_script_tag() has parameter $attributes 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-loader.php:2939                                                                                                                                     
  2955   Function wp_get_inline_script_tag() has parameter $attributes 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-loader.php:2955                                                                                                                                     
  3043   Function wp_print_inline_script_tag() has parameter $attributes 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-loader.php:3043                                                                                                                                     
  3081   Call to an undefined method object::get_data().                                                                                                                               
         🪪  method.notFound                                                                                                                                                           
         at src/wp-includes/script-loader.php:3081                                                                                                                                     
  3099   Parameter #1 $array of function usort contains unresolvable type.                                                                                                             
         🪪  argument.unresolvableType                                                                                                                                                 
         at src/wp-includes/script-loader.php:3099                                                                                                                                     
  3100   Parameter #2 $callback of function usort contains unresolvable type.                                                                                                          
         🪪  argument.unresolvableType                                                                                                                                                 
         at src/wp-includes/script-loader.php:3100                                                                                                                                     
  3128   Parameter #1 $css of function _wp_normalize_relative_css_links expects string, string|false given.                                                                            
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:3128                                                                                                                                     
  3158   Function _wp_normalize_relative_css_links() should return string but returns string|null.                                                                                     
         🪪  return.type                                                                                                                                                               
         at src/wp-includes/script-loader.php:3158                                                                                                                                     
  3244   Function wp_enqueue_stored_styles() has parameter $options 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-loader.php:3244                                                                                                                                     
  3318   Function wp_enqueue_block_style() 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-loader.php:3318                                                                                                                                     
  3756   Parameter #3 $priority of function remove_action expects int, int|true given.                                                                                                 
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:3756                                                                                                                                     
  3763   Parameter #3 $priority of function add_action expects int, int|true given.                                                                                                    
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:3763                                                                                                                                     
  3846   Parameter #1 $text of method WP_HTML_Tag_Processor@anonymous/script-loader.php:3773::insert_after() expects string, string|false given.                                       
         🪪  argument.type                                                                                                                                                             
         at src/wp-includes/script-loader.php:3846                                                                                                                                     
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

 [ERROR] Found 35 errors                                                                                                

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.

…ctions.wp-scripts.php, and script-loader.php
@github-actions
Copy link

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.

),
'7.0.0'
);
continue;
Copy link
Member Author

Choose a reason for hiding this comment

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

I should add a unit test for this.

'tinymce_version',
'required_php_version',
'required_php_extensions'
);
Copy link
Member Author

Choose a reason for hiding this comment

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

Warrants a unit test.

@github-actions
Copy link

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.

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