Skip to content

Instantly share code, notes, and snippets.

@zaenk
Last active August 4, 2022 09:17
Show Gist options
  • Save zaenk/fd40178cb4c687d84430491281a152fa to your computer and use it in GitHub Desktop.
Save zaenk/fd40178cb4c687d84430491281a152fa to your computer and use it in GitHub Desktop.
Configure phan static analysis tool for a Yii2 project

Configure phan static analysis tool for a Yii2 project

Prerequisites:

  • Windows 10
  • Git bash
  • XAMPP portable with PHP 7.0
  • php and composer on path

Steps to configure

  • wget https://windows.php.net/downloads/pecl/releases/ast/0.1.6/php_ast-0.1.6-7.0-ts-vc14-x86.zip
  • extract php_ast.dll to $PHP/ext
  • add extension=php_ast.dll to php.ini
  • composer require phpdocumentor/reflection-docblock:~4.3.0
  • composer require phan/phan
  • add the autoload to composer.json
"autoload": {
    "psr-4": {
        "": ["common/", "frontend/"]
    }
}
  • Generate conifg, set the analysis level to the most forgiving level:
    • .\vendor\bin\phan --init --init-level=5 (only if .phar/config.php not exists)
    • .\vendor\bin\phan
  • Or set it to the most restriciteve level:
    • .\vendor\bin\phan --init --init-level=1 --init-overwrite
    • .\vendor\bin\phan

Source

@manojshinde404
Copy link

PHP Warning: PHP Startup: Unable to load dynamic library 'php_ast.dll' (tried: C:\PHP\ext\php_ast.dll (The specified module could not be found), C:\PHP\ext\php_php_ast.dll.dll (The specified module could not be found)) in Unknown on line 0

@manojshinde404
Copy link

could you please help me out for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment