Repository: WordPress/WordPress-Coding-Standards (php)

Issue:
Add antispambot to list of functions that don't need escaping
The function `antispambot` takes an email address, and obfuscates it by encoding it using HTML entities. [Documentation](https://codex.wordpress.org/Function_Reference/antispambot)

For example, this code:

```php
echo antispambot( 'john.doe@mysite.com' );
```

This will output the email like this in the HTML:

```
&#106;&#111;h&#110;&#46;&#100;&#111;&#101;&#64;mysit&#101;.&#99;&#111;&#109;
```

PHPCS complains about that code, saying it should require escaping, when it doesn't.

Pull request description:
Sniff::$formattingFunctions: add `antispambot()` to the list
Fixes #1246

Includes unit tests.

Patch:
diff --git a/WordPress/Sniff.php b/WordPress/Sniff.php
index 276c7456..58ebd3c7 100644
--- a/WordPress/Sniff.php
+++ b/WordPress/Sniff.php
@@ -358,14 +358,15 @@ abstract class Sniff implements PHPCS_Sniff {
 	 * @var array
 	 */
 	protected $formattingFunctions = array(
-		'array_fill' => true,
-		'ent2ncr'    => true,
-		'implode'    => true,
-		'join'       => true,
-		'nl2br'      => true,
-		'sprintf'    => true,
-		'vsprintf'   => true,
-		'wp_sprintf' => true,
+		'antispambot' => true,
+		'array_fill'  => true,
+		'ent2ncr'     => true,
+		'implode'     => true,
+		'join'        => true,
+		'nl2br'       => true,
+		'sprintf'     => true,
+		'vsprintf'    => true,
+		'wp_sprintf'  => true,
 	);
 
 	/**


Test patch:
diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.inc b/WordPress/Tests/Security/EscapeOutputUnitTest.inc
index e5a34228..9698ce56 100644
--- a/WordPress/Tests/Security/EscapeOutputUnitTest.inc
+++ b/WordPress/Tests/Security/EscapeOutputUnitTest.inc
@@ -300,3 +300,8 @@ trigger_error(); // Ignore.
 _deprecated_file(); // Ignore.
 
 \_deprecated_file( \basename( __FILE__ ), '1.3.0' ); // Ok.
+
+// Issue #1246.
+echo antispambot( 'john.doe@mysite.com' ); // OK.
+echo antispambot( esc_html( $email ) ); // OK.
+echo antispambot( $email ); // Bad.
diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.php b/WordPress/Tests/Security/EscapeOutputUnitTest.php
index 5ae98881..571cd24b 100644
--- a/WordPress/Tests/Security/EscapeOutputUnitTest.php
+++ b/WordPress/Tests/Security/EscapeOutputUnitTest.php
@@ -89,6 +89,7 @@ class EscapeOutputUnitTest extends AbstractSniffUnitTest {
 			289 => 1,
 			294 => 1,
 			297 => 1,
+			307 => 1,
 		);
 	}