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

PrefixAllGlobals: sniff should check for two-letter prefixes #1733

Closed
Ipstenu opened this issue Jun 20, 2019 · 3 comments · Fixed by #1741
Closed

PrefixAllGlobals: sniff should check for two-letter prefixes #1733

Ipstenu opened this issue Jun 20, 2019 · 3 comments · Fixed by #1741
Labels
Component: Extra Focus: WP interoperability Doing things the WP way, prefer using WP functionality over userland/PHP native Type: Enhancement
Milestone

Comments

@Ipstenu
Copy link
Contributor

Ipstenu commented Jun 20, 2019

Is your feature request related to a problem?

The sniffer for PrefixAllGlobals does not check for two letter prefixes. This is a problem as there are roughly 80,000 (yes thousand) plugins, and a large number

Describe the solution you'd like

Prefixes should be checked for length. They should be at least 3 characters.

INVALID: function mp_save_post()

VALID: function myplugin_save_post()

Additional context (optional)

This should be recommended by default

@mikelking
Copy link

I appreciate that you included examples of valid vs invalid. Curious how would this check be affected by the NAMESPACE attribute?

If one were to use;

NAMESPACE myplugin

function save_post() { ... }

@GaryJones
Copy link
Member

In this case, that save_post() function in your example is not in the global namespace (it's in the myplugin namespace), so the sniff wouldn't check it for the presence of a prefix anyway.

NielsdeBlaauw added a commit to NielsdeBlaauw/WordPress-Coding-Standards that referenced this issue Jun 20, 2019
NielsdeBlaauw added a commit to NielsdeBlaauw/WordPress-Coding-Standards that referenced this issue Jun 20, 2019
@mikelking
Copy link

@GaryJones

That is what I thought. Thanks for the clarification.

@jrfnl jrfnl added Component: Extra Focus: WP interoperability Doing things the WP way, prefer using WP functionality over userland/PHP native Type: Enhancement labels Jul 1, 2019
@jrfnl jrfnl added this to the 2.x Next milestone Jul 1, 2019
NielsdeBlaauw added a commit to NielsdeBlaauw/WordPress-Coding-Standards that referenced this issue Jul 3, 2019
NielsdeBlaauw added a commit to NielsdeBlaauw/WordPress-Coding-Standards that referenced this issue Jul 16, 2019
jrfnl added a commit that referenced this issue Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Extra Focus: WP interoperability Doing things the WP way, prefer using WP functionality over userland/PHP native Type: Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants