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

Function collect_from_method

src/scope_collector/tests.rs:27–49  ·  view source on GitHub ↗

Helper: parse PHP code and collect scope from the first method body found inside the first class.

(php: &str)

Source from the content-addressed store, hash-verified

25/// Helper: parse PHP code and collect scope from the first method body
26/// found inside the first class.
27fn collect_from_method(php: &str) -> ScopeMap {
28 with_parsed_program(php, "test", |program, _content| {
29 for stmt in program.statements.iter() {
30 if let Statement::Class(class) = stmt {
31 for member in class.members.iter() {
32 if let ClassLikeMember::Method(method) = member
33 && let MethodBody::Concrete(block) = &method.body
34 {
35 let body_start = block.left_brace.start.offset;
36 let body_end = block.right_brace.end.offset;
37 return collect_function_scope(
38 &method.parameter_list,
39 block.statements.as_slice(),
40 body_start,
41 body_end,
42 );
43 }
44 }
45 }
46 }
47 panic!("No class method found in test PHP code");
48 })
49}
50
51/// Helper: find access by name and return all offsets + kinds.
52fn accesses_for(scope_map: &ScopeMap, name: &str) -> Vec<(u32, AccessKind)> {

Calls 3

with_parsed_programFunction · 0.85
collect_function_scopeFunction · 0.85
iterMethod · 0.80

Tested by

no test coverage detected