diff --git a/src/Phan/PhanConvertToSubset.php b/src/Phan/PhanConvertToSubset.php index 990a8f1..513a821 100644 --- a/src/Phan/PhanConvertToSubset.php +++ b/src/Phan/PhanConvertToSubset.php @@ -9,6 +9,12 @@ final class PhanConvertToSubset extends AbstractConverter { + private const SEVERITY_LEVELS = [ + 0 => 'info', + 5 => 'minor', + 10 => 'critical', + ]; + public function convertToSubset(): void { try { @@ -22,6 +28,7 @@ public function convertToSubset(): void $node->location->path, $node->location->lines->begin ), + 'severity' => self::SEVERITY_LEVELS[$node->severity] ?? null, 'location' => [ 'path' => $node->location->path, 'lines' => [ diff --git a/tests/Phan/PhanConverterTest.php b/tests/Phan/PhanConverterTest.php index 99bcfd1..b47e707 100644 --- a/tests/Phan/PhanConverterTest.php +++ b/tests/Phan/PhanConverterTest.php @@ -40,6 +40,7 @@ public function testItCanConvertPhanJsonToSubset(): void [ 'description' => '(Phan) UndefError PhanUndeclaredClassConstant Reference to constant class from undeclared class \PhpParser\Node\Stmt\ClassMethod', 'fingerprint' => 'e8547906ee21b4f8e8804de980a9d239', + 'severity' => 'critical', 'location' => [ 'path' => 'app/Class.php', 'lines' => [ diff --git a/tests/Phan/fixtures/output.json b/tests/Phan/fixtures/output.json index e0fa56a..d77e34d 100644 --- a/tests/Phan/fixtures/output.json +++ b/tests/Phan/fixtures/output.json @@ -2,6 +2,7 @@ { "description": "(Phan) UndefError PhanUndeclaredClassConstant Reference to constant class from undeclared class \\PhpParser\\Node\\Stmt\\ClassMethod", "fingerprint": "e8547906ee21b4f8e8804de980a9d239", + "severity": "critical", "location": { "path": "app/Class.php", "lines": { diff --git a/tests/TestCase.php b/tests/TestCase.php index bbc923d..2ffac58 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -34,6 +34,7 @@ public function multipleConvertersProvider(): array 'output' => [ 'description' => '(Phan) UndefError PhanUndeclaredClassConstant Reference to constant class from undeclared class \PhpParser\Node\Stmt\ClassMethod', 'fingerprint' => 'e8547906ee21b4f8e8804de980a9d239', + 'severity' => 'critical', 'location' => [ 'path' => 'app/Class.php', 'lines' => [ diff --git a/tests/fixtures/output.json b/tests/fixtures/output.json index cd85bec..12a7992 100644 --- a/tests/fixtures/output.json +++ b/tests/fixtures/output.json @@ -2,6 +2,7 @@ { "description": "(Phan) UndefError PhanUndeclaredClassConstant Reference to constant class from undeclared class \\PhpParser\\Node\\Stmt\\ClassMethod", "fingerprint": "e8547906ee21b4f8e8804de980a9d239", + "severity": "critical", "location": { "path": "app/Class.php", "lines": {