Question

I have a problem using php Depend and PMD. When I use:

pdepend --summary-xml=/home/<mydirectory>/.sonar/pdepend.xml --suffix=php,php3,php4,php5,phtml,inc /home/<mydirectory>

this is the result:

Parsing...
.................................................. 1260
........................PHP Catchable fatal error: Argument 1 passed to PHP_Depend_Parser_UnexpectedTokenException::__construct() must be an instance of PHP_Depend_Token, integer given, called in /usr/share/php/PHP/Depend/Parser.php on line 5444 and defined in /usr/share/php/PHP/Depend/Parser/UnexpectedTokenException.php on line 70 PHP Stack trace: PHP 1. {main}() /usr/bin/pdepend:0 PHP 2. PHP_Depend_TextUI_Command::main() /usr/bin/pdepend:78 PHP 3. PHP_Depend_TextUI_Command->run() /usr/share/php/PHP/Depend/TextUI/Command.php:679 PHP 4. PHP_Depend_TextUI_Runner->run() /usr/share/php/PHP/Depend/TextUI/Command.php:206 PHP 5. PHP_Depend->analyze() /usr/share/php/PHP/Depend/TextUI/Runner.php:331 PHP 6. PHP_Depend->performParseProcess() /usr/share/php/PHP/Depend.php:306 PHP 7. PHP_Depend_Parser->parse() /usr/share/php/PHP/Depend.php:560 PHP 8. PHP_Depend_Parser->parseOptionalStatement() /usr/share/php/PHP/Depend/Parser.php:370 PHP 9. PHP_Depend_Parser->parseIfStatement() /usr/share/php/PHP/Depend/Parser.php:5474 PHP 10. PHP_Depend_Parser->parseStatementBody() /usr/share/php/PHP/Depend/Parser.php:3195 PHP 11. PHP_Depend_Parser->parseStatement() /usr/share/php/PHP/Depend/Parser.php:2320 PHP 12. PHP_Depend_Parser_UnexpectedTokenException->__construct() /usr/share/php/PHP/Depend/Parser.php:5444

The same happens with:

phpmd /home/<mydirectory> xml /home/<mydirectory>/Sonar_Way_php.xml 

PHP Catchable fatal error: Argument 1 passed to PHP_Depend_Parser_UnexpectedTokenException::__construct() must be an instance of PHP_Depend_Token, integer given, called in /usr/share/php/PHP/Depend/Parser.php on line 5444 and defined in /usr/share/php/PHP/Depend/Parser/UnexpectedTokenException.php on line 70 PHP Stack trace:

PHP   1. {main}() /usr/bin/phpmd:0
PHP   2. PHP_PMD_TextUI_Command::main() /usr/bin/phpmd:48
PHP   3. PHP_PMD_TextUI_Command->run() /usr/share/php/PHP/PMD/TextUI/Command.php:151
PHP   4. PHP_PMD->processFiles() /usr/share/php/PHP/PMD/TextUI/Command.php:129
PHP   5. PHP_PMD_Parser->parse() /usr/share/php/PHP/PMD.php:203
PHP   6. PHP_Depend->analyze() /usr/share/php/PHP/PMD/Parser.php:128
PHP   7. PHP_Depend->performParseProcess() /usr/share/php/PHP/Depend.php:306
PHP   8. PHP_Depend_Parser->parse() /usr/share/php/PHP/Depend.php:560
PHP   9. PHP_Depend_Parser->parseOptionalStatement() /usr/share/php/PHP/Depend/Parser.php:370
PHP  10. PHP_Depend_Parser->parseIfStatement() /usr/share/php/PHP/Depend/Parser.php:5474
PHP  11. PHP_Depend_Parser->parseStatementBody() /usr/share/php/PHP/Depend/Parser.php:3195
PHP  12. PHP_Depend_Parser->parseStatement() /usr/share/php/PHP/Depend/Parser.php:2320
PHP  13. PHP_Depend_Parser_UnexpectedTokenException->__construct() /usr/share/php/PHP/Depend/Parser.php:5444

¿Any sugestion? Thanks.

No correct solution

OTHER TIPS

It's a bug of pdepend and pmd. In /usr/share/php/PHP/Depend/parser.php I changed:

private function parseStatement()
{
    if (null === ($stmt = $this->parseOptionalStatement())) {
        throw new PHP_Depend_Parser_UnexpectedTokenException(
            $this->tokenizer->next(),
            $this->sourceFile->getFileName()
        );
    }
    return $stmt;
}

for this:

private function parseStatement()
{
    if (null === ($stmt = $this->parseOptionalStatement())) {
        throw new PHP_Depend_Parser_UnexpectedTokenException(
            new PHP_Depend_Token,
            $this->sourceFile->getFileName()
        );
    }
    return $stmt;
}

I obtain only warnings and the process continue:

PHP Warning: Missing argument 1 for PHP_Depend_Token::__construct(), called in /usr/share/php/PHP/Depend/Parser.php on line 5442 and defined in /usr/share/php/PHP/Depend/Token.php on line 121

We can wait next upgrade ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top