PHPMD(1)

πŸ“¦
version 2.15.0 Β· 3 versions
, in ubuntu noble

πŸ’– PHPMD πŸ’–

okay bestie, welcome to the PHPMD manual page β€” it's the command line interface for PHPMD, and yes we are gonna get through the whole thing together, no skimming, no skipping. grab a boba, we're doing this. πŸ§‹βœ¨


🌸 NAME 🌸

PHPMD β€” it's literally the PHPMD command line interface, that's the whole vibe πŸ’…


✨ DESCRIPTION ✨

so. here's the tea. πŸ«– you have three mandatory arguments and you cannot skip a single one of them, they're the main characters:

  1. a php source code filename or directory. and she's flexible!! it can be a comma-separated string, a glob pattern, or literally just - to scan stdin πŸ‘‘
  2. a report format
  3. a ruleset filename, or a comma-separated string of ruleset filenames

put together it looks like this, iconic behavior:

phpmd /path/to/source format ruleset

πŸŽ€ the formats you can pick from

ansi, baseline, checkstyle, github, gitlab, html, json, sarif, text, xml

πŸ¦‹ the rulesets you can pick from

cleancode, codesize, controversial, design, naming, unusedcode


πŸ’… OPTIONS πŸ’…

these are the optional arguments, and the thing about them is they go after the mandatory ones. mandatory first, optional after, that's the order, periodt.

  • --verbose, -v, -vv, -vvv β€” show debug information. the more v's, the more you're gonna see, iykyk πŸ”
  • --minimum-priority β€” rule priority threshold; any rules with a lower priority than this will not be used
  • --report-file β€” send report output to a file; default is STDOUT
  • --error-file β€” send errors (other than reported violations) output to a file; default is STDERR
  • --suffixes β€” comma-separated string of valid source code filename extensions, e.g. php,phtml
  • --exclude β€” comma-separated string of patterns that are used to ignore directories. use asterisks to exclude by pattern. for example *src/foo/*.php or *src/foo/*
  • --strict β€” also report those nodes with a @SuppressWarnings annotation. no hiding bestie πŸ™ˆ
  • --ignore-errors-on-exit β€” will exit with a zero code, even on error
  • --ignore-violations-on-exit β€” will exit with a zero code, even if any violations are found
  • --cache β€” will enable the result cache
  • --cache-file β€” instead of the default .phpmd.result-cache.php it will use this file as the result cache file path
  • --cache-strategy β€” sets the caching strategy to determine if a file is still fresh. either content to base it on the file contents, or timestamp to base it on the file modified timestamp
  • --generate-baseline β€” will generate a phpmd.baseline.xml next to the first ruleset file location
  • --update-baseline β€” will remove any non-existing violations from the phpmd.baseline.xml
  • --baseline-file β€” a custom location of the baseline file
  • --color β€” enable color in output 🌈 (yes it's giving aesthetic, we love that for us)
  • --extra-line-in-excerpt β€” specify how many extra lines are added to a code snippet in html format
  • -- β€” explicit argument separator: anything after -- will be read as an argument even if it starts with - or matches the name of an option. it's the "no seriously, this one's a value not a flag" escape hatch πŸ”₯
real talk though: that last one? chef's kiss. anything after -- gets treated as a plain argument, even if it starts with - or even if it's literally spelled like one of the options above. so if your filename is out here looking like a flag, this is how you tell phpmd to chill and just read it as-is. πŸ’€

that's the whole page bestie, you ate that πŸ“

this page was brought to you by PHPMD 2.15.0, dated December 2023 β€” mwah, love u, go lint something πŸ’œπŸŽ€βœ¨

πŸ“¦ where this page comes from