github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

manuelpichler / phpmd

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 17
    • 3
  • Source
  • Commits
  • Network (3)
  • Downloads (3)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Switch Branches (12)
    • git-0.2.x
    • master ✓
    • naming-rules
    • noelg-master
    • noelg-parser-experimental
    • noelg-rules-experimental
    • remote-svn-trunk
    • ticket12-weighted-method-count-rule
    • ticket17-exit-code-for-violations
    • ticket28-joey
    • ticket28-joey-mapi-static-variables-marked-as-unused
    • ticket28-static-variables-marked-as-unused
  • Switch Tags (3)
    • 0.2.6
    • 0.2.5
    • 0.2.3
  • Branch List
Sending Request…
Click here to lend your support to: phpmd and make a donation at www.pledgie.com !

PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend. — Read more

  Cancel

http://phpmd.org

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

# URL to continuous integration server changed to cruise.phpmd.org 
manuelpichler (author)
Tue Jul 06 13:27:21 -0700 2010
commit  8571936bef9ff5225245
tree    22be485a9a745bc82dbe
parent  dea1add2cda003de06f8
phpmd /
name age
history
message
file .gitignore Sun Jul 04 10:22:59 -0700 2010 # Do not add auto created files to repository. ... [manuelpichler]
file CHANGELOG Sun Jul 04 02:22:46 -0700 2010 # Package manifest and CHANGELOG adjusted. git... [manuelpichler]
file LICENSE Tue Jan 05 13:10:55 -0800 2010 Merge branch '0.2.n' git-svn-id: svn://xplib.d... [manuelpichler]
file README.rst Sat May 01 05:18:36 -0700 2010 # README file added. git-svn-id: svn://xplib.d... [manuelpichler]
file build.properties Sun Jul 04 05:34:39 -0700 2010 # Additional targets added that check the integ... [manuelpichler]
file build.xml Tue Jul 06 13:07:18 -0700 2010 # Import required properties. [manuelpichler]
directory conf/ Sun Jul 04 05:34:35 -0700 2010 # Missing exit() expression added to bootstrap ... [manuelpichler]
file config.properties.template Sun Jul 04 10:22:58 -0700 2010 # Continuous integration configuration added. ... [manuelpichler]
file config.xml Tue Jul 06 13:27:21 -0700 2010 # URL to continuous integration server changed ... [manuelpichler]
file package.xml Sun Jul 04 02:22:46 -0700 2010 # Package manifest and CHANGELOG adjusted. git... [manuelpichler]
file phpmd.bat Tue Jan 05 12:37:48 -0800 2010 # Author e-mail and project url changed. git-s... [manuelpichler]
file phpmd.php Wed Mar 03 22:08:59 -0800 2010 # New rule that checks the length of several va... [manuelpichler]
directory rulesets/ Sun Jun 06 13:02:49 -0700 2010 - Implemented #24: Implement Depth Of Inheritan... [manuelpichler]
file setup.sh Sun Jul 04 10:23:00 -0700 2010 # Missing fetch command added. git-svn-id: svn... [manuelpichler]
directory source/ Sun Jun 06 13:02:49 -0700 2010 - Implemented #24: Implement Depth Of Inheritan... [manuelpichler]
directory test/ Sun Jun 06 13:02:51 -0700 2010 # Missing @covers annotation for parent class a... [manuelpichler]
README.rst

Command line usage

Type phpmd [filename|directory] [report format] [ruleset file], i.e:

mapi@arwen ~ $ phpmd PHP/Depend/DbusUI/ xml rulesets/codesize.xml
<?xml version="1.0" encoding="UTF-8" ?>
<pmd version="0.0.1" timestamp="2009-12-19T22:17:18+01:00">
  <file name="/projects/pdepend/PHP/Depend/DbusUI/ResultPrinter.php">
    <violation beginline="67"
               endline="224"
               rule="TooManyMethods"
               ruleset="Code Size Rules"
               package="PHP_Depend\DbusUI"
               class="PHP_Depend_DbusUI_ResultPrinter"
               priority="3">
      This class has too many methods, consider refactoring it.
    </violation>
  </file>
</pmd>

You can pass a file name or a directory name containing PHP source code to PHPMD.

The PHPMD PEAR or Phar distribution includes the rule set files inside its archive, even if the "rulesets/codesize.xml" parameter above looks like a filesystem reference.

Command line options

  • Notice that the default output is in XML, so you can redirect it to a file and XSLT it or whatever

  • You can also use shortened names to refer to the built-in rule sets, like this:

    phpmd PHP/Depend/DbusUI/ xml codesize
    
  • The command line interface also accepts the following optional arguments:

    • --minimumpriority - The rule priority threshold; rules with lower priority than they will not be used.
    • --reportfile - Sends the report output to the specified file, instead of the default output target STDOUT.
    • --extensions - Comma separated string of valid PHP source file extensions.
    • --ignore - Comma separated string of files or directories that will be ignored during the parsing process.

Using multiple rule sets

PHPMD uses so called rule sets that configure/define a set of rules which will be applied against the source under test. The default distribution of PHPMD is already shipped with a few default sets, that can be used out-of-box. You can call PHPMD's cli tool with a set's name to apply this configuration:

~ $ phpmd /path/to/source text codesize

But what if you would like to apply more than one rule set against your source? You can also pass a list of rule set names, separated by comma to PHPMD's cli tool:

~ $ phpmd /path/to/source text codesize,unusedcode,naming

You can also mix custom rule set files with build-in rule sets:

~ $ phpmd /path/to/source text codesize,/my/rules.xml

That's it. With this behavior you can specify you own combination of rule sets that will check the source code.

Exit codes

PHPMD's command line tool currently defines three different exit codes.

  • 0, This exit code indicates that everything worked as expected. This means there was no error/exception and PHPMD hasn't detected any rule violation in the code under test.
  • 1, This exit code indicates that an error/exception occured which has interrupted PHPMD during execution.
  • 2, This exit code means that PHPMD has processed the code under test without the occurence of an error/exception, but it has detected rule violations in the analyzed source code.

Renderers

At the moment PHPMD comes with the following three renderers:

  • xml, which formats the report as XML.
  • text, simple textual format.
  • html, single HTML file with possible problems.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server
  • English
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Српски
  • Svenska
  • 中文