PHP code example of staabm / phpstan-baseline-analysis
1. Go to this page and download the library: Download staabm/phpstan-baseline-analysis library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
staabm / phpstan-baseline-analysis example snippets
$ git clone ...
$ phpstan-baseline-analyze '*phpstan-baseline.neon' --json > now.json
$ git checkout `git rev-list -n 1 --before="1 week ago" HEAD`
$ phpstan-baseline-analyze '*phpstan-baseline.neon' --json > reference.json
$ phpstan-baseline-trend reference.json now.json
Analyzing Trend for app/portal/phpstan-baseline.neon
Overall-Errors: 30 -> 17 => improved
Classes-Cognitive-Complexity: 309 -> 177 => improved
Deprecations: 1 -> 2 => worse
Invalid-Phpdocs: 3 -> 1 => good
Unknown-Types: 5 -> 15 => worse
Anonymous-Variables: 4 -> 3 => good
Unused-Symbols: 1 -> 1 => good
Native-Return-Type-Coverage: 20 -> 2 => worse
Native-Property-Type-Coverage: 3 -> 3 => good
Native-Param-Type-Coverage: 4 -> 40 => improved
name: Trends Analyse
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * 4'
jobs:
behat:
name: Trends
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- run: "composer global pstan-baseline-analyze '*phpstan-baseline.neon' --json > ../now.json"
- run: git checkout `git rev-list -n 1 --before="1 week ago" HEAD`
- run: "phpstan-baseline-analyze '*phpstan-baseline.neon' --json > ../reference.json"
- name: analyze trend
shell: php {0}
run: |
exec('phpstan-baseline-trend ../reference.json ../now.json > ../trend.txt', $output, $exitCode);
$project = '${{ github.repository }}';
if ($exitCode == 0) {
# improvements
file_put_contents(
'mattermost.json',
json_encode(["username" => "github-action-trend-bot", "text" => $project ." :tada:\n". file_get_contents("../trend.txt")])
);
}
elseif ($exitCode == 1) {
# steady
file_put_contents(
'mattermost.json',
json_encode(["username" => "github-action-trend-bot", "text" => $project ." :green_heart:\n". file_get_contents("../trend.txt")])
);
}
elseif ($exitCode == 2) {
# got worse
file_put_contents(
'mattermost.json',
json_encode(["username" => "github-action-trend-bot", "text" => $project ." :broken_heart:\n". file_get_contents("../trend.txt")])
);
}
- run: 'curl -X POST -H "Content-Type: application/json" -d @mattermost.json ${{ secrets.MATTERMOST_WEBHOOK_URL }}'
if: always()