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

New WPHookHelper utility class, incl PHP 8.0+ named param helper #2148

Merged
merged 3 commits into from
Dec 15, 2022

Commits on Dec 14, 2022

  1. Sniff: remove the $hookFunctions property

    ... as it is not currently used anywhere in the WPCS codebase.
    jrfnl committed Dec 14, 2022
    Configuration menu
    Copy the full SHA
    8349f90 View commit details
    Browse the repository at this point in the history
  2. Move "hook" related utilities to dedicated WPHookHelper

    The "hook" related property is only used by a small set of sniffs, so are better placed in a dedicated class.
    
    This commit moves the `$hookInvokeFunctions` property to a new `WordPressCS\WordPress\Helpers\WPHookHelper` class and starts using that class in the relevant sniffs.
    
    Note:
    * The property is now `private` (and `static`).
    * Access to the property can be obtained via the new `WPHookHelper::get_functions()` method.
    * This new method can also pre-filter the list to only return thos functions which are not specifically to invoke deprecated hooks.
    
    Related to 1465
    jrfnl committed Dec 14, 2022
    Configuration menu
    Copy the full SHA
    610d371 View commit details
    Browse the repository at this point in the history
  3. WPHookHelper: add new get_hook_name_param() method

    ... to support retrieving the hook name parameters from a stack of parameters, while supporting PHP 8.0+ function calls using named arguments.
    
    This new method will be tested via the implementations in the `ValidHookName` and the `PrefixAllGlobals` sniffs.
    jrfnl committed Dec 14, 2022
    Configuration menu
    Copy the full SHA
    73ea966 View commit details
    Browse the repository at this point in the history