Skip to content

๐Ÿค A friendly error formatter extension for PHPStan that provides more readable and informative output, including code snippets and color highlighting.

License

Notifications You must be signed in to change notification settings

yamadashy/phpstan-friendly-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

34 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค PHPStan Friendly Formatter

Downloads Test Status Latest Version License

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

๐ŸŒŸ Features

  • Display Code Frame: See the problematic code right where the error occurs
  • Error Identifier Summary: Get a quick overview of error types and their frequencies
  • Beautiful Output: Enjoy a visually appealing and easy-to-read error report

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:

  • Instantly pinpoint what's wrong in your code
  • Reduce mental overhead when interpreting error messages
  • Accelerate your debugging process

๐Ÿš€ Getting Started

  1. You may use Composer to install this package as a development dependency.
composer require --dev yamadashy/phpstan-friendly-formatter
  1. Register error formatter into your phpstan.neon or phpstan.neon.dist:
includes:
    - ./vendor/yamadashy/phpstan-friendly-formatter/extension.neon
  1. 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%%'
  • lineBefore ... Number of lines to display before error line
  • lineAfter ... Number of lines to display after error line
  • editorUrl ... URL with placeholders like [table formatter config](URL for editor like table formatter)

๐Ÿ–ผ๏ธ 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.

About

๐Ÿค A friendly error formatter extension for PHPStan that provides more readable and informative output, including code snippets and color highlighting.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published