Skip to content

Commit

Permalink
patch part 3/3 for PHP_PHPSTAN and SARIF support (see feature request #…
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed May 10, 2024
1 parent 94c18e7 commit 5ebd066
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions TEMPLATES/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
parameters:
level: 0

services:
errorFormatter.sarif:
class: Bartlett\Sarif\Converter\PhpStanConverter
7 changes: 4 additions & 3 deletions megalinter/descriptors/php.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ linters:
# PHP Stan
- linter_name: phpstan
name: PHP_PHPSTAN
can_output_sarif: true
linter_url: https://phpstan.org/
linter_repo: https://github.com/phpstan/phpstan
linter_image_url: https://i.imgur.com/WaRKPlC.png
Expand All @@ -98,6 +99,8 @@ linters:
- "--no-ansi"
- "--memory-limit"
- "1G"
cli_sarif_args:
- "--error-format=sarif"
cli_lint_errors_count: regex_number
cli_lint_errors_regex: "Found ([0-9]+) error"
examples:
Expand All @@ -107,9 +110,7 @@ linters:
- "phpstan analyse --no-progress --no-ansi mydir1/ mydir2/ myfile.php"
install:
dockerfile:
- FROM ghcr.io/phpstan/phpstan:latest-php8.3 as phpstan
- COPY --link --from=phpstan /composer/vendor/phpstan/phpstan/phpstan.phar /usr/bin/phpstan
- RUN chmod +x /usr/bin/phpstan
- RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && composer global require phpstan/phpstan bartlett/sarif-php-sdk
idea:
- name: PHPStan / Psalm / Generics
url: https://plugins.jetbrains.com/plugin/12754-phpstan--psalm--generics
Expand Down

0 comments on commit 5ebd066

Please sign in to comment.