Skip to content

Commit 296a840

Browse files
committed
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 #10607 See #64238. git-svn-id: https://develop.svn.wordpress.org/trunk@61358 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2d2911d commit 296a840

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/wp-includes/class-wp-dependencies.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,12 @@ class WP_Dependencies {
5656
/**
5757
* An array of additional arguments passed when a handle is registered.
5858
*
59-
* Arguments are appended to the item query string.
59+
* The keys are dependency handles and the values are query strings which are appended to the item URL's query
60+
* string, after the `ver` if provided.
6061
*
6162
* @since 2.6.0
6263
*
63-
* @var array
64+
* @var array<string, string>
6465
*/
6566
public $args = array();
6667

@@ -100,7 +101,7 @@ class WP_Dependencies {
100101
*
101102
* @since 5.9.0
102103
*
103-
* @var array
104+
* @var array<string, string|null>
104105
*/
105106
private $queued_before_register = array();
106107

src/wp-includes/class-wp-dependency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _WP_Dependency {
6666
* Extra data to supply to the handle.
6767
*
6868
* @since 2.6.0
69-
* @var array
69+
* @var array<string, mixed>
7070
*/
7171
public $extra = array();
7272

@@ -82,7 +82,7 @@ class _WP_Dependency {
8282
* Translation path set for this dependency.
8383
*
8484
* @since 5.0.0
85-
* @var string
85+
* @var string|null
8686
*/
8787
public $translations_path;
8888

src/wp-includes/class-wp-scripts.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class WP_Scripts extends WP_Dependencies {
4646
* Holds handles of scripts which are enqueued in footer.
4747
*
4848
* @since 2.8.0
49-
* @var array
49+
* @var string[]
5050
*/
5151
public $in_footer = array();
5252

@@ -118,7 +118,7 @@ class WP_Scripts extends WP_Dependencies {
118118
* List of default directories.
119119
*
120120
* @since 2.8.0
121-
* @var array
121+
* @var string[]|null
122122
*/
123123
public $default_dirs;
124124

@@ -374,7 +374,8 @@ public function do_item( $handle, $group = false ) {
374374
$filtered_src = apply_filters( 'script_loader_src', $src, $handle );
375375

376376
if (
377-
$this->in_default_dir( $filtered_src )
377+
is_string( $filtered_src )
378+
&& $this->in_default_dir( $filtered_src )
378379
&& ( $before_script || $after_script || $translations_stop_concat || $this->is_delayed_strategy( $strategy ) )
379380
) {
380381
$this->do_concat = false;
@@ -589,9 +590,9 @@ public function get_inline_script_tag( $handle, $position = 'after' ) {
589590
*
590591
* @since 2.1.0
591592
*
592-
* @param string $handle Name of the script to attach data to.
593-
* @param string $object_name Name of the variable that will contain the data.
594-
* @param array $l10n Array of data to localize.
593+
* @param string $handle Name of the script to attach data to.
594+
* @param string $object_name Name of the variable that will contain the data.
595+
* @param array<string, mixed> $l10n Array of data to localize.
595596
* @return bool True on success, false on failure.
596597
*/
597598
public function localize( $handle, $object_name, $l10n ) {

src/wp-includes/class-wp-styles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class WP_Styles extends WP_Dependencies {
9696
* List of default directories.
9797
*
9898
* @since 2.8.0
99-
* @var array
99+
* @var string[]|null
100100
*/
101101
public $default_dirs;
102102

@@ -183,7 +183,7 @@ public function do_item( $handle, $group = false ) {
183183
}
184184

185185
if ( $this->do_concat ) {
186-
if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
186+
if ( is_string( $src ) && $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
187187
$this->concat .= "$handle,";
188188
$this->concat_version .= "$handle$ver";
189189

0 commit comments

Comments
 (0)