Helper: parse PHP code and collect scope from the first method body found inside the first class.
(php: &str)
| 25 | /// Helper: parse PHP code and collect scope from the first method body |
| 26 | /// found inside the first class. |
| 27 | fn 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. |
| 52 | fn accesses_for(scope_map: &ScopeMap, name: &str) -> Vec<(u32, AccessKind)> { |
no test coverage detected