• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / phpcs display sniff name

phpcs display sniff name

Last updated on October 20, 2022 by Sal Ferrarello

By default phpcs does NOT display the relevant name of the sniff when a sniff fails.

By adding the -s argument, the sniff names will be displayed. See the following from phpcs --help.

-s    Show sniff codes in all reports

You can add this to your PHP CodeSniffer XML Ruleset with the following:

<!-- Append arg -s to phpcs to display the name of failed sniffs -->
<arg value="s"/>

Editor Specific Configurations

VS Code

In Visual Studio Code using the PHPCS extensions, this can be configured with the phpcs.showSources configuration option.

Or if you are using PHP Sniffer & Beautifier, this can be configured with the phpsab.snifferShowSources configuration option.

Vim with ALE Plugin

In Vim (or Neovim) using the ALE Plugin the sniff name is displayed by default. However, sometimes longer sniffs get truncated. In this case, you can run the command

:messages

which will display a list of messages that have been displayed (including the full version of the sniff name).

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Programming, Solution Tagged With: PHP, PHPCS

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in