MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / parse_analyze_issues

Function parse_analyze_issues

src/mago.rs:745–789  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

743
744 #[test]
745 fn parse_analyze_issues() {
746 let content = "<?php\nfunction foo(): string { return 42; }\n";
747 let file_path = "/tmp/phpantom-mago-xyz.php";
748
749 let json = r#"{
750 "issues": [
751 {
752 "level": "Warning",
753 "code": "type-mismatch",
754 "message": "Type mismatch in return.",
755 "notes": ["expected string, got int"],
756 "help": "Change the return type or the value.",
757 "annotations": [
758 {
759 "message": "returns int here",
760 "kind": "Primary",
761 "span": {
762 "file_id": {
763 "name": "test.php",
764 "path": "/tmp/phpantom-mago-xyz.php",
765 "size": 50,
766 "file_type": "Host"
767 },
768 "start": { "offset": 35, "line": 1 },
769 "end": { "offset": 37, "line": 1 }
770 }
771 }
772 ]
773 }
774 ]
775 }"#;
776
777 let diags = parse_mago_json(json, content, file_path, "mago-analyze").unwrap();
778 assert_eq!(diags.len(), 1);
779 assert_eq!(diags[0].severity, Some(DiagnosticSeverity::WARNING));
780 assert_eq!(diags[0].source.as_deref(), Some("mago-analyze"));
781 assert!(diags[0].message.contains("Type mismatch in return."));
782 assert!(diags[0].message.contains("returns int here"));
783 assert!(diags[0].message.contains("Note: expected string, got int"));
784 assert!(
785 diags[0]
786 .message
787 .contains("Help: Change the return type or the value.")
788 );
789 }
790
791 // ── parse_mago_json — empty result ──────────────────────────────
792

Callers

nothing calls this directly

Calls 2

parse_mago_jsonFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected