PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.




PHP Versions

Supported Languages


Official Documentation

YAML Configuration


  • input:

    Patterns to include in reports.

    Note: The input patterns are not applied when running PHPMD since PHPMD considers dependency between files and filtering the input files affects how PHPMD detects issues. Therefore, the files excluded by the patterns are always processed and you may even see logs related to the excluded files in the job console. However, Inspecode eventually ignores any issues detected on the excluded files when generating job reports.

    If you need to let PHPMD ignore particular files, consider specifying --exclude under options: instead.

  • ignore:

    Patterns to exclude from reports.

    Note: Just like input:, the ignore patterns are not applied when running PHPMD.

  • auto-fix:


  • config-file:

    A ruleset filename or a comma-separated string of ruleset filenames.

    If omitted, cleancode,codesize,controversial,design,naming,unusedcode will be used by default.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.25 CPU with 960 MiB RAM.

      Inspecode automatically specifies -d memory_limit=<limit> to PHP in order to configure the maximum amount of memory that PHPMD is allowed to allocate according to this value. Inspecode reserves 240 MiB RAM for system, and makes the rest of RAM available to PHPMD for memory allocation. For example, -d memory_limit=720M is specified by default (for 0.25 CPU), -d memory_limit=5520M is specified for 1.5 CPU.

  • options:

    Below is the list of options that are supported:

    --minimumpriority: rule priority threshold; rules with lower priority than this will not be used
    --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
    --strict: also report those nodes with a @SuppressWarnings annotation
  • thresholds:

    • num-issues:

      In addition to general severity levels, the following tool specific severity levels can be specified:

      • Change absolutely required (equivalent to general severity level critical)
      • Change highly recommended (equivalent to general severity level error)
      • Change recommended (equivalent to general severity level warning)
      • Change optional, Change highly optional (equivalent to general severity level info)
  • incremental:


    Note: The incremental analysis cannot be supported for PHPMD. This is because PHPMD analyzes source code with considering dependency between files and the results on unchanged files can be affected by changed files.

  • experimental:

    No tool specific experimental options are available.

YAML Examples

  • With default options:

        phpmd: default
  • With custom machine:

            cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
  • With custom options:

            --suffixes: php,phtml
  • With a configuration (ruleset) file:

          config-file: ./my-ruleset.xml

Configuration File Detection

If no configuration (ruleset) files are specified via config-file field, Inspecode walks the file tree in lexical order in your repository to find configuration files matching the following patterns and specifies the files placed in the same directory as the first found one to PHPMD automatically.

  • phpmd.xml
  • cleancode.xml
  • codesize.xml
  • controversial.xml
  • design.xml
  • naming.xml
  • unusedcode.xml
  • *ruleset*.xml
  • rulesets/*.xml

Note: Inspecode ignores specific configuration files while searching. See Configuration > Tool Configuration > Field: config-file for detail.

If the configuration file detected by Inspecode is not the one you want to use or you do not want to use any configuration files, you can disable Inspecode from detecting configuration files by explicitly setting an empty string to config-file field like below:

      config-file: ""

results matching ""

    No results matching ""