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
This commit is contained in:
Weston Ruter
2025-12-07 04:16:33 +00:00
parent 67c33bebb7
commit 5e940f833d
5 changed files with 16 additions and 14 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -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 ) {

View File

@@ -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";

View File

@@ -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.