1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00
psalm/bin/generate_levels_doc.php

63 lines
1.4 KiB
PHP
Raw Normal View History

2020-02-17 22:33:28 +01:00
<?php
2021-12-03 20:11:20 +01:00
use Psalm\Config\IssueHandler;
use Psalm\Issue\CodeIssue;
2020-02-17 22:33:28 +01:00
require_once(dirname(__DIR__) . '/vendor/autoload.php');
2021-12-03 20:11:20 +01:00
$issue_types = IssueHandler::getAllIssueTypes();
2020-02-17 22:33:28 +01:00
$grouped_issues = [];
foreach ($issue_types as $issue_type) {
$issue_class = 'Psalm\\Issue\\' . $issue_type;
2021-12-03 20:11:20 +01:00
if (!class_exists($issue_class) || !is_a($issue_class, CodeIssue::class, true)) {
2020-02-17 22:33:28 +01:00
throw new Exception($issue_class . ' is not a Codeissue');
}
/** @var int */
$issue_level = $issue_class::ERROR_LEVEL;
$grouped_issues[$issue_level][] = $issue_type;
}
?>
## Always treated as errors
<?php
foreach ($grouped_issues[-1] as $issue_type) {
2020-03-19 17:34:48 +01:00
echo ' - [' . $issue_type . '](issues/' . $issue_type . '.md)' . "\n";
2020-02-17 22:33:28 +01:00
}
?>
## Errors that only appear at level 1
<?php
foreach ($grouped_issues[1] as $issue_type) {
2020-03-19 17:34:48 +01:00
echo ' - [' . $issue_type . '](issues/' . $issue_type . '.md)' . "\n";
2020-02-17 22:33:28 +01:00
}
?>
<?php
foreach ([2, 3, 4, 5, 6, 7] as $level) {
echo '## Errors ignored at level ' . ($level + 1) . ($level < 7 ? ' and higher' : '') . "\n\n";
echo 'These issues are treated as errors at level ' . $level . ' and below.' . "\n\n";
foreach ($grouped_issues[$level] as $issue_type) {
2020-03-19 17:34:48 +01:00
echo ' - [' . $issue_type . '](issues/' . $issue_type . '.md)' . "\n";
2020-02-17 22:33:28 +01:00
}
echo "\n";
}
?>
## Feature-specific errors
<?php
foreach ($grouped_issues[-2] as $issue_type) {
2020-03-19 17:34:48 +01:00
echo ' - [' . $issue_type . '](issues/' . $issue_type . '.md)' . "\n";
2020-02-17 22:33:28 +01:00
}
?>