Empty list of arguments when `apply_filters` is used in a conditional clause instead of assigned to a variable
LuigiPulcini opened this issue · 2 comments
LuigiPulcini commented
This issue is similar to #11.
The list of arguments is empty when apply_filters
is used inside a conditional clause instead of assigned to a variable first.
So, when using the right doc block, the following code doesn't output the correct result:
if ( apply_filters( 'some_condition_filter', $some_condition, $some_other_parameter ) ) {
do_something();
}
and must be replaced with as follows:
$some_condition = apply_filters( 'some_condition_filter', $some_condition, $some_other_parameter );
if ( $some_condition ) {
do_something();
}
remcotolsma commented
I just created a test for this issue:
wp-documentor/tests/issue-17/test-issue-17.php
Lines 1 to 21 in 3626ead
The arguments table is not empty?
wp-documentor/tests/issue-17/hooks.md
Lines 10 to 23 in 3626ead
Or am I seeing this wrong @LuigiPulcini?
irshadahmad21 commented
Same happens when casting the value returned by apply_filters
$should_do = (bool) apply_filters( 'should_we_do_it', true, $some_value );