Analysis¶
Analysis in software development refers to the systematic examination of source code, runtime behaviour, or architecture to detect issues, measure quality, or derive understanding.
Static analysis examines code without executing it. Tools such as PHPStan, Psalm, and Phan inspect PHP source files for type errors, undefined variables, dead code, and security vulnerabilities. Exakat is a static analyser specifically designed for PHP, able to audit large codebases and enforce rules across many categories.
Dynamic analysis examines code during execution. It covers profiling, fuzzing, mutation testing, and runtime error detection.
Architectural analysis focuses on the relationships between components, coupling, cohesion, and adherence to intended design patterns.
<?php
// Running static analysis from PHP (e.g., as part of a CI pipeline)
$output = [];
$exitCode = 0;
exec('vendor/bin/phpstan analyse src --level=8 --no-progress', $output, $exitCode);
if ($exitCode !== 0) {
echo implode(PHP_EOL, $output);
exit($exitCode);
}
?>
See also PHPStan, Psalm, Exakat and Top 7 Methods, Pros/Cons and Best Practices.
Related : Static Application Security Testing (SAST), Linting, Abstract Syntactic Tree (AST), Metrics, Quality, Code Review, Continuous Integration (CI), Dead Code, Type Coverage, Code Inventory, Static Code Analysis (SCA), Tool, Lexical Analysis, Semantic Analysis, Control Flow Analysis, Data Flow Analysis (DFA), Symbolic Analysis, Pattern-Based Analysis, Linting
Related packages : phpstan/phpstan, vimeo/psalm, phan/phan