Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phpmd crashes with parenthesized argument to isset #992

Open
6 tasks done
patrinos opened this issue Dec 22, 2022 · 1 comment
Open
6 tasks done

Phpmd crashes with parenthesized argument to isset #992

patrinos opened this issue Dec 22, 2022 · 1 comment

Comments

@patrinos
Copy link

patrinos commented Dec 22, 2022

  • 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

  • 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".
@tvbeek
Copy link
Member

tvbeek commented Dec 22, 2022

@patrinos thanks for reporting

The full trace is:

        -       Unexpected token: (, line: 3, col: 11, file: /home/tjvb/projects/phpmd/test.php.
#0 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(7440): PDepend\Source\Parser\UnexpectedTokenException->__construct()
#1 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4536): PDepend\Source\Language\PHP\AbstractPHPParser->getUnexpectedTokenException()
#2 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(4901): PDepend\Source\Language\PHP\AbstractPHPParser->parseVariableOrConstantOrPrimaryPrefix()
#3 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2204): PDepend\Source\Language\PHP\AbstractPHPParser->parseVariableList()
#4 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2819): PDepend\Source\Language\PHP\AbstractPHPParser->parseIssetExpression()
#5 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(2500): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalExpression()
#6 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion70.php(278): PDepend\Source\Language\PHP\AbstractPHPParser->parseBraceExpression()
#7 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(3491): PDepend\Source\Language\PHP\PHPParserVersion70->parseParenthesisExpression()
#8 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(6101): PDepend\Source\Language\PHP\AbstractPHPParser->parseIfStatement()
#9 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php(397): PDepend\Source\Language\PHP\AbstractPHPParser->parseOptionalStatement()
#10 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(587): PDepend\Source\Language\PHP\AbstractPHPParser->parse()
#11 /home/tjvb/projects/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php(335): PDepend\Engine->performParseProcess()
#12 /home/tjvb/projects/phpmd/src/main/php/PHPMD/Parser.php(99): PDepend\Engine->analyze()
#13 /home/tjvb/projects/phpmd/src/main/php/PHPMD/PHPMD.php(240): PHPMD\Parser->parse()
#14 /home/tjvb/projects/phpmd/src/main/php/PHPMD/TextUI/Command.php(136): PHPMD\PHPMD->processFiles()
#15 /home/tjvb/projects/phpmd/src/main/php/PHPMD/TextUI/Command.php(184): PHPMD\TextUI\Command->run()
#16 /home/tjvb/projects/phpmd/src/bin/phpmd(61): PHPMD\TextUI\Command::main()
#17 {main}

This result in that it is a crash for PDepend, I have created in issue in that repository ( pdepend/pdepend#639 )

@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants