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

Move "global variable" related utilities to dedicated WPGlobalVariablesHelper #2159

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 19, 2022

The "global variable" related utilities are only used by a small number of sniffs, so are better placed in a dedicated class.

This commit moves the $wp_globals property to a new WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper and starts using that class in the relevant sniffs.

Note:

  • The property is now private (and static). This protects the property against inadvertent changes.
  • Access to the property can be obtained via the new WPGlobalVariablesHelper::get_names() method.
  • Alternatively, the new WPGlobalVariablesHelper::is_wp_global() method can be used to check if a given variable name is the name of a WP global variable.

Related to #1465

Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…lesHelper`

The "global variable" related utilities are only used by a small number of sniffs, so are better placed in a dedicated class.

This commit moves the `$wp_globals` property to a new `WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper` and starts using that class in the relevant sniffs.

Note:
* The property is now `private` (and `static`).
    This protects the property against inadvertent changes.
* Access to the property can be obtained via the new `WPGlobalVariablesHelper::get_names()` method.
* Alternatively, the new `WPGlobalVariablesHelper::is_wp_global()` method can be used to check is a given variable name is the name of a WP global variable.

Related to 1465
@jrfnl jrfnl force-pushed the feature/move-wp-global-list-to-helper-class branch from 00b3764 to 38152a4 Compare December 19, 2022 21:32
@dingo-d dingo-d merged commit 146ae94 into develop Dec 20, 2022
@dingo-d dingo-d deleted the feature/move-wp-global-list-to-helper-class branch December 20, 2022 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants