WordPress / WordPress/WordPress-Coding-Standards
Sniff to check for the unused parameters in hooks
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem?
A lot of times plugin and theme authors add hook callbacks but fail to provide all the necessary parameters. For instance, in custom widgets (taken from the WPThemeReview issue):
$title = apply_filters( 'widget_title', $title );
and according to the documentation, there should exist two extra parameters:
$title = apply_filters( 'widget_title', $title, $instance, $id_base );
Describe the solution you'd like
A solution would be to have a sniff that checks if any of the core WP hooks, that are invoked in the plugin or theme, have the correct amount of parameters passed as in the hook definition.
We would rely on the utility sniff that would check for all the core hooks, which would be a part of #1803 issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review issue #1803 and the linked WordPress hook documentation first, since the requested sniff depends on a utility that identifies core hooks. Define how hook invocations and their expected parameters should be compared, then verify that valid and incomplete calls are distinguished by the resulting sniff tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100