Add example for fixing a single sniff

Author: afilinaCreated Oct 1, 2020Updated Mar 5, 2026
LabelsType: documentation

I have no idea how to submit changes to the wiki. Here's a patch file:

patch
From 63025d83c7964f2020a26ee806235c69871f66c5 Mon Sep 17 00:00:00 2001
From: Anna Filina <[email protected]>
Date: Thu, 1 Oct 2020 09:42:10 -0400
Subject: [PATCH] Add example for fixing a single sniff

---
 Fixing-Errors-Automatically.md | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/Fixing-Errors-Automatically.md b/Fixing-Errors-Automatically.md
index e816c68..c2f1c02 100644
--- a/Fixing-Errors-Automatically.md
+++ b/Fixing-Errors-Automatically.md
@@ -135,4 +135,31 @@ Sometimes the file may need to be processed multiple times in order to fix all t
     E: [Line 3] Expected 1 space after "="; 0 found (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
     Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff (line 259) replaced token 4 (T_EQUAL) "=" => "=·"
     * fixed 1 violations, starting loop 3 *
-    *** END FILE FIXING ***
\ No newline at end of file
+    *** END FILE FIXING ***
+
+## Fixing a Specific Sniff
+
+First, find the correct name of the sniff(s) in the selected standard:
+
+    $ phpcs -e --standard=PHPCompatibility
+
+    The PHPCompatibility standard contains 117 sniffs
+
+    PHPCompatibility (117 sniffs)
+    -----------------------------
+      PHPCompatibility.Classes.ForbiddenAbstractPrivateMethods
+      PHPCompatibility.Classes.NewAnonymousClasses
+      ...
+
+Specify both the standard and the sniff:
+
+    $ phpcbf --standard=PHPCompatibility --sniffs=PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess
+
+    PHPCBF RESULT SUMMARY
+    ---------------------------------------------
+    FILE                         FIXED  REMAINING
+    ---------------------------------------------
+    /path/to/code/myfile.php     2      0
+    ---------------------------------------------
+    A TOTAL OF 2 ERRORS WERE FIXED IN 1 FILE
+    ---------------------------------------------
-- 
2.15.1

Source: squizlabs/PHP_CodeSniffer