Make WordPress Core


Ignore:
Timestamp:
11/29/2019 09:40:58 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Correct @param type for the function parameter in tests_add_filter() and _test_filter_build_unique_id().

Synchronize documentation for add_filter(), tests_add_filter(), _wp_filter_build_unique_id(), _test_filter_build_unique_id().

Add a note that $tag and $priority are no longer used in _wp_filter_build_unique_id() since [46220], and the function always returns a string now.

Props donmhico, remcotolsma, SergeyBiryukov.
Fixes #47407. See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/functions.php

    r46586 r46801  
    3939 * Adds hooks before loading WP.
    4040 *
    41  * @param string       $tag             The name for the filter to add.
    42  * @param object|array $function_to_add The function/callback to execute on call.
    43  * @param int          $priority        The priority.
    44  * @param int          $accepted_args   The amount of accepted arguments.
    45  * @return bool Always true.
     41 * @see add_filter()
     42 *
     43 * @param string   $tag             The name of the filter to hook the $function_to_add callback to.
     44 * @param callable $function_to_add The callback to be run when the filter is applied.
     45 * @param int      $priority        Optional. Used to specify the order in which the functions
     46 *                                  associated with a particular action are executed.
     47 *                                  Lower numbers correspond with earlier execution,
     48 *                                  and functions with the same priority are executed
     49 *                                  in the order in which they were added to the action. Default 10.
     50 * @param int      $accepted_args   Optional. The number of arguments the function accepts. Default 1.
     51 * @return true
    4652 */
    4753function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
     
    5157        add_filter( $tag, $function_to_add, $priority, $accepted_args );
    5258    } else {
    53         $idx                                    = _test_filter_build_unique_id( $tag, $function_to_add, $priority );
     59        $idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority );
     60
    5461        $wp_filter[ $tag ][ $priority ][ $idx ] = array(
    5562            'function'      => $function_to_add,
     
    6370 * Generates a unique function ID based on the given arguments.
    6471 *
    65  * @param string       $tag      Unused. The name of the filter to build ID for.
    66  * @param object|array $function The function to generate ID for.
    67  * @param int          $priority Unused. The priority.
    68  * @return string Unique function ID.
     72 * @see _wp_filter_build_unique_id()
     73 *
     74 * @param string   $tag      Unused. The name of the filter to build ID for.
     75 * @param callable $function The function to generate ID for.
     76 * @param int      $priority Unused. The order in which the functions
     77 *                           associated with a particular action are executed.
     78 * @return string Unique function ID for usage as array key.
    6979 */
    7080function _test_filter_build_unique_id( $tag, $function, $priority ) {
     
    8191
    8292    if ( is_object( $function[0] ) ) {
     93        // Object class calling.
    8394        return spl_object_hash( $function[0] ) . $function[1];
    8495    } elseif ( is_string( $function[0] ) ) {
    85         // Static Calling.
     96        // Static calling.
    8697        return $function[0] . $function[1];
    8798    }
Note: See TracChangeset for help on using the changeset viewer.