Make WordPress Core


Ignore:
Timestamp:
12/22/2025 08:43:17 PM (3 months ago)
Author:
westonruter
Message:

Docs: Improve specificity of PHP types in functions.wp-scripts.php and functions.wp-styles.php.

These files now adhere to PHPStan level 8.

Developed in https://github.com/WordPress/wordpress-develop/pull/10652

Follow-up to [61362], [61358].

See #64238.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.wp-scripts.php

    r60948 r61402  
    142142            '4.5.0'
    143143        );
    144         $data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) );
     144        $data = trim( (string) preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) );
    145145    }
    146146
     
    161161 * @since 6.9.0 The $fetchpriority parameter of type string was added to the $args parameter of type array.
    162162 *
    163  * @param string           $handle    Name of the script. Should be unique.
    164  * @param string|false     $src       Full URL of the script, or path of the script relative to the WordPress root directory.
    165  *                                    If source is set to false, script is an alias of other scripts it depends on.
    166  * @param string[]         $deps      Optional. An array of registered script handles this script depends on. Default empty array.
    167  * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
    168  *                                    as a query string for cache busting purposes. If version is set to false, a version
    169  *                                    number is automatically added equal to current installed WordPress version.
    170  *                                    If set to null, no version is added.
    171  * @param array|bool       $args     {
     163 * @param string                          $handle Name of the script. Should be unique.
     164 * @param string|false                    $src    Full URL of the script, or path of the script relative to the WordPress root directory.
     165 *                                                If source is set to false, script is an alias of other scripts it depends on.
     166 * @param string[]                        $deps   Optional. An array of registered script handles this script depends on. Default empty array.
     167 * @param string|bool|null                $ver    Optional. String specifying script version number, if it has one, which is added to the URL
     168 *                                                as a query string for cache busting purposes. If version is set to false, a version
     169 *                                                number is automatically added equal to current installed WordPress version.
     170 *                                                If set to null, no version is added.
     171 * @param array<string, string|bool>|bool $args   {
    172172 *     Optional. An array of additional script loading strategies. Default empty array.
    173173 *     Otherwise, it may be a boolean in which case it determines whether the script is printed in the footer. Default false.
     
    222222 * @todo Documentation cleanup
    223223 *
    224  * @param string $handle      Script handle the data will be attached to.
    225  * @param string $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable.
    226  *                            Example: '/[a-zA-Z0-9_]+/'.
    227  * @param array  $l10n        The data itself. The data can be either a single or multi-dimensional array.
     224 * @param string               $handle      Script handle the data will be attached to.
     225 * @param string               $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable.
     226 *                                          Example: '/[a-zA-Z0-9_]+/'.
     227 * @param array<string, mixed> $l10n        The data itself. The data can be either a single or multi-dimensional array.
    228228 * @return bool True if the script was successfully localized, false otherwise.
    229229 */
     
    347347 * @since 6.9.0 The $fetchpriority parameter of type string was added to the $args parameter of type array.
    348348 *
    349  * @param string           $handle    Name of the script. Should be unique.
    350  * @param string           $src       Full URL of the script, or path of the script relative to the WordPress root directory.
    351  *                                    Default empty.
    352  * @param string[]         $deps      Optional. An array of registered script handles this script depends on. Default empty array.
    353  * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
    354  *                                    as a query string for cache busting purposes. If version is set to false, a version
    355  *                                    number is automatically added equal to current installed WordPress version.
    356  *                                    If set to null, no version is added.
    357  * @param array|bool       $args     {
     349 * @param string                          $handle Name of the script. Should be unique.
     350 * @param string                          $src    Full URL of the script, or path of the script relative to the WordPress root directory.
     351 *                                                Default empty.
     352 * @param string[]                        $deps   Optional. An array of registered script handles this script depends on. Default empty array.
     353 * @param string|bool|null                $ver    Optional. String specifying script version number, if it has one, which is added to the URL
     354 *                                                as a query string for cache busting purposes. If version is set to false, a version
     355 *                                                number is automatically added equal to current installed WordPress version.
     356 *                                                If set to null, no version is added.
     357 * @param array<string, string|bool>|bool $args   {
    358358 *     Optional. An array of additional script loading strategies. Default empty array.
    359359 *     Otherwise, it may be a boolean in which case it determines whether the script is printed in the footer. Default false.
Note: See TracChangeset for help on using the changeset viewer.