Skip to content

Commit 4d0160f

Browse files
NamingConventions/PrefixAllGlobals: update min prefix length from 3 to 4 chars (#2479)
1 parent 0f2fadb commit 4d0160f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

WordPress/Docs/NamingConventions/PrefixAllGlobalsStandard.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function <em>wp_save_post()</em> {}
101101
</code_comparison>
102102
<standard>
103103
<![CDATA[
104-
Prefixes must have a minimum length of three character to be considered valid, as many plugins and themes share the same initials.
104+
Prefixes must have a minimum length of four character to be considered valid, as many plugins and themes share the same initials.
105105
]]>
106106
</standard>
107107
<code_comparison>

WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ final class PrefixAllGlobalsSniff extends AbstractFunctionParameterSniff {
5959
* Minimal number of characters the prefix needs in order to be valid.
6060
*
6161
* @since 2.2.0
62+
* @since 3.2.0 The minimum number of characters was raised from 3 to 4.
6263
*
6364
* @link https://github.com/WordPress/WordPress-Coding-Standards/issues/1733 Issue 1733.
65+
* @link https://github.com/WordPress/WordPress-Coding-Standards/issues/2467 Issue 2467.
6466
*
6567
* @var int
6668
*/
67-
const MIN_PREFIX_LENGTH = 3;
69+
const MIN_PREFIX_LENGTH = 4;
6870

6971
/**
7072
* Target prefixes.

WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.1.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] wp
77
function wp_do_something() {}
88

9-
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] ^%&
10-
function ^%&_do_something() {}
9+
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] ^%&%
10+
function ^%&%_do_something() {}
1111

1212
// Now let's set the real prefixes we want to test for.
1313
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] acronym,tgmpa
@@ -511,13 +511,13 @@ function aa_do_something(){}
511511

512512
// The following line mimics an empty prefix value.
513513
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] ,
514-
function aaa_do_something(){}
514+
function aaaa_do_something(){}
515515

516516
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] 😊
517517
function 😊_do_something(){}
518518

519-
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] 😊😊
520-
function 😊😊_do_something(){}
519+
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] 😊😊😊
520+
function 😊😊😊_do_something(){}
521521

522522
// Reset to the standard test prefixes.
523523
// phpcs:set WordPress.NamingConventions.PrefixAllGlobals prefixes[] acronym,tgmpa

0 commit comments

Comments
 (0)