phpcs(1)

πŸ“¦ version 3.7.2, in debian bookworm, ubuntu jammy, ubuntu noble

🌸 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 reports
  • bootstrap β€” a comma separated list of files to run before processing starts
  • encoding β€” the encoding of the files being checked (default is iso-8859-1)
  • extensions β€” a comma separated list of file extensions to check. you can specify the type of the file using ext/type, e.g., module/php,es/js
  • file β€” one or more files and/or directories to check
  • fileList β€” 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 class
  • generator β€” 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 directories
  • processes β€” how many files should be checked simultaneously (default is 1)
  • report β€” print either the full, xml, checkstyle, csv, json, junit, emacs, source, summary, diff, svnblame, gitblame, hgblame, or notifysend report, or specify the path to a custom report class (the full report is printed by default)
  • reportFile β€” write the report to the specified file path
  • reportWidth β€” how many columns wide screen reports should be printed, or set to "auto" to use current screen width, where supported
  • severity β€” the minimum severity required to display an error or warning
  • sniffs β€” 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 use
  • stdinPath β€” if processing STDIN, the file path that STDIN will be processed as
  • tabWidth β€” 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 all phpcs: 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