Forrest logo
tool overview
On this page you find all important commands for the CLI tool phan. If the command you are looking for is missing please ask our AI.

phan

Phan is a command line tool, written in PHP, that is used for static analysis of PHP code. It is primarily designed for detecting potential issues and providing helpful suggestions to improve code quality. Phan utilizes both the PHP-Parser and the PHP-AST libraries to parse and analyze PHP code.

The tool focuses on identifying potential runtime errors, such as undefined variables, missing or mismatched function arguments, and incorrect function calls. It can also detect issues related to type compatibility, such as type mismatches, undefined class references, and invalid property accesses.

Phan supports a wide range of PHP features, including the latest PHP 8 syntax, as well as numerous extensions and language constructs. It provides detailed error messages with precise locations, aiding developers in quickly locating and addressing issues in their codebase.

One beneficial aspect of Phan is its extensibility. It allows developers to add custom checks and plugins to enforce specific coding standards or project-specific rules. It also integrates with popular code editors and IDEs, such as Visual Studio Code and PHPStorm, to provide real-time feedback during development.

Phan supports various configuration options to fine-tune its analysis, including options to exclude specific files or directories from analysis, customize error reporting levels, and define additional type annotations.

The tool can be integrated into continuous integration (CI) pipelines to automatically analyze code changes and flag potential issues before merging them into the main codebase. This helps in maintaining code quality and minimizing the introduction of bugs.

Phan has an active open-source community and is regularly updated to support new PHP language features and provide better analysis capabilities. It is widely used in the PHP development community to improve code quality, catch potential bugs, and enhance overall development practices.

Overall, Phan is a powerful command line tool for static analysis of PHP code, offering developers a comprehensive set of checks and suggestions to ensure their code is efficient, reliable, and maintainable.

List of commands for phan:

  • phan:tldr:07cdf phan: Generate a `.phan/config.php` in the current directory.
    $ phan --init
    try on your machine
    explain this command
  • phan:tldr:2f32c phan: Specify the output mode.
    $ phan --output-mode ${select}
    try on your machine
    explain this command
  • phan:tldr:52f66 phan: Specify the number of parallel processes.
    $ phan --processes ${number_of_processes}
    try on your machine
    explain this command
  • phan:tldr:5f6c3 phan: Generate a Phan configuration file using a specific level (1 being strictest to 5 being the least strict).
    $ phan --init --init-level ${level}
    try on your machine
    explain this command
  • phan:tldr:abba8 phan: Analyze the current directory.
    $ phan
    try on your machine
    explain this command
  • phan:tldr:bfb30 phan: Specify a config file (defaults to `.phan/config.php`).
    $ phan --config-file ${path-to-config-php}
    try on your machine
    explain this command
  • phan:tldr:dfa63 phan: Analyze one or more directories.
    $ phan --directory ${path-to-directory} --directory ${path-to-another_directory}
    try on your machine
    explain this command
tool overview