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

Refactor the script to extract hooks, to ensure devdocs is up to date #1771

Open
3 tasks
thomasnares opened this issue Dec 27, 2023 · 0 comments
Open
3 tasks

Comments

@thomasnares
Copy link
Contributor

thomasnares commented Dec 27, 2023

Maintaining hook list in the docs is mandatory, and this list constantly evolves on each:

  • core release
  • themes update
  • modules update

A PR is currently in draft here: #1741

This script tries to find hook with regexes in all files in a release zip archive, or in a directory (to add hummingbird for example, as it is not yet included in the releases).

Regexes are hard to maintain and hard to write.

The best approach would be to parse the php code with a library to avoid those regexes.

Issues with this script:

  • Fix some regexes to match hooks in codebase (you must scan all files, and identify where hooks are called)
  • Fix the name cleaning array (linked with regex matching)
  • Detect if hooks uses check_exceptions, chain and array_return

I'm still not sure we can match all hooks with regexes against the codebase.

Solution

Another approach would be to refactor the HookFinder with the famous php-parser library which produces AST : https://github.com/nikic/php-parser (the one used by PHPStan to detect bugs).

Possible caveats

  • Will it parse correctly smarty or twig files ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant