wordpress-develop
wordpress-develop copied to clipboard
Implement PHPStan level 8 compliance for `script-loader.php`
Trac ticket: https://core.trac.wordpress.org/ticket/64238
This fixes the following PHPStan issues for level 8 compliance:
phpstan analyze --memory-limit=4G --level=8 src/wp-includes/script-loader.php
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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 28 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.