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

Function test_parse_functions_standalone

tests/integration/parser.rs:988–1011  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

986
987#[tokio::test]
988async fn test_parse_functions_standalone() {
989 let backend = create_test_backend();
990 let php = concat!(
991 "<?php\n",
992 "function hello(): void {}\n",
993 "function add(int $a, int $b): int { return $a + $b; }\n",
994 );
995
996 let functions = backend.parse_functions(php);
997 assert_eq!(functions.len(), 2, "Should extract 2 standalone functions");
998
999 let hello = functions.iter().find(|f| f.name == "hello").unwrap();
1000 assert!(hello.parameters.is_empty());
1001 assert_eq!(hello.return_type_str().as_deref(), Some("void"));
1002 assert!(hello.namespace.is_none());
1003
1004 let add = functions.iter().find(|f| f.name == "add").unwrap();
1005 assert_eq!(add.parameters.len(), 2);
1006 assert_eq!(add.parameters[0].name, "$a");
1007 assert_eq!(add.parameters[0].type_hint_str().as_deref(), Some("int"));
1008 assert_eq!(add.parameters[1].name, "$b");
1009 assert_eq!(add.return_type_str().as_deref(), Some("int"));
1010 assert!(add.namespace.is_none());
1011}
1012
1013#[tokio::test]
1014async fn test_parse_functions_inside_namespace() {

Callers

nothing calls this directly

Calls 5

create_test_backendFunction · 0.85
parse_functionsMethod · 0.80
iterMethod · 0.80
unwrapMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected