-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPDoc improvement #91
Conversation
inc/api.php
Outdated
@@ -333,7 +333,7 @@ function expectApplied($filter) | |||
* | |||
* @param string $filter | |||
* @param null $callback | |||
* @return bool | |||
* @return false|int Return hook priority or false if hook was not added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is right.
If I do has_filter( 'the_content', 'my_filter' )
, I will either get false
, if the filter callback has not been added, or the priority, if it did.
However, if I don't pass a callback, and just ask for something like has_filter( 'the_content' )
, I would expect to get either true
or false
...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also was confused about this. But this function works as counter part of Worpdress has filter
, isn't it?
https://core.trac.wordpress.org/browser/tags/5.6/src/wp-includes/plugin.php#L132
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rechecked code: yes, can return true
:
https://github.com/Brain-WP/BrainMonkey/blob/master/src/Hook/HookStorage.php#L217
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed the proper doc should be bool|int
because the function is the counter part of WordPress has_filter
, and even if WordPress has_filter
is documented as false|int
it actually returns true
when no callback is given and there's at least a callback attached.
In fact, WordPress has_filter
calls WP_Hook::has_filter
which, when no callback is given, calls WP_Hook::has_filters
, which will return true
if any callback is there.
So @shvlv would you mind to change the doc-block to bool|int
so I can merge?
Thanks @tfrommen for looking into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmazzap Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shvlv
Сlearer return type for \Brain\Monkey\Filters\has function.