2013-07-11 40 views
0

我使用php Depend和PMD時出現問題。當我使用:使用PHP_Depend和PHP_PMD時出錯

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

這就是結果:

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

同樣有發生:

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 

¿任何sugestion?謝謝。

回答

0

這是一個pdepend和pmd的bug。在/usr/share/php/PHP/Depend/parser.php我改變:

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

此:

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

我只獲得警告,並在過程中不斷:

PHP的警告:缺少PHP_Depend_Token :: __ construct()的參數1,在第5442行的/usr/share/php/PHP/Depend/Parser.php中調用,並在/usr/share/php/PHP/Depend/Token.php中在線定義121

我們可以等下一次升級e;)