Skip to content

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

Open
@thomasnares

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 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 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions