Skip to content

Commit 4657895

Browse files
committed
Script Loader: Simplify data structure in wp_default_packages_vendor() to facilitate static analysis.
This resolves two PHPStan level 7 issues: `offsetAccess.notFound` and `argument.type`. Follow-up to [44114]. See #64238, #45065. git-svn-id: https://develop.svn.wordpress.org/trunk@61425 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 745a537 commit 4657895

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/wp-includes/script-loader.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,21 @@ function wp_default_packages_vendor( $scripts ) {
8888
$suffix = wp_scripts_get_suffix();
8989

9090
$vendor_scripts = array(
91-
'react',
92-
'react-dom' => array( 'react' ),
93-
'react-jsx-runtime' => array( 'react' ),
94-
'regenerator-runtime',
95-
'moment',
96-
'lodash',
97-
'wp-polyfill-fetch',
98-
'wp-polyfill-formdata',
99-
'wp-polyfill-node-contains',
100-
'wp-polyfill-url',
101-
'wp-polyfill-dom-rect',
102-
'wp-polyfill-element-closest',
103-
'wp-polyfill-object-fit',
104-
'wp-polyfill-inert',
105-
'wp-polyfill',
91+
'react' => array(),
92+
'react-dom' => array( 'react' ),
93+
'react-jsx-runtime' => array( 'react' ),
94+
'regenerator-runtime' => array(),
95+
'moment' => array(),
96+
'lodash' => array(),
97+
'wp-polyfill-fetch' => array(),
98+
'wp-polyfill-formdata' => array(),
99+
'wp-polyfill-node-contains' => array(),
100+
'wp-polyfill-url' => array(),
101+
'wp-polyfill-dom-rect' => array(),
102+
'wp-polyfill-element-closest' => array(),
103+
'wp-polyfill-object-fit' => array(),
104+
'wp-polyfill-inert' => array(),
105+
'wp-polyfill' => array(),
106106
);
107107

108108
$vendor_scripts_versions = array(
@@ -124,15 +124,13 @@ function wp_default_packages_vendor( $scripts ) {
124124
);
125125

126126
foreach ( $vendor_scripts as $handle => $dependencies ) {
127-
if ( is_string( $dependencies ) ) {
128-
$handle = $dependencies;
129-
$dependencies = array();
130-
}
131-
132-
$path = "/wp-includes/js/dist/vendor/$handle$suffix.js";
133-
$version = $vendor_scripts_versions[ $handle ];
134-
135-
$scripts->add( $handle, $path, $dependencies, $version, 1 );
127+
$scripts->add(
128+
$handle,
129+
"/wp-includes/js/dist/vendor/$handle$suffix.js",
130+
$dependencies,
131+
$vendor_scripts_versions[ $handle ],
132+
1
133+
);
136134
}
137135

138136
did_action( 'init' ) && $scripts->add_inline_script( 'lodash', 'window.lodash = _.noConflict();' );

0 commit comments

Comments
 (0)