PHP已成为时下最热门的编程语言之一,然而却有许多PHP程序员苦恼找不到合适的工具来帮助本身分析和解析PHP代码。今天小编就为你们介绍几个很是不错的工具,来帮助程序员们提升本身的工做效率,一块儿来看看吧!php
PHP-Parser是一个用PHP编写的PHP解析器(支持PHP 5.4以及更早的版本),这种特殊的解析器很是适合静态代码分析。该工具的目的就是简化静态代码分析和操做,它使程序员可以以编程的方式来处理任何应用程序的代码。html
PHPSandbox将运行PHP做为独立进程的一种方式。 它为程序员提供一种外围脚本的保护,好比错误、崩溃、运行慢的脚本,或者不适合在代码中运行的脚本,均可做为独立进程来运行。git
PHPMD这个工具可以探测PHP源代码中一些潜在的问题。例如:程序员
PHPCPD是一个在代码中寻找相似模式的工具,使用它是为了在代码库中识别代码在何处被复制或粘贴。这是常规构建过程当中一个很是有用的工具,它会帮助程序员分析代码,以免在代码库中重复调用函数。github
PHPCheckstyle是一个帮助PHP程序员检查代码和报告错误的工具,运行于PHP 5.0以及更高的版本。经过SVN钩子脚本的方式来调用PHPCheckstyle,能够强制代码必须符合预先设定的编码标准(好比PEAR编码标准),有助于在多人合做项目中提升代码总体质量。编程
Ubench是一个用于评测PHP代码执行时间和内存使用效率的开发库。使用方法以下:app
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
require_once
'src/Ubench.<span id="1_nwp" style="width: auto; height: auto; float: none;"><a id="1_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=php&k0=php&kdi0=0&luki=8&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="1" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">php</span></a></span>'
;
$bench
=
new
Ubench;
$bench
->start();
// Execute some code
$bench
->
end
();
// Get elapsed time and <span id="2_nwp" style="width: auto; height: auto; float: none;"><a id="2_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=memory&k0=memory&kdi0=0&luki=4&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="2" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">memory</span></a></span>
echo
$bench
->getTime();
// 156ms or 1.123s
echo
$bench
->getTime(true);
// elapsed microtime in float
echo
$bench
->getTime(false,
'%d%s'
);
// 156ms or 1s
echo
$bench
->getMemoryPeak();
// 152B or 90.00Kb or 15.23Mb
echo
$bench
->getMemoryPeak(true);
// memory <span id="3_nwp" style="width: auto; height: auto; float: none;"><a id="3_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=peak&k0=peak&kdi0=0&luki=3&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="3" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">peak</span></a></span> in bytes
echo
$bench
->getMemoryPeak(false,
'%.3f%s'
);
// 152B or 90.152Kb or 15.234Mb
// Returns the memory usage at the end <span id="4_nwp" style="width: auto; height: auto; float: none;"><a id="4_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=mark&k0=mark&kdi0=0&luki=2&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="4" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">mark</span></a></span>
echo
$bench
->getMemoryUsage();
// 152B or 90.00Kb or 15.23Mb
|
PHP Analyzer执行和编译器相同的流动分析,确保代码在每一个潜在执行路径的每一行都执行了测试。这种特殊的工具帮助开发人员提升了本身的代码质量,从而确保了工做效率。编程语言