yamadashy / phpstan-friendly-formatter

🀝 A friendly error formatter extension for PHPStan that provides more readable and informative output, including code snippets and color highlighting.
https://packagist.org/packages/yamadashy/phpstan-friendly-formatter
MIT License
44 stars 1 forks source link
code-quality developer-tools php php8 phpstan phpstan-extension static-analysis static-code-analysis testing

🀝 PHPStan Friendly Formatter

Downloads Test Status Latest Version License

Enhance your PHPStan experience with a formatter that brings your code to life! πŸš€

🌟 Features

PHPStan Friendly Formatter Example

🎯 Motivation

Ever felt lost in a sea of file paths and line numbers? We've been there! That's why we created this formatter to:

πŸš€ Getting Started

  1. You may use Composer to install this package as a development dependency.

    composer require --dev yamadashy/phpstan-friendly-formatter
  2. Register error formatter into your phpstan.neon or phpstan.neon.dist:

    includes:
    - ./vendor/yamadashy/phpstan-friendly-formatter/extension.neon
  3. Finally, set the errorFormat parameter:

    parameters:
    errorFormat: friendly

Optional: Simplify Your Workflow

If you want to make it simpler, setting scripts in composer.json as follows:

{
    "scripts": {
        "analyze": "phpstan analyze --error-format friendly"
    }
}

You can run a short command like this:

composer analyze

βš™οΈ Configuration Options

You can customize in your phpstan.neon:

parameters:
    friendly:
        # default is 3
        lineBefore: 3
        lineAfter: 3
        # default is null
        editorUrl: 'phpstorm://open?file=%%file%%&line=%%line%%'

πŸ–ΌοΈ Example

When you actually introduce it in GitHub Actions, it will be displayed as follows.

PHPStan Friendly Formatter output in GitHub Actions https://github.com/yamadashy/laravel-blade-minify-directive/actions/runs/4714024802/jobs/8360104870

πŸ“œ License

Distributed under the MIT license.