jdecool / phpstan-report
Enhance PHPStan analysis by providing report analysis
Installs: 23 212
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
pkg:composer/jdecool/phpstan-report
Requires
- php: ^8.1
- monolog/monolog: ^2.0 || ^3.0
- phpstan/phpstan: ^1.11 || ^2.0
- psr/log: ^2.0 || ^3.0
- symfony/config: ^5.4 || ^6.0 || ^7.1
- symfony/console: ^5.4 || ^6.0 || ^7.1
- symfony/dependency-injection: ^5.4 || ^6.0 || ^7.1
- symfony/filesystem: ^5.4 || ^6.0 || ^7.1
- symfony/finder: ^5.4 || ^6.0 || ^7.1
- symfony/polyfill-intl-icu: ^1.31
Requires (Dev)
- ergebnis/composer-normalize: ^2.43
- fakerphp/faker: ^1.24
- phpunit/phpunit: ^10.5
- symfony/var-dumper: ^5.4 || ^6.0 || ^7.1
README
A simple wrapper around PHPStan to extends PHPStan's functionality by providing a customizable report generation feature. It allows you to run PHPStan analysis and generate reports on ignored errors in various formats.
Installation
You can install the package via composer:
composer require --dev jdecool/phpstan-report
Usage
This package provides two main commands:
Analyze Command
The analyze command runs PHPStan analysis and generates reports on ignored errors:
php vendor/bin/phpstan-report analyze
Options
--report-output-format: Specify the output format for the report--report-without-analyze: Generate a report without running the PHPStan analysis--report-continue-on-error: Continue report generation even if the analysis fails--report-maximum-allowed-errors: Set the maximum number of allowed errors--report-sort-by: Sort the report results (options: identifier, occurrence)--report-exclude-identifier: Identifier to exclude from the report (accepts multiple values)--report-file-<format>: Export report in an output file for a particular format--report-http-target-url: The target URL to send the report to (available only if output format ishttp)--report-http-add-header: Add a header to the HTTP request (available only if output format ishttp)--report-gitlab-severity-mapping: JSON string mapping error identifiers to GitLab severity levels (available only if output format isgitlab)
Available formats are: text, html, http, json, gitlab and heatmap.
For a full list of options, run:
php vendor/bin/phpstan-report analyze --help
View Command
The view command displays detailed information about specific ignored errors from the PHPStan result cache:
php vendor/bin/phpstan-report view <identifier> [<identifier>...]
This command allows you to examine specific error identifiers without running a new analysis.
Options
The view command takes error identifiers as arguments and displays detailed information about those errors in a table format showing:
- Error identifier
- Error message
- File path
- Line number
For help with the view command, run:
php vendor/bin/phpstan-report view --help
Examples
Run analysis and generate a text report:
php vendor/bin/phpstan-report analyze src tests
Generate an HTML report without running analysis:
php vendor/bin/phpstan-report analyze --report-without-analyze --report-output-format=html
Run analysis, continue on error, and save report to a file:
php vendor/bin/phpstan-report analyze --report-continue-on-error --report-file-json=report.json src
Generate a heatmap report of files with most ignored errors:
php vendor/bin/phpstan-report analyze --report-file-heatmap=heatmap.svg src
Generate a GitLab report with custom severity mapping:
php vendor/bin/phpstan-report analyze --report-output-format=gitlab \
--report-gitlab-severity-mapping='{"missingType.property":"info","argument.type":"critical"}' src
For more details on GitLab severity mapping, see docs/gitlab-severity-mapping.md.
View Command Examples
View details about a specific error identifier:
php vendor/bin/phpstan-report view "missingType.iterableValue"
View details about multiple error identifiers:
php vendor/bin/phpstan-report view "missingType.iterableValue" "nullCoalesce.expr"