WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#47407 assigned enhancement

Documentation `tests_add_filter` function incorrect

Reported by: remcotolsma Owned by: SergeyBiryukov
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch
Focuses: Cc:

Description

In https://core.trac.wordpress.org/changeset/43555 some documentation was added for the tests_add_filter function. According the documentation the second parameter $function_to_add should be an array or an object:

@param object|array $function_to_add The function/callback to execute on call.

Should this not be changed to callable? Same as the add_filter function?
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/plugin.php#L99

Scrutinizer is complaining about this:

'_manually_load_plugin' of type string is incompatible with the type array|object expected by parameter $function_to_add of tests_add_filter().

https://scrutinizer-ci.com/g/pronamic/wp-money/inspections/3724dc22-f4fb-46cd-90bc-0928063ae820/issues/files/tests/bootstrap.php?status=failed&conditionIds%5B0%5D=367219#

Change History (1)

#1 @dkarfa
3 months ago

<?php
        
tests_add_filter( 'muplugins_loaded', array( $this, '_manually_load_plugin' ) );

public function _manually_load_plugin() {
    // Function to do.
} 
Note: See TracTickets for help on using tickets.