Open
Description
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
andarray_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 ?
Metadata
Assignees
Labels
No labels
Activity