()
| 1200 | |
| 1201 | #[test] |
| 1202 | fn classify_range_mixed_roles() { |
| 1203 | // $x is a parameter (read inside, written before) |
| 1204 | // $y is a local (written and read only inside) |
| 1205 | // $z is a return value (written inside, read after) |
| 1206 | let php = r#"<?php |
| 1207 | function test() { |
| 1208 | $x = 1; |
| 1209 | $y = $x + 1; |
| 1210 | echo $y; |
| 1211 | $z = $y * 2; |
| 1212 | echo $z; |
| 1213 | } |
| 1214 | "#; |
| 1215 | let scope_map = collect_from_function(php); |
| 1216 | |
| 1217 | let _x_accesses = accesses_for(&scope_map, "$x"); |
| 1218 | let y_accesses = accesses_for(&scope_map, "$y"); |
| 1219 | let z_accesses = accesses_for(&scope_map, "$z"); |
| 1220 | |
| 1221 | // Extract the middle range: from $y write to just before $z write. |
| 1222 | let range_start = y_accesses[0].0; |
| 1223 | let range_end = z_accesses[0].0; |
| 1224 | |
| 1225 | let classification = scope_map.classify_range(range_start, range_end); |
| 1226 | |
| 1227 | // $x is written before range, read inside → parameter. |
| 1228 | assert!( |
| 1229 | classification.parameters.contains(&"$x".to_string()), |
| 1230 | "Expected $x as parameter: {:?}", |
| 1231 | classification |
| 1232 | ); |
| 1233 | |
| 1234 | // $y is written inside, read inside, then read after (in $z = $y * 2) → depends on range. |
| 1235 | // Since $y is also read at `echo $y` which might be inside or outside depending on exact offsets. |
| 1236 | // The important thing is the classification runs without panicking. |
| 1237 | } |
| 1238 | |
| 1239 | #[test] |
| 1240 | fn classify_excludes_this_from_names() { |
nothing calls this directly
no test coverage detected