Make WordPress Core

Changeset 61425


Ignore:
Timestamp:
01/03/2026 07:15:32 AM (8 months ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r61418 r61425  
    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
     
    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
Note: See TracChangeset for help on using the changeset viewer.