Skip to content
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

Hook docblocks #398

Closed
1 task done
szepeviktor opened this issue Sep 19, 2024 · 2 comments
Closed
1 task done

Hook docblocks #398

szepeviktor opened this issue Sep 19, 2024 · 2 comments
Labels
type:bug Something isn’t working.

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Sep 19, 2024

Describe the bug

Hook docblocks are not standard (compared to WordPress core, PHPStan)

/**
* Valid status codes to redirect with.
*
* @hook srm_valid_status_codes
* @param {array} $status_codes Valid status codes to redirect with. Default array( 301, 302, 303, 307, 403, 404, 410 ) and other codes returned by `srm_additional_status_codes` filter hook.
* @returns {array} Filtered valid status codes.
*/
return apply_filters( 'srm_valid_status_codes', array_keys( srm_get_valid_status_codes_data() ) );

Steps to Reproduce

  • There is no need to declare the hook name in the docblock
  • The first @param is the third parameter of apply_filters, the first one is the hook name, the second one is the initial value
  • Current docblock is a JSDoc block, not PHPDoc

Would you merge a PR fixing all those?

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@szepeviktor szepeviktor added the type:bug Something isn’t working. label Sep 19, 2024
@dkotter
Copy link
Collaborator

dkotter commented Sep 19, 2024

  • There is no need to declare the hook name in the docblock
  • The first @param is the third parameter of apply_filters, the first one is the hook name, the second one is the initial value
  • Current docblock is a JSDoc block, not PHPDoc

All of these are expected as we use the wp-hookdoc tool to automatically create a documentation site (see https://10up.github.io/safe-redirect-manager/).

wp-hookdoc utilizes JSDoc to process these comments, which is why these docblocks are different from what we use on functions or methods.

We are exploring a new tool to automate this documentation but there's no timeline on when that will happen, so going to close this out.

@dkotter dkotter closed this as completed Sep 19, 2024
@szepeviktor
Copy link
Contributor Author

I see. That project is abandoned 6 years ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn’t working.
Projects
Archived in project
Development

No branches or pull requests

2 participants