phpmd / 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.

Home Page:https://phpmd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Runing w/ cleancode crashes

semirke opened this issue · comments

  • PHPMD version: github master branch

  • PHP Version: PHP 7.4.33 (cli) (built: Nov 15 2022 06:03:30) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies

  • Installation type: git + composer

  • Operating System / Distribution & Version: Debian 11

Current Behavior

I get a stack trace:
Fatal error: Uncaught Error: Call to a member function getParent() on null in /opt/phpmd/src/main/php/PHPMD/Rule/AbstractLocalVariable.php:297
Stack trace:
#0 /opt/phpmd/src/main/php/PHPMD/Rule/CleanCode/UndefinedVariable.php(76): PHPMD\Rule\AbstractLocalVariable->isPassedByReference(Object(PHPMD\Node\ASTNode))
#1 /opt/phpmd/src/main/php/PHPMD/RuleSet.php(262): PHPMD\Rule\CleanCode\UndefinedVariable->apply(Object(PHPMD\Node\MethodNode))
#2 /opt/phpmd/src/main/php/PHPMD/Parser.php(295): PHPMD\RuleSet->apply(Object(PHPMD\Node\MethodNode))
#3 /opt/phpmd/src/main/php/PHPMD/Parser.php(270): PHPMD\Parser->apply(Object(PHPMD\Node\MethodNode))
#4 [internal function]: PHPMD\Parser->visitMethod(Object(PDepend\Source\AST\ASTMethod), NULL)
#5 /opt/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/AbstractASTArtifact.php(274): call_user_func(Array, Object(PDepend\Source\AST\ASTMethod), NULL)
#6 /opt/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/ASTVisitor/AbstractASTVisitor.php(113): PDepend\Source\AST\AbstractAS in /opt/phpmd/src/main/php/PHPMD/Rule/AbstractLocalVariable.php on line 297

Expected Behavior

A report.

Steps To Reproduce:

phpmd . ansi cleancode,controversial,design,naming,unusedcode --suffixes=php

It's reproducible on phpmd's own code, too.

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".