7 Tools for parsing and parsing PHP code
PHP has become one of the most popular programming languages, but many PHP programmers fret that they can't find the right tools to help analyze and parse PHP code. Today's small series for you to introduce a few very good tools to help programmers improve their efficiency, come together to see it!
PHP Parser
Php-parser is a PHP parser written in PHP (PHP 5.4 and earlier), a special parser ideal for static code analysis. The purpose of the tool is to simplify static code analysis and manipulation, which enables programmers to programmatically manipulate the code of any application.
Phpsandbox
Phpsandbox is a way to run PHP as a standalone process. It provides programmers with the protection of a perimeter script, such as errors, crashes, slow scripts, or scripts that are not suitable for running in code, and can be run as standalone processes.
PHP Mess Detector
PHPMD This tool can detect some potential problems in PHP source code. For example:
- Bugs that may exist
- Code that is not up to the best standard
- Too complex a grammar
- Parameters, methods, properties that have never been used
Phpcpd
PHPCPD is a tool that looks for similar patterns in code and uses it to identify where code is copied or pasted in the code base. This is a very useful tool in the regular build process that helps programmers analyze code to avoid repeating calls to functions in the code base.
Phpcheckstyle
Phpcheckstyle is a tool that helps PHP programmers check code and report errors, running in PHP 5.0 and later. Invoking Phpcheckstyle via the SVN hook script can force code to conform to pre-programmed coding standards (such as the Pear encoding standard), helping to improve the overall quality of the code in a multi-person collaborative project.
Ubench
Ubench is a development library that evaluates PHP code execution time and memory usage efficiency. Here's how to use it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
require_once 'src/Ubench.php'
;
$bench =
new Ubench;
$bench
->start();
// Execute some code
$bench
->
end
();
// Get elapsed time and memory
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 peak in bytes
echo $bench
->getMemoryPeak(false,
'%.3f%s'
);
// 152B or 90.152Kb or 15.234Mb
// Returns the memory usage at the end mark
echo $bench
->getMemoryUsage();
// 152B or 90.00Kb or 15.23Mb
|
PHP Analyzer
PHP Analyzer performs the same flow analysis as the compiler, ensuring that the code performs tests on every line of the potential execution path. This special tool helps developers improve their code quality to ensure productivity.