Commit 5e940f833d for wordpress.org
commit 5e940f833dcb5a5e878accff0950df3d7f43a8ff
Author: Weston Ruter <weston@xwp.co>
Date: Sun Dec 7 04:16:33 2025 +0000
Docs: Improve accuracy for types in phpdoc for `WP_Dependencies`, `_WP_Dependency`, `WP_Scripts`, and `WP_Styles`.
This increases these classes to PHPStan level 8.
Developed in https://github.com/WordPress/wordpress-develop/pull/10607
See #64238.
Built from https://develop.svn.wordpress.org/trunk@61358
git-svn-id: http://core.svn.wordpress.org/trunk@60670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-dependencies.php b/wp-includes/class-wp-dependencies.php
index 92c277e86f..c3dc40bc88 100644
--- a/wp-includes/class-wp-dependencies.php
+++ b/wp-includes/class-wp-dependencies.php
@@ -56,11 +56,12 @@ class WP_Dependencies {
/**
* An array of additional arguments passed when a handle is registered.
*
- * Arguments are appended to the item query string.
+ * The keys are dependency handles and the values are query strings which are appended to the item URL's query
+ * string, after the `ver` if provided.
*
* @since 2.6.0
*
- * @var array
+ * @var array<string, string>
*/
public $args = array();
@@ -100,7 +101,7 @@ class WP_Dependencies {
*
* @since 5.9.0
*
- * @var array
+ * @var array<string, string|null>
*/
private $queued_before_register = array();
diff --git a/wp-includes/class-wp-dependency.php b/wp-includes/class-wp-dependency.php
index 6666b166af..4900bf737d 100644
--- a/wp-includes/class-wp-dependency.php
+++ b/wp-includes/class-wp-dependency.php
@@ -66,7 +66,7 @@ class _WP_Dependency {
* Extra data to supply to the handle.
*
* @since 2.6.0
- * @var array
+ * @var array<string, mixed>
*/
public $extra = array();
@@ -82,7 +82,7 @@ class _WP_Dependency {
* Translation path set for this dependency.
*
* @since 5.0.0
- * @var string
+ * @var string|null
*/
public $translations_path;
diff --git a/wp-includes/class-wp-scripts.php b/wp-includes/class-wp-scripts.php
index 3e7908095e..1326627404 100644
--- a/wp-includes/class-wp-scripts.php
+++ b/wp-includes/class-wp-scripts.php
@@ -46,7 +46,7 @@ class WP_Scripts extends WP_Dependencies {
* Holds handles of scripts which are enqueued in footer.
*
* @since 2.8.0
- * @var array
+ * @var string[]
*/
public $in_footer = array();
@@ -118,7 +118,7 @@ class WP_Scripts extends WP_Dependencies {
* List of default directories.
*
* @since 2.8.0
- * @var array
+ * @var string[]|null
*/
public $default_dirs;
@@ -374,7 +374,8 @@ class WP_Scripts extends WP_Dependencies {
$filtered_src = apply_filters( 'script_loader_src', $src, $handle );
if (
- $this->in_default_dir( $filtered_src )
+ is_string( $filtered_src )
+ && $this->in_default_dir( $filtered_src )
&& ( $before_script || $after_script || $translations_stop_concat || $this->is_delayed_strategy( $strategy ) )
) {
$this->do_concat = false;
@@ -589,9 +590,9 @@ class WP_Scripts extends WP_Dependencies {
*
* @since 2.1.0
*
- * @param string $handle Name of the script to attach data to.
- * @param string $object_name Name of the variable that will contain the data.
- * @param array $l10n Array of data to localize.
+ * @param string $handle Name of the script to attach data to.
+ * @param string $object_name Name of the variable that will contain the data.
+ * @param array<string, mixed> $l10n Array of data to localize.
* @return bool True on success, false on failure.
*/
public function localize( $handle, $object_name, $l10n ) {
diff --git a/wp-includes/class-wp-styles.php b/wp-includes/class-wp-styles.php
index 455f1c986e..2af3581d9a 100644
--- a/wp-includes/class-wp-styles.php
+++ b/wp-includes/class-wp-styles.php
@@ -96,7 +96,7 @@ class WP_Styles extends WP_Dependencies {
* List of default directories.
*
* @since 2.8.0
- * @var array
+ * @var string[]|null
*/
public $default_dirs;
@@ -183,7 +183,7 @@ class WP_Styles extends WP_Dependencies {
}
if ( $this->do_concat ) {
- if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
+ if ( is_string( $src ) && $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
$this->concat .= "$handle,";
$this->concat_version .= "$handle$ver";
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 238bc553af..7980ce7acf 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61357';
+$wp_version = '7.0-alpha-61358';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.