phpcs(1)
πΈ phpcs β PHP code sniffer CLI tool πΈ
okay bestie, pull up a chair, because this is the manual page for phpcs, aka the PHP_CodeSniffer command line tool. yes the manual calls itself "General Commands Manual" up top, we're just not doing that energy here. let's go π
β¨ SYNOPSIS β¨
phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors]
[--cache=cacheFile] [--no-cache] [--tab-width=tabWidth]
[--report=report] [--report-file=reportFile]
[--report-report=reportFile] [--report-width=reportWidth]
[--basepath=basepath] [--bootstrap=bootstrap] [--severity=severity]
[--error-severity=severity] [--warning-severity=severity] [--runtime-set
key value] [--config-set key value] [--config-delete key]
[--config-show] [--standard=standard] [--sniffs=sniffs]
[--exclude=sniffs] [--encoding=encoding] [--parallel=processes]
[--generator=generator] [--extensions=extensions [--ignore=patterns]
[--ignore-annotations] [--stdin-path=stdinPath] [--file-list=fileList]
[--filter=filter] file ...
π DESCRIPTION π
phpcs (or PHP_CodeSniffer) is a PHP5 script that tokenises PHP, JavaScript and CSS files so it can sniff out violations of a coding standard you picked. it's literally an essential dev tool β it keeps your code clean and consistent, no cap. it can also help prevent some common semantic errors that developers make. we love a tool that has your back π«Ά
π PARAMETERS π
these are the lil placeholders that go in all those = slots. here's the whole list, every single one:
cacheFileβ use a specific file for caching (by default it just uses a temporary file, very low maintenance of it)basepathβ a path to strip from the front of file paths inside reportsbootstrapβ a comma separated list of files to run before processing startsencodingβ the encoding of the files being checked (default isiso-8859-1)extensionsβ a comma separated list of file extensions to check. you can specify the type of the file usingext/type, e.g.,module/php,es/jsfileβ one or more files and/or directories to checkfileListβ a file containing a list of files and/or directories to check (one per line, bestie, ONE per line)filterβ use either the"gitmodified"or"gitstaged"filter, or specify the path to a custom filter classgeneratorβ use either the"HTML","Markdown"or"Text"generator (this forces documentation generation instead of checking, heads up)patternsβ a comma separated list of patterns to ignore files and directoriesprocessesβ how many files should be checked simultaneously (default is1)reportβ print either thefull,xml,checkstyle,csv,json,junit,emacs,source,summary,diff,svnblame,gitblame,hgblame, ornotifysendreport, or specify the path to a custom report class (thefullreport is printed by default)reportFileβ write the report to the specified file pathreportWidthβ how many columns wide screen reports should be printed, or set to"auto"to use current screen width, where supportedseverityβ the minimum severity required to display an error or warningsniffsβ a comma separated list of sniff codes to include or exclude during checking (all sniffs must be part of the specified standard, okurrr)standardβ the name or path of the coding standard to usestdinPathβ if processing STDIN, the file path that STDIN will be processed astabWidthβ the number of spaces each tab represents
π OPTION π
the actual flags, in the exact order the page gives them. buckle up, it's a long list and we're not skipping a single one:
-nβ do not print warnings (shortcut for--warning-severity=0)-wβ print both warnings and errors (this is the default)-lβ local directory only, no recursion-sβ show sniff codes in all reports-aβ run interactively-eβ explain a standard by showing the sniffs it includes-pβ show progress of the run-qβ quiet mode; disables progress and verbose output-nβ stop error messages from being recorded (saves a lot of memory, but stops many reports from being used)
ok so real talk: yes, -n shows up twice in this list with two completely different jobs. that's exactly what the page says, we're just reporting the news. lowkey iconic, highkey confusing π«
-vβ print processed files-vvβ print ruleset and token output-vvvβ print sniff processing information-iβ show a list of installed coding standards-dβ set the key php.ini value to value or true if value is omitted--helpβ print the help message--versionβ print version information--colorsβ use colors in output--no-colorsβ do not use colors in output (this is the default)--cacheβ cache results between runs--no-cacheβ do not cache results between runs (this is the default)--ignore-annotationsβ ignore allphpcs:annotations in code comments
π¦ SEE ALSO π¦
phpcbf(1)β its sibling, the fixer-upper π§
and that's the whole page, bestie!! no detail left behind, every flag accounted for, vibe check passed with flying colors π this manual page is dated 2018-02-27 and belongs to the phpcs(1) family β mwah, kiss the manual, go run a sniff on your codebase, and slay π
πβ¨
π¦ where this page comes from
- debian bookworm: php-codesniffer 3.7.1-2 Β· BSD-3-Clause
- ubuntu jammy: php-codesniffer 3.6.2-1 Β· BSD-3-Clause
- ubuntu noble: php-codesniffer 3.7.2-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms