Helper: parse PHP code and collect scope from the first function body found.
(php: &str)
| 5 | |
| 6 | /// Helper: parse PHP code and collect scope from the first function body found. |
| 7 | fn collect_from_function(php: &str) -> ScopeMap { |
| 8 | with_parsed_program(php, "test", |program, _content| { |
| 9 | for stmt in program.statements.iter() { |
| 10 | if let Statement::Function(func) = stmt { |
| 11 | let body_start = func.body.left_brace.start.offset; |
| 12 | let body_end = func.body.right_brace.end.offset; |
| 13 | return collect_function_scope( |
| 14 | &func.parameter_list, |
| 15 | func.body.statements.as_slice(), |
| 16 | body_start, |
| 17 | body_end, |
| 18 | ); |
| 19 | } |
| 20 | } |
| 21 | panic!("No function found in test PHP code"); |
| 22 | }) |
| 23 | } |
| 24 | |
| 25 | /// Helper: parse PHP code and collect scope from the first method body |
| 26 | /// found inside the first class. |
no test coverage detected