()
| 675 | |
| 676 | #[test] |
| 677 | fn classify_range_parameters() { |
| 678 | // $x is written before the range and read inside → parameter. |
| 679 | let php = r#"<?php |
| 680 | function test() { |
| 681 | $x = new Foo(); |
| 682 | echo $x; |
| 683 | } |
| 684 | "#; |
| 685 | let scope_map = collect_from_function(php); |
| 686 | |
| 687 | // Find the offsets of the write and read. |
| 688 | let x_accesses = accesses_for(&scope_map, "$x"); |
| 689 | assert_eq!(x_accesses.len(), 2); |
| 690 | let write_offset = x_accesses[0].0; |
| 691 | let read_offset = x_accesses[1].0; |
| 692 | let frame_end = scope_map.frames[0].end; |
| 693 | |
| 694 | // Range that only includes the read (not the write). |
| 695 | // Use frame_end so the range stays within the function body. |
| 696 | let classification = scope_map.classify_range(read_offset, frame_end); |
| 697 | assert!( |
| 698 | classification.parameters.contains(&"$x".to_string()), |
| 699 | "Expected $x in parameters, got: {:?}", |
| 700 | classification.parameters |
| 701 | ); |
| 702 | assert!(classification.return_values.is_empty()); |
| 703 | assert!(classification.locals.is_empty()); |
| 704 | |
| 705 | // Range that includes only the write. |
| 706 | let classification2 = scope_map.classify_range(write_offset, read_offset); |
| 707 | // Written inside, read after → return value. |
| 708 | assert!( |
| 709 | classification2.return_values.contains(&"$x".to_string()), |
| 710 | "Expected $x in return_values, got: {:?}", |
| 711 | classification2 |
| 712 | ); |
| 713 | } |
| 714 | |
| 715 | #[test] |
| 716 | fn classify_range_locals() { |
nothing calls this directly
no test coverage detected