Critiquing PHP-code / PerlCritic for PHP?

做~自己de王妃 提交于 2019-12-06 08:13:49

问题


I'm looking for an equivalent of PerlCritic for PHP. PerlCritc is a static source code analyzer that qritiques code and warns about everything from unused variables, to unsafe ways to handle data to almost anything.

Is there such a thing for PHP that could (preferably) be run outside of an IDE, so that source code analysis could be automated?


回答1:


Not sure I've ever heard about a PHP tool that would do all that... But a couple of existing QA-related tools, that might help you at least a bit, would be :

  • PHPMD - PHP Mess Detector -- might actually be the best choice for you, if you consider the set of rules it checks for.
  • PHP_CodeSniffer
  • PHP_Depend
  • Of course, phpDocumentor can help too : when generating the phpDoc, it can report errors, especially about missing doc-blocks (doesn't report errors in the code, but can still help improve its quality !)
  • And don't forget the Xdebug extension, that can generate code-coverage reports, which are especially useful when your code is unit-tested with PHPUnit.

Those two will analyse your code, and can be run from the command-line (i.e. outside of an IDE).




回答2:


See SD PHP CloneDR for a static analysis tool that finds duplicated code (exact and near misses) across large bodies of PHP code.

There are examples of a PHP clone detection run on the Joomla OSS web framework at the site.



来源:https://stackoverflow.com/questions/2432576/critiquing-php-code-perlcritic-for-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!