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.

Overview

PHPMD

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.

https://phpmd.org

Latest Stable Version License Travis Build Status AppVeyor Build Status Scrutinizer Build Status Scrutinizer Code Quality Chat with us on Gitter Monthly downloads Total downloads

Installation

See https://phpmd.org/download/index.html

Command line usage

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

mapi@arwen ~ $ phpmd php/PDepend/DbusUI/ xml rulesets.xml

While the rulesets.xml ruleset file could look like this:

<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
         xmlns="http://pmd.sf.net/ruleset/1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
                       http://pmd.sf.net/ruleset_xml_schema.xsd"
         xsi:noNamespaceSchemaLocation="
                       http://pmd.sf.net/ruleset_xml_schema.xsd">
  <description>
    My custom rule set that checks my code...
  </description>

  <rule ref="rulesets/codesize.xml" />
  <rule ref="rulesets/cleancode.xml" />
  <rule ref="rulesets/controversial.xml" />
  <rule ref="rulesets/design.xml" />
  <rule ref="rulesets/naming.xml" />
  <rule ref="rulesets/unusedcode.xml" />
</ruleset>

The xml report would like like this:

<?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="81"
               endline="81"
               rule="UnusedFormalParameter"
               ruleset="Unused Code Rules"
               externalInfoUrl="https://phpmd.org/rules/unusedcode.html#unusedformalparameter"
               priority="3">
      Avoid unused parameters such as '$builder'.
    </violation>
  </file>
</pmd>

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

The PHPMD 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.
    • --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.
    • --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.
    • --generate-baseline - will generate a phpmd.baseline.xml for existing violations next to the ruleset definition file.
    • --update-baseline - will remove all violations from an existing phpmd.baseline.xml that no longer exist. New violations will _not_ be added.
    • --baseline-file - the filepath to a custom baseline xml file. The filepath of all baselined files must be relative to this file location.

    An example command line:

    phpmd PHP/Depend/DbusUI xml codesize --reportfile phpmd.xml --suffixes php,phtml
    

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.

Using multiple source files and folders

PHPMD also allowes you to specify multiple source directories in case you want to create one output for certain parts of your code

~ $ phpmd /path/to/code,index.php,/another/place/with/code text codesize

Exit codes

PHPMD's command line tool currently defines four 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 exception occurred which has interrupted PHPMD during execution.
  • 2, This exit code means that PHPMD has processed the code under test without the occurrence of an error/exception, but it has detected rule violations in the analyzed source code. You can also prevent this behaviour with the --ignore-violations-on-exit flag, which will result to a 0 even if any violations are found.
  • 3, This exit code means that one or multiple files under test could not
    be processed because of an error. There may also be violations in other files that could be processed correctly.

Renderers

At the moment PHPMD comes with the following renderers:

  • xml, which formats the report as XML.
  • text, simple textual format.
  • html, single HTML file with possible problems.
  • json, formats JSON report.
  • ansi, a command line friendly format.
  • github, a format that GitHub Actions understands.

Baseline

For existing projects a violation baseline can be generated. All violations in this baseline will be ignored in further inspections.

The recommended approach would be a phpmd.xml in the root of the project. To generate the phpmd.baseline.xml next to it:

~ $ phpmd /path/to/source text phpmd.xml --generate-baseline

To specify a custom baseline filepath for export:

~ $ phpmd /path/to/source text phpmd.xml --generate-baseline --baseline-file /path/to/source/phpmd.baseline.xml

By default PHPMD will look next to phpmd.xml for phpmd.baseline.xml. To overwrite this behaviour:

~ $ phpmd /path/to/source text phpmd.xml --baseline-file /path/to/source/phpmd.baseline.xml

To clean up an existing baseline file and only remove no longer existing violations:

~ $ phpmd /path/to/source text phpmd.xml --update-baseline

PHPMD for enterprise

Available as part of the Tidelift Subscription.

The maintainers of PHPMD and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Comments
  • .pdepend folder grew to 45 GB

    .pdepend folder grew to 45 GB

    I posted the problem first in the PHPStorm tracker: http://youtrack.jetbrains.com/issue/WI-18654

    I use PHPStorm as IDE which provides an interface to PMD.

    Windows x64, php installed as standalone with all pear/pecl packages configured correctly as far as I can tell. PMD runs fine and also runs fine in PHPStorm. It just seems that it never cleans up after itself.

    I was told to report this here as the PHPStorm devs won't fix it.

    PDepend Cache 
    opened by normadize 28
  • Cannot create new nodes, when internal state is frozen.

    Cannot create new nodes, when internal state is frozen.

    This is a bit tricky issue.

    For start I know that this error is actually triggered by pdepend/pdepend package yet it happens when I'm using PHPMD so I decided to post this issue here.

    I'm trying to run PHPMD on my PHP7 project. In most cases it fails with message:

    Cannot create new nodes, when internal state is frozen.
    

    I've tried to run PHPMD for some directories located inside my src dir and it worked. Yet again, when I tried to put them together separated by comma the fail message returned.

    I'm not sure what's causing this problem. At first I've thought it's a problem of code written in PHP7 yet it seems to be unrelated (for single directories PHPMD works).

    I'm using PHPMD in 2.3.2 version. Tried to run binary in PHP 5.6.15, and 7.0RC7

    Bug 
    opened by radmen 22
  • Clarify ElseExpression rule

    Clarify ElseExpression rule

    From the docs: "An if expression with an else branch is never necessary". It then goes on: "You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements."

    I don't understand the reasoning. Why is an early return (or, I assume, continue) statement intrinsically simpler to read? Why should we avoid else statements simply because they are never necessary? (The if statement, I might add, is never necessary either!)

    These factors are unchanged:

    • There is still an if.
    • The "else" condition is still evaluated in exactly the same cases, only now by "falling through" instead of branching to the else block. The rationale that the exact condition for evaluating the else code is not clear, persists.

    New issues are introduced:

    • When using early returns, postprocessing code that has to be run in both branches has to be duplicated, introducing the potential for later divergence.
    • When using early returns, the "else" code is "promoted" to a shallower indentation level, suggesting to the casual reader that it is the default case, even if the cases may be 50/50.
    • When moving the if/else into a separate method, that method then needs to use early returns as well, because it can't use else either. Does it make the code more readable to have that method simply for this single purpose?
    • A ternary operator is often harder to read. The only advantage I see there is that it only allows expressions instead of statements.

    I have had a spirited discussion with my coworkers, but fail to be convinced so far that this rule achieves its objectives. I understand that else statements often appear in bad code, but I see them as a symptom rather than a cause. I feel that encouraging less experienced developers to use early returns and ternary operators may cause them to write worse code, not better.

    I have found only a few critiques of the else statement on Google, and all of them focus on bad uses of else, not on the use of else per se.

    My suggestion is to either:

    • Clarify some of these concerns in the docs, and improve the suggestions.
    • Put this rule in the "controversial" set.

    I haven't made my own version of the docs text yet, because first I would like to have a clear understanding of the reasoning behind the rule and make sure there is nothing I miss.

    Enhancement Documentation 
    opened by sbesselsen 22
  • Avoid unused parameters on PHP 8: Constructor property

    Avoid unused parameters on PHP 8: Constructor property

    • PHPMD version: 2.10.0
    • PHP Version: 8.0.3
    • Installation type: composer
    • Operating System / Distribution & Version: Ubuntu 20.04

    Current Behavior

    Getting "Avoid unused parameters such as '$createNewUser'" violation when declaring parameters in the constructor in php8.

    Expected Behavior

    No violation, as php8 introduces the possibility of declaring class prorieties in the constructor, like so: https://stitcher.io/blog/constructor-promotion-in-php-8

    Steps To Reproduce:

    • install the latest phpmd
    • declare class proprieties in the constructor, for example:
     public function __construct(
            private CreateNewUser $createNewUser,
            private PasswordGenerator $passwordGenerator
        ) {
        }
    
    • run vendor/bin/phpmd . xml phpmd.xml --reportfile ./test-results/php-mess-detector.xml
    • see violations in the xml output file: Avoid unused parameters such as '$createNewUser'. Avoid unused parameters such as '$passwordGenerator'.

    Checks before submitting

    • [*] Be sure that there isn't already an issue about this. See: Issues list
    • [*] Be sure that there isn't already a pull request about this. See: Pull requests
    • [*] I have added every step to reproduce the bug.
    • [*] If possible I added relevant code examples.
    • [*] This issue is about 1 bug and nothing more.
    • [*] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
    Bug php8.0 php8.x Good first issue 
    opened by andrei-aceweb 21
  • Replaced HTML renderer with new

    Replaced HTML renderer with new "pretty HTML" renderer

    I got tired of the default styling of the HTML renderer, so I took some time to create something new and prettier. I think it looks fine, so I decided to share it back to the project as an additional renderer. :)

    Sample

    image

    Old sample: https://user-images.githubusercontent.com/6860713/31499693-cd15ac5e-af65-11e7-811b-f157c47985ec.png

    This PR contains a new renderer, selectable as pretty-html parameter in addition to existing html, xml, text output formats.

    Usage is thus something like this:

    ./vendor/phpmd/phpmd/src/bin/phpmd /home/user/php-code-directory pretty-html codesize,cleancode --reportfile pretty-report.html
    

    I don't know if I edited the licencing texts correctly, but that can be obviously fixed.

    Feature Output 
    opened by smuuf 21
  • PHPMD complaining about UnusedFormalParameters when overriding method from base class.

    PHPMD complaining about UnusedFormalParameters when overriding method from base class.

    Following issue #50, I also have a warning about UnusedFormalParameters which I think should no be happening.

    I created classes extending the base Symfony 2.0 Command class which includes an execute method :

    class Command
    {
        [...]
        protected function execute(InputInterface $input, OutputInterface $output)
        {
            throw new \LogicException('You must override the execute() method in the concrete command class.');
        }
        [...]
    }
    

    My own classes are as follow :

    class BaseCommand extends Command
    {
        [...]
    }
    
    class ConfigCommand extends BaseCommand
    {
        protected function configure()
        {
            [...]
        }
    
        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $this->loadContext();
            $output->writeln('<info>Current configuration is:</info>');
            $output->writeln(Yaml::dump(Context::getInstance()->getParam('config')));
        }
    }
    

    PHPMD is complaining about the $input parameter that is not used on the ConfigCommand, but there is nothing I can do about it since I really don't need it and I also cannot obviously call the parent method or redefine it since it is part of the Symfony2 framework.

    Thanks for your great tool !

    Enhancement 
    opened by krtek4 20
  • Phar throwing errors in PHP 8.0.

    Phar throwing errors in PHP 8.0.

    • PHPMD version: 2.10.0
    • PHP Version: 8.0.3
    • Installation type: phar
    • Operating System / Distribution & Version: macOS

    Current Behavior

    I'm seeing multiple errors during a single lint execution.

    ./Bin/phpmd Test.php json cleancode,codesize,controversial,design,naming,unusedcode 
    PHP Deprecated:  Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/config/Util/XmlUtils.php on line 54
    
    Deprecated: Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/config/Util/XmlUtils.php on line 54
    PHP Deprecated:  Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/config/Util/XmlUtils.php on line 68
    
    Deprecated: Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/config/Util/XmlUtils.php on line 68
    PHP Deprecated:  Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php on line 517
    
    Deprecated: Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php on line 517
    PHP Deprecated:  Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php on line 519
    
    Deprecated: Function libxml_disable_entity_loader() is deprecated in phar:///<xxxxx>/Bin/phpmd/vendor/symfony/dependency-injection/Loader/XmlFileLoader.php on line 519
    {
        "version": "2.10.0snapshot202104261849",
        "package": "phpmd",
        "timestamp": "2021-04-27T02:27:17+00:00",
        "files": [
            {
                "file": "\/Users\/mike\/Developer\/phpmd.novaextension\/Test.php",
                "violations": [
                    {
                        "beginLine": 3,
                        "endLine": 6,
                        "package": "+global",
                        "function": null,
                        "class": "Testasfsdfsdafsdfsadfsdfsdfsdafsadfsafsdfsdfdsfdsfsdaf",
                        "method": null,
                        "description": "Avoid excessively long class names like Testasfsdfsdafsdfsadfsdfsdfsdafsadfsafsdfsdfdsfdsfsdaf. Keep class name length under 40.",
                        "rule": "LongClassName",
                        "ruleSet": "Naming Rules",
                        "externalInfoUrl": "https:\/\/phpmd.org\/rules\/naming.html#longclassname",
                        "priority": 3
                    }
                ]
            }
        ]
    }
    

    Expected Behavior

    • The errors make it difficult to parse the results programatically.
    • I would expect libxml_disable_entity_loader() not to be referenced when running in PHP 8.

    Steps To Reproduce:

    Run the above command on the following file:

    <?php
    
    class Testasfsdfsdafsdfsadfsdfsdfsdafsadfsafsdfsdfdsfdsfsdaf
    {
        //
    }
    

    Checks before submitting

    • [X] Be sure that there isn't already an issue about this. See: Issues list
    • [X] Be sure that there isn't already a pull request about this. See: Pull requests
    • [X] I have added every step to reproduce the bug.
    • [X] If possible I added relevant code examples.
    • [X] This issue is about 1 bug and nothing more.
    • [X] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
    Enhancement 
    opened by mikebronner 17
  • NPath Complexity of 315525

    NPath Complexity of 315525

    I have a command line option interface, which formats the output for display to the user when the tool is called wrong. The options could be values in a config file (XML, INI) or even the command line similar to getopts.

    The function below is being reported as a Cylomatic Complexity of 15, but a NPath Complexity over 300K.

    The code will loop through each option and depending on how it is defined (must enter, has a value, value optional, etc..) it will build the usage output. This class is used to support options from various sources, not just the command line with getopts.

    public function GetHelpOutput($Title, $Description)
    {
        $HelpOutput  = $Title . self::TAB . $Description . self::NEW_LINE;
        $HelpOutput .= 'Available Parameters:' . self::NEW_LINE;
    
        $LargestWord = 0;
        $IsOptional  = FALSE;
        $IsNeedValue = FALSE;
        foreach ($this->CommandLineOptions_ as $Key => $CommandOption)
        {
            if( ! $CommandOption->Required)
            {
                $IsOptional = TRUE;
            }
            if( $CommandOption->ValueRequired)
            {
                $IsNeedValue = TRUE;
            }
            $Size        = strlen($CommandOption->WordParameter);
            $LargestWord = ($Size > $LargestWord) ? $Size : $LargestWord;
        }
    
        $MaxBuffer = ($IsOptional ? 4 : 0) + ($IsNeedValue ? 6 : 0) + 4 + $LargestWord;
        foreach ($this->CommandLineOptions_ as $Key => $CommandOption)
        {
            $Parameter  = (strlen($CommandOption->LetterParameter) > 0) ? '-' . $CommandOption->LetterParameter : '  ';
            $Parameter .= ($IsOptional && $CommandOption->Required) ? ' ' : NULL;
            if( strlen($CommandOption->WordParameter) > 0)
            {
                $Parameter .= (substr($Parameter, 0, 1) == '-') ? ' | ' : '   ';
                $Parameter .= '--' . $CommandOption->WordParameter;
            }
    
            if( $CommandOption->ValueRequired)
            {
                $Parameter .= ' value';
            }
    
            if( ! $CommandOption->Required )
            {
                $Parameter = '[' . $Parameter . ']';
            }
    
            $HelpOutput .= str_pad($Parameter, $MaxBuffer, ' ', STR_PAD_RIGHT);
            $HelpOutput .= ' - ' . $CommandOption->Description;
            $HelpOutput .= self::NEW_LINE;
        }
        return $HelpOutput;
    }
    

    Output from PHPMD 1.5.0

    OPTIONS.class:307 The method GetHelpOutput() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. OPTIONS.class:307 The method GetHelpOutput() has a n NPath complexity of 315525. The configured NPath complexity threshold is 200.

    Bug PDepend 
    opened by Chowarmaan 17
  • 1.5.0 release contains pdepend version specification with no upper limit

    1.5.0 release contains pdepend version specification with no upper limit

    A 1.5.0 install at the moment will accept a 2.0.0 pdepend version, even though 2.x is not compatible with phpmd 1.5.x. This is due to phpmd depending on pdepend using a >= version constraint (no upper limit).

    Broken:

    $ cat composer.json
    {
        "require": {
            "phpmd/phpmd": "~1.0"
        }
    }
    
    $ vendor/bin/phpmd
    PHP Warning:  require_once(PHP/Depend/Autoload.php): failed to open stream: 
    ...etc...
    

    Works (force pdepend to a 1.x release):

    $ cat composer.json
    {
        "require": {
            "phpmd/phpmd": "~1.0",
            "pdepend/pdepend": "~1.0"
        }
    }
    
    $ vendor/bin/phpmd
    Mandatory arguments:
    ...etc...
    

    See also: https://getcomposer.org/doc/01-basic-usage.md#package-versions https://getcomposer.org/doc/01-basic-usage.md#next-significant-release-tilde-operator- https://getcomposer.org/doc/faqs/why-are-unbound-version-constraints-a-bad-idea.md

    Bug 
    opened by alcohol 16
  • Unexpected token appears in PHP 8.0

    Unexpected token appears in PHP 8.0

    • PHPMD version: 2.9.1
    • PHP Version: 8.0
    • Installation type: composer
    • Operating System / Distribution & Version: Docker Image php:8.0-fpm-alpine

    Current Behavior

    It worked fine in PHP7.4, but in PHP8.0 it shows Unexpected token: in all the .php files it inspects.

    Expected Behavior

    The process is completed normally.

    Steps To Reproduce:

    • $ phpmd . text phpmd.xml

    phpmd.xml

    <?xml version="1.0"?>
    <ruleset name="Custom_PHPMD">
        <description>Custom ruleset PHPMD</description>
        <rule ref="rulesets/codesize.xml" />
        <rule ref="rulesets/controversial.xml">
            <exclude name="CamelCasePropertyName" />
            <exclude name="CamelCaseParameterName" />
            <exclude name="CamelCaseVariableName" />
        </rule>
        <rule ref="rulesets/design.xml" />
        <rule ref="rulesets/unusedcode.xml" />
        <rule ref="rulesets/naming.xml">
            <exclude name="ShortVariable"/>
            <exclude name="LongVariable" />
        </rule>
        <rule ref="rulesets/naming.xml/ShortVariable">
            <properties>
                <property name="exceptions" value="id,e,tz"/>
            </properties>
        </rule>
        <rule ref="rulesets/cleancode.xml">
            <exclude name="BooleanArgumentFlag"/>
            <exclude name="ElseExpression"/>
            <exclude name="StaticAccess"/>
        </rule>
        <exclude-pattern>*/_ide_helper.php</exclude-pattern>
        <exclude-pattern>*/_ide_helper_models.php</exclude-pattern>
        <exclude-pattern>*/_ide_helper_redis.php</exclude-pattern>
        <exclude-pattern>*/database/*</exclude-pattern>
        <exclude-pattern>*/cache/*</exclude-pattern>
        <exclude-pattern>*/*.blade.php</exclude-pattern>
        <exclude-pattern>*/autoload.php</exclude-pattern>
        <exclude-pattern>*/storage/*</exclude-pattern>
        <exclude-pattern>*/docs/*</exclude-pattern>
        <exclude-pattern>*/vendor/*</exclude-pattern>
        <exclude-pattern>*/migrations/*</exclude-pattern>
        <exclude-pattern>*/tmp/*</exclude-pattern>
    </ruleset>
    
    

    output message

    This is just one example, but other files are displayed as well.

    /src/app/Console/Kernel.php     -       Unexpected token: App\Console, line: 3, col: 11, file: /src/app/Console/Kernel.php.
    /src/app/Exceptions/Handler.php -       Unexpected token: App\Exceptions, line: 3, col: 11, file: /src/app/Exceptions/Handler.php.
    ...
    

    As you can see in the file below, an Unexpected token is displayed at the time of the namespace.

    https://github.com/laravel/laravel/blob/8.x/app/Console/Kernel.php https://github.com/laravel/laravel/blob/8.x/app/Exceptions/Handler.php

    Checks before submitting

    • [x] Be sure that there isn't already an issue about this. See: Issues list
    • [x] Be sure that there isn't already a pull request about this. See: Pull requests
      • Searching for issues in PHP8 and 8.0 and Unexpected
    • [x] I have added every step to reproduce the bug.
    • [ ] If possible I added relevant code examples.
    • [x] This issue is about 1 bug and nothing more.
    • [x] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
    PDepend Compatibility php8.0 
    opened by hrs-o 14
  • Compliance PHP 7.4

    Compliance PHP 7.4

    Hello, I was wondering what was the plan about making PHPMD works for PHP 7.4

    So far I have tried and obviously type properties are not working we got:

    -	Unexpected token:
    

    but also destructuring does not make phpmd happy !

    Thanks for maintaining!

    opened by Plopix 14
  • Phpmd crashes with parenthesized argument to isset

    Phpmd crashes with parenthesized argument to isset

    • PHPMD version: 2.13.0
    • PHP Version: 8.0.23
    • Installation type: phive
    • OS: Linux Alpine 3.15

    Current Behavior

    phpmd craches with the error "Unexpected token: (, ..."

    Expected Behavior

    The expected behavior should be a warning by phpmd for the extra parentheses

    Steps To Reproduce:

    The issue can be reproduced with the following valid php code.

    <?php
    $value = 1;
    if (isset(($value))) {
      print "value = $value\n";
    }
    

    Checks before submitting

    • [x] Be sure that there isn't already an issue about this. See: Issues list
    • [x] Be sure that there isn't already a pull request about this. See: Pull requests
    • [x] I have added every step to reproduce the bug.
    • [x] If possible I added relevant code examples.
    • [x] This issue is about 1 bug and nothing more.
    • [x] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
    Bug PDepend 
    opened by patrinos 1
  • Avoid using undefined variables with static array in trait

    Avoid using undefined variables with static array in trait

    • PHPMD version: 2.13.0
    • PHP Version: 8.1
    • Installation type: composer
    • Operating System / Distribution & Version: Ubuntu 22.04

    Current Behavior

    <?php
    use SomeTrait;
    
    class Example {
       use SomeTrait;
    
       public function test(){
         $bla = self::$someTraitVar['someKey'];
       }
    }
    ?>
    
    <?php
    
    trait SomeTrait {
       protected static array $someTraitVar = [
          'someKey' => 12345
       ];
    }
    ?>
    

    This will mark self::$someTraitVar['someKey']; within the test method as "Avoid using undefined variables...".

    Expected Behavior

    Should not be marked as "Avoid using undefined variables...".

    Steps To Reproduce:

    See example code above

    opened by tebeso 0
  • Changed alternative `php-includepath` to priority path

    Changed alternative `php-includepath` to priority path

    • PHPMD version: 2.12.0
    • PHP Version: 7.4
    • Installation type: (composer)
    • Operating System / Distribution & Version: (Linux)

    Current Behavior

    For now you can use php-includepath setting as an alternative path. It means that you try to find a ruleset with pathes from get_include_path() ini setting then you try to find that with <php-includepath> setting.

    Expected Behavior

    Proposition to use <php-includepath> as priority path instead of alternative. It means that paths from this setting should be added at the beginning of the include_path ini setting.

    Steps To Reproduce:

    if you use ruleset path that exist with some path from get_include_path(). it make it impossible to use that with a path <php-includepath>. Anyway you return the path from existing pathes from get_include_path().

    Checks before submitting

    • [x] Be sure that there isn't already an issue about this. See: Issues list
    • [x] Be sure that there isn't already a pull request about this. See: Pull requests
    • [x] I have added every step to reproduce the bug.
    • [x] If possible I added relevant code examples.
    • [x] This issue is about 1 bug and nothing more.
    • [x] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".

    Code example.

    PHPMD\RuleSetFactory::224 line Proposition to change $includePath = get_include_path() . PATH_SEPARATOR . $includePath; to $includePath .= PATH_SEPARATOR . get_include_path();.

    opened by vol4onok 0
  • PHPMD crashes when parsing enum with a value named

    PHPMD crashes when parsing enum with a value named "DEFAULT"

    • PHPMD version: 2.13.0 (and pdepend 2.12.1)
    • PHP Version: 8.1.7
    • Installation type: composer
    • Operating System / Distribution & Version: Alpine 3.16 (docker container)

    Current Behavior

    When an enum contains a value named DEFAULT, phpmd crashes.

    <?php
    
    enum Example
    {
        case DEFAULT;
    }
    

    Error message:

    Unexpected token: DEFAULT, line: 5, col: 10, file: /var/www/html/dev/packages/module-dataflow/Component/Database/InsertMode.php.
    #0 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(7966): PDepend\Source\Parser\UnexpectedTokenException-&gt;__construct(Object(PDepend\Source\Tokenizer\Token), Object(PDepend\Source\AST\ASTCompilationUnit))
    #1 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(8116): PDepend\Source\Language\PHP\AbstractPHPParser-&gt;getUnexpectedTokenException()
    #2 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(1099): PDepend\Source\Language\PHP\AbstractPHPParser-&gt;parseEnumCase()
    #3 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion81.php(164): PDepend\Source\Language\PHP\AbstractPHPParser-&gt;parseTypeBody(Object(PDepend\Source\AST\ASTEnum))
    #4 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(6578): PDepend\Source\Language\PHP\PHPParserVersion81-&gt;parseEnumDeclaration()
    #5 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(516): PDepend\Source\Language\PHP\AbstractPHPParser-&gt;parseOptionalStatement()
    #6 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(606): PDepend\Source\Language\PHP\AbstractPHPParser-&gt;parse()
    #7 /var/www/html/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(351): PDepend\Engine-&gt;performParseProcess()
    #8 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/Parser.php(99): PDepend\Engine-&gt;analyze()
    #9 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php(240): PHPMD\Parser-&gt;parse(Object(PHPMD\Report))
    #10 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php(136): PHPMD\PHPMD-&gt;processFiles(&#039;dev/packages/mo...&#039;, &#039;phpmd.xml.dist&#039;, Array, Object(PHPMD\RuleSetFactory), Object(PHPMD\Report))
    #11 /var/www/html/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php(184): PHPMD\TextUI\Command-&gt;run(Object(PHPMD\TextUI\CommandLineOptions), Object(PHPMD\RuleSetFactory))
    #12 /var/www/html/vendor/phpmd/phpmd/src/bin/phpmd(61): PHPMD\TextUI\Command::main(Array)
    #13 /var/www/html/vendor/bin/phpmd(120): include(&#039;/var/www/html/v...&#039;)
    #14 {main}
    

    Expected Behavior

    Expected behavior is no error, just a successful analysis.

    Steps To Reproduce:

    1. Create a file with the enum in the above example.
    2. Run phpmd on this file.
    Bug PDepend Compatibility php8.1 
    opened by guvra 2
  • Add ExceptionList property for UnusedFormalParameter

    Add ExceptionList property for UnusedFormalParameter

    Type: feature

    This PR add the exception property to the UnusedFormalParameter rule.

    Some classes of some frameworks, such as Laravel ApiResource, uses some parameters that arent used by the method.

    image

    opened by PedroPMS 8
  • Create common utility to handle exceptions lists

    Create common utility to handle exceptions lists

    Type: refactoring Breaking change: yes (protected scope)

    BC: getExceptionsList() can be called from custom rules that would extends StaticAccess, TooManyMethds, LongClassName, ShortClassName, LongVariable, ShortVariable, ShortMethodName or UnusedLocalVariable previously returned array and will now return a object implementing IteratorAggregate, ArrayAccess so if user iterates over it or call isset($exceptions[$key]) the resulting behavior will be the same, but if they expect exactly an array (strong typing or using some array_ method on it), they will need to replace $this->getExceptionList() with iterator_to_array($this->getExceptionList()) also if they overridden getExceptionList() in a sub-class, they will need to wrap the returned value in a class like:

    class ArrayWrapper
    {
        public function __construct(private array $list)
        {
        }
    
        public function contains(string $key): bool
        {
            return in_array($key, $this->list, true);
        }
    }
    

    Risk of BC for real users is low as users are encouraged to extends AbstractRule to create their own, there is little interest to extend an actual rule (BTW, they should likely be final in next major version, and have their methods private)

    Motivation: we have all the listed rules above having a getExceptionList() method, all with very close code:

    • 1 variant uses array_flip on the list then call isset instead of in_array, this variant add a fixed cost per activated rule but reduces to cost per iteration (method/class/function/variable). As per my benchmark it will benefit to each rule checking more than 13 times the exceptions list, so it would benefit to most of the projects/usages when PHPMD is given big code base, and it would make slower only analyses of very small project or partial analyze (such as a single-file check). So, in my opinion it makes sense to use the isset() variant for all rules.
    • due to slightly different method of trim/filter, ,, would in some rules generate a blank exception, in some other not, in some case whitespace around comas will be ignored but not in all rules. It sounds those differences are not wanted and just edge-case bugs. Harmonizing them would ensure a given exceptions could be used for any rule in the config and be handled the same way.
    • some rules also trim \ with whitespace, this makes sense only for class name, so I make it as a parameter and only exceptions list meant to be checked against class name have it, other get the default value "" so only whitespace is trimmed.

    Apart the $trim parameter then now rules supporting exceptions config will all have the same method implementation with minimum code:

        protected $exceptions;
    
        protected function getExceptionsList()
        {
            if ($this->exceptions === null) {
                $this->exceptions = new ExceptionsList($this);
            }
    
            return $this->exceptions;
        }
    

    After dropping PHP 5.3 this can became a trait and minimize the duplicate code accros rules.

    #924 will also require to add this config.

    Refactoring RFC 
    opened by kylekatarnls 3
Releases(2.13.0)
  • 2.13.0(Sep 10, 2022)

    Added

    • Require pdepend/pdepend 2.12
    • Added #943 Static access add ignore pattern for methods
    • Added #958 Add missing ruleset error message on baseline
    • Added #955 Add Gitlab renderer for Gitlab CI

    Fixed

    • Fixed #4 Typo on Superglobals rule
    • Fixed #976 Avoid deprecated exceptions
    • Fixed #977 Add missing github & gitlab reportfile options
    • Improved #954 npath complexity documentation with example
    • Improved #946 Highlight readme code examples

    Changed

    • #969 Update codecov intergration
    • #970 Remove Travis badge
    • #976 Avoid deprecated exceptions
    • #968 Optimize parseRuleNode steps order

    New Contributors

    • @jvipez made their first contribution in #946
    • @modess made their first contribution in #954
    • @metalmini made their first contribution in #957
    • @koenhendriks made their first contribution in #978

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @AJenbo
    • @frankdekker
    • @jlmobbex
    • @jvipez
    • @koenhendriks
    • @kylekatarnls
    • @modess
    • @metalmini
    • @tvbeek
    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.89 MB)
    phpmd.phar.asc(455 bytes)
  • 2.12.0(Mar 24, 2022)

    Added

    • Added composer/xdebug-handler 3 support #930
    • Added GitHub action config for PHP 8.1 #918 #942

    Fixed

    • Fixed #276 in #833: Disallow capital letter at the beginning in CamelCasePropertyName rule.
    • Fixed typo in exclude-pattern.xml #944

    New Contributors

    • @franmomu made their first contribution in https://github.com/phpmd/phpmd/pull/930
    • @emretepedev made their first contribution in https://github.com/phpmd/phpmd/pull/944

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @emretepedev
    • @franmomu
    • @martzd
    • @kylekatarnls
    • @tvbeek
    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.83 MB)
    phpmd.phar.asc(455 bytes)
  • 2.11.1(Dec 17, 2021)

  • 2.11.0(Nov 29, 2021)

    Added

    • Added #815 in #817: Rule name in text output

    Fixed

    • Fixed #884 in #905: Avoid unused parameters on PHP 8: Constructor property
    • Fixed #870 in #906: False-positive message "Avoid using undefined variables" on a static variable
    • Fixed #714 in #781: static:: and self:: properties access

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @kylekatarnls
    • @ravage84
    • @ricfio
    • @Sylry
    • @tvbeek
    • @YAhiru
    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.82 MB)
    phpmd.phar.asc(455 bytes)
  • 2.10.2(Jul 22, 2021)

    Added

    • Added #898 in #902: Added newline for better ANSI output

    Changed

    • Changed #901 in #903: Improve baseline basepath calculation

    Fixed

    • Fixed #894: Fixed typo in DuplicatedArrayKey title incl. link
    • Update PHP Depend to the latest version, this fixed different PHP 8 options: #889 #893 #896

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @dmetzler1988
    • @frankdekker
    • @himanshu007-creator
    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.81 MB)
    phpmd.phar.asc(455 bytes)
  • 2.10.1(May 11, 2021)

  • 2.10.0(Apr 26, 2021)

    Added

    • Added #879: Documentation for Junit export with third party
    • Added #836: Provide option to allow reference to a class in the root namespace without an import
    • Added #856: Adds checkstyle compatible renderer, suitable for cs2pr or reviewdog
    • Added #858 in #865: Add SARIF renderer.
    • Added #873 and #876: Added option to baseline existing violations
    • Added #861: Docs for GitHub renderer
    • Added #868 In #869: Option to ignore globally-namespaced classes from MissingImport
    • Added #834 : Add "tool" property to main "pmd" tag in XML report

    Changed

    • Changed #786: Add convenience method AbstractNode::findChildrenOfTypeVariable()
    • Changed documentation: #874 #849 #724
    • Changed #514 in #872: Change exit code on processing errors
    • Changed: Internal code improvement #839 #875 #838 #862 #788 #830
    • Changed #848 #864: Use GitHub actions

    Fixed

    • Fixed #673 in #782: Ignore dynamic class name from missing imports
    • Fixed #577 in #844: Recognize compact variables with double quotes
    • Fixed #818 in #822: Fix passing-by-reference detection
    • Fixed #826 in #827: Consider foreach exception only for direct children
    • Fixed #851 in #852: Fix multiple underscores in method name when allow-underscore-test is allowed
    • Fixed #846 in #847: Catch DevelopmentCodeFragment with fully qualified functions
    • Fixed #829 in #835: Fatal error while analyzing anonymous class
    • Fixed #816 in #818: Fixed undefined index referring

    Deprecated

    • Deprecated: getIgnorePattern and setIgnorePattern on PHPMD\PHPMD see #772

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @a-menshchikov
    • @babanesma
    • @ComiR
    • @danepowell
    • @ffflabs
    • @frankdekker
    • @kamioftea
    • @kdebisschop
    • @kylekatarnls
    • @lukasbestle
    • @martzd
    • @ravage84
    • @SanderSander
    • @tvbeek

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.79 MB)
    phpmd.phar.asc(455 bytes)
  • 2.9.1(Sep 23, 2020)

    Fixed

    • Fixed #714: Improved static member detection
    • Fixed #816: Fixed undefined index referring

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @a-menshchikov
    • @kylekatarnls

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.69 MB)
    phpmd.phar.asc(581 bytes)
  • 2.9.0(Sep 2, 2020)

    Added

    • Added #496: Add rule for PHP's @ operator
    • Added #737: Allowing custom exclusion for StaticAccess by extending the class
    • Added #749: Add allow-underscore option for CamelCaseParameterName & CamelCaseVariableName
    • Added #747: Long variable subtract suffix
    • Added #763 via #765: Added rules LongClassName and ShortClassName

    Changed

    • Changed: #529 : Replaced HTML renderer with new "pretty HTML" renderer
    • Changed: #806 : Changed #44 Change private methods to protected in rules. Make rules extendable
    • Changed: Internal code improvement #750 #752 #756 #757 #758 #759 #768 #773 #775 #785 #787 #791 #792

    Fixed

    • Fixed #743: Output for version
    • Fixed #754: Fixed #720 undefined variable in foreach when passed by reference
    • Fixed #764: Fixed #718 Handle anonymous class in "undefined variable" rule
    • Fixed #770: Fixed #769 Handle deconstruction assignation for undefined variable
    • Fixed #781: Fixed #714 static:: and self:: properties access
    • Fixed #784: Fixed #672 Handle passing-by-reference in native PHP functions
    • Fixed #793: Fixed #580 Raise UnusedFormalParameter instead UnusedLocalVariable for unused closure parameter
    • Fixed #794: Fixed #540 Detect unused variable declared multiple times
    • Fixed #805: Fixed #802 Prevent an error with nested arrays
    • Fixed #807: Fixed #790 Fix for short variables rule inside foreach statements
    • Fixed #809: Fixed #808 Ignore rule path for supression annotation
    • Updated different parts of the documentation. #717 #736 #748 #811

    Deprecated

    • Deprecated all the PHPMD exceptions that aren't part of the PHPMD\Exceptions namespace. See #775

    A potential BC change:

    With the clean-up in #768 we have a potential BC break in an unsupported part that we want to give attention for.

    The class aliases PHP_PMD_* used for PHPMD 1.x backwards PEAR compatibility were removed. If you happen to still depend on these, please adjust your code like so:

    From PHP_PMD_[Component]_[Class]' to PHPMD\[Component]\[Class], as in PHP_PMD_Renderer_HTMLRenderer' to PHPMD\Renderer\HTMLRenderer. See #768

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @ale7714
    • @artem-prozorov
    • @eeree
    • @frankdekker
    • @kylekatarnls
    • @MarkVaughn
    • @ondrejfuhrer
    • @ravage84
    • @smuuf
    • @sveneld
    • @tuc0w
    • @tvbeek
    • @tuc0w

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.69 MB)
    phpmd.phar.asc(581 bytes)
  • 2.8.2(Feb 24, 2020)

    Fixed

    • Fixed #732: Added __serialize and __unserialize to list of ignored methods for camelCase rule.

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @kylekatarnls

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.64 MB)
    phpmd.phar.asc(581 bytes)
  • 2.8.1(Dec 27, 2019)

    Fixed

    • Fixed PHP 7.4 unit tests compatibility
    • Improved documentation
    • Automated website generation and PHAR publishing

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @tvbeek
    • @kylekatarnls
    • @BackEndTea

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.64 MB)
    phpmd.phar.asc(581 bytes)
  • 2.8.0(Dec 24, 2019)

    Added

    • Required at least pdepend/pdepend 2.6:
      • Added PHP 7.1 to 7.3 syntax support
      • Added Symfony 5 support
    • #571: Added ignore-namespaces property to DevelopmentCodeFragment rule
    • #595: Added a renderer which writes an ansi report string

    Fixed

    • Improved performances by disabling XDebug if in use
    • #657 Fix IfStatementAssignment violation message
    • #667: Be sure the phar file use the latest possible versions of dependencies (like pdepend)
    • #661: Fix IfStatementAssignment thrown incorrectly
    • #676: Handle @SuppressWarnings on each method for CountInLoop
    • #659: Update RuleSetFactory to be PHP 7.4 compatible
    • Update different parts of the documentation. #595 #645 #646 #648 #652 #665 #679 #691

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @raa0121
    • @AJenbo
    • @DannyvdSluijs
    • @eeree
    • @Jir4
    • @poplary
    • @SailorMax
    • @tariq86
    • @PtrTn
    • @wirwolf
    • @tvbeek
    • @szepeviktor
    • @kylekatarnls
    • @ravage84

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.64 MB)
    phpmd.phar.asc(581 bytes)
  • 2.8.0-beta.2(Dec 16, 2019)

    Added

    • Required at least pdepend/pdepend 2.6:
      • Added PHP 7.1 to 7.3 syntax support
      • Added Symfony 5 support
    • #571: Added ignore-namespaces property to DevelopmentCodeFragment rule
    • #595: Added a renderer which writes an ansi report string

    Fixed

    • Improved performances by disabling XDebug if in use
    • #657 Fix IfStatementAssignment violation message
    • #667: Be sure the phar file use the latest possible versions of dependencies (like pdepend)
    • #661: Fix IfStatementAssignment thrown incorrectly
    • #676: Handle @SuppressWarnings on each method for CountInLoop
    • #659: Update RuleSetFactory to be PHP 7.4 compatible
    • Update different parts of the documentation. #595 #645 #646 #648 #652 #665 #679 #691

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @raa0121
    • @AJenbo
    • @DannyvdSluijs
    • @eeree
    • @Jir4
    • @poplary
    • @SailorMax
    • @tariq86
    • @PtrTn
    • @wirwolf
    • @tvbeek
    • @szepeviktor
    • @kylekatarnls
    • @ravage84

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.62 MB)
    phpmd.phar.asc(581 bytes)
  • 2.8.0-beta.1(Dec 4, 2019)

    Added

    • #571: Added ignore-namespaces property to DevelopmentCodeFragment rule
    • #595: Added a renderer which writes an ansi report string

    Fixed

    • Improved performances by disabling XDebug if in use
    • #657 Fix IfStatementAssignment violation message
    • #667: Be sure the phar file use the latest possible versions of dependencies (like pdepend)
    • #661: Fix IfStatementAssignment thrown incorrectly
    • #676: Handle @SuppressWarnings on each method for CountInLoop
    • #659: Update RuleSetFactory to be PHP 7.4 compatible
    • Update different parts of the documentation. #595 #645 #646 #648 #652 #665 #679 #691

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @raa0121
    • @AJenbo
    • @DannyvdSluijs
    • @eeree
    • @Jir4
    • @poplary
    • @SailorMax
    • @tariq86
    • @PtrTn
    • @wirwolf
    • @tvbeek
    • @szepeviktor
    • @kylekatarnls
    • @ravage84

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.63 MB)
    phpmd.phar.asc(581 bytes)
  • 2.7.0(Jul 30, 2019)

    The new maintainer team of PHPMD is pleased to announce its first minor release PHP Mess Detector version 2.7.0.

    This contains all the new features, improvements and fixes from over 250 commits from two and a half years since 2.6.0. Please, also take note of a backwards incompatible property renaming in the CouplingBetweenObjects rule.

    Added

    Fixed

    • #482: Renamed minimum property to maximum in CouplingBetweenObjects rule (backwards incompatible)
    • #626: Fixed special characters escaping in violation description for XML output
    • #378: Fixed warning/error when trying to export to a non-existing path
    • #575: Fixed UnusedFormalParameter false positive in string compound variable
    • #480: Fixed "Start tag expected, '<' not found" error
    • #494: Fixed UnusedPrivateField false positive
    • #583: Changed LongNaming rule to apply on private fields too
    • #572: Added support for both @SuppressWarnings and @suppressWarnings annotation cases

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @eeree
    • @DmitryNaum
    • @john-whitley
    • @JulienPalard
    • @ravage84
    • @exploitfate
    • @RyDroid
    • @tominventisbe
    • @dxops
    • @jaymoulin
    • @avmnu-sng
    • @HappyHippyHippo
    • @vt-iwamoto
    • @choult
    • @liviascapin
    • @kylekatarnls
    • @JeroenDeDauw
    • @emirb
    • @tvbeek
    • @OndraM
    • @Marius786
    • @BenjaminPaap
    • @fbertolotti
    • @gbirke
    • @MarkVaughn
    • @rafalwrzeszcz
    • @mindplay-dk
    • @KOLANICH
    • @schinkel
    • @jhoff
    • @EvgenyOrekhov
    • @1ma
    • @duncancumming
    • @edhgoose
    • @mermshaus
    • @manuelpichler
    • @richvigorito

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.30 MB)
    phpmd.phar.asc(581 bytes)
  • 2.6.1(Jul 5, 2019)

    The new maintainer team of PHPMD is pleased to announce PHP Mess Detector version 2.6.1. This is a patch release for the 2.6.x release branch.

    Changes

    You can expect the following changes in this release:.

    • Build the PHAR file on Travis-CI and publish it to GitHub releases #616

    Consult the changelog for the full history of noteworthy changes or browse through the list of commits since the last release.

    Contributors to this release

    We would like to thank all the contributors that helped make this release possible:

    • @jakzal
    • @ravage84

    Also, we are very grateful to contributors that opened issues, created pull requests or participated as our community.

    Source code(tar.gz)
    Source code(zip)
    phpmd.phar(2.37 MB)
Owner
PHP Mess Detector
PHP Mess Detector
Debugger frontend

Yii Debug Viewer The package ... Requirements PHP 7.4 or higher. Installation The package could be installed with composer: composer require yiisoft/y

Yii Software 10 Jul 25, 2022
A tool for quickly measuring the size of a PHP project.

PHPLOC phploc is a tool for quickly measuring the size and analyzing the structure of a PHP project. Installation This tool is distributed as a PHP Ar

Sebastian Bergmann 2.3k Jan 4, 2023
Beautiful and understandable static analysis tool for PHP

PhpMetrics PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report. Documentation | Twitter | Contributing

PhpMetrics 2.3k Dec 22, 2022
PHP completion, refactoring, introspection tool and language server.

Phpactor This project aims to provide heavy-lifting refactoring and introspection tools which can be used standalone or as the backend for a text edit

Phpactor 882 Jan 1, 2023
Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects

Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. You can freely define your architectural layers over classes and which rules should apply to them.

QOSSMIC GmbH 2.2k Dec 30, 2022
PHP Architecture Tester - Easy to use architectural testing tool for PHP :heavy_check_mark:

Easy to use architecture testing tool for PHP Introduction ?? PHP Architecture Tester is a static analysis tool to verify architectural requirements.

Carlos A Sastre 765 Dec 30, 2022
A tool to automatically fix PHP Coding Standards issues

PHP Coding Standards Fixer The PHP Coding Standards Fixer (PHP CS Fixer) tool fixes your code to follow standards; whether you want to follow PHP codi

null 11.6k Jan 3, 2023
PHP Static Analysis Tool - discover bugs in your code without running it!

PHPStan - PHP Static Analysis Tool PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even b

PHPStan 11.6k Dec 30, 2022
A PHP code-quality tool

GrumPHP Sick and tired of defending code quality over and over again? GrumPHP will do it for you! This composer plugin will register some git hooks in

PHPro 3.9k Jan 1, 2023
A command line refactoring tool for PHP

PHP Refactoring Browser Note: This software is under development and in alpha state. Refactorings do not contain all necessary pre-conditions and migh

QafooLabs 562 Dec 30, 2022
A static php code analysis tool using the Graph Theory

Mondrian Ok guyz, you have a master degree in Graph Theory, you follow Law of Demeter and you live on S.O.L.I.D principles ? Let's have some Fun ! (^ω

Florent Genette 391 Nov 30, 2022
PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions.

PHPCheckstyle Overview PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions. The tools checks the inpu

PHPCheckstyle 157 Dec 5, 2022
A static analysis tool for finding errors in PHP applications

Psalm Psalm is a static analysis tool for finding errors in PHP applications. Installation To get started, check out the installation guide. Live Demo

Vimeo 5k Jan 2, 2023
A web tool to explore the ASTs generated by PHP-Parser.

phpast.com A web tool to explore the ASTs generated by PHP-Parser. About This web tool provides a GUI for exploring the AST of your PHP code. You can

Ryan Chandler 23 Nov 29, 2022
A tool to automatically fix PHP Coding Standards issues by Dragon Code.

A tool to automatically fix PHP Coding Standards issues by Dragon Code.

The Dragon Code 24 Aug 27, 2022
Tool helping us to analyze software projects

Qafoo Quality Analyzer This software is a tool to visualize metrics and source code. We use this software for Code Reviews together with our customers

Qafoo GmbH 494 Dec 29, 2022
Baseline tool for PHP_CodeSniffer

PHP_CodeSniffer Baseliner This tool enables you to integrate PHP_CodeSniffer into an existing project by automatically adding phpcs:ignore and phpcs:d

ISAAC 13 Nov 26, 2022
All In 1 Spam Tool For Termux Users Subscribe Us (Noob Hackers) some shit heads are trying to abuse this script so don't worry about them ...let them hallucinate ...but you are free to use this script

ABOUT TOOL : SPAMX is a all in one Bombing+Spam tool from this tool you can send anonymous messages to your target without showing your real number an

N17R0 449 Jan 7, 2023
A static analysis tool for security

progpilot A static analyzer for security purposes Only PHP language is currently supported Installation Option 1: use standalone phar Download the lat

null 271 Dec 27, 2022