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

Function foreach_value_is_write

src/scope_collector/tests.rs:189–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

187
188#[test]
189fn foreach_value_is_write() {
190 let php = r#"<?php
191function test($items) {
192 foreach ($items as $key => $value) {
193 echo $key;
194 echo $value;
195 }
196}
197"#;
198 let scope_map = collect_from_function(php);
199
200 // foreach key and value bindings are writes.
201 assert_eq!(count_kind(&scope_map, "$key", AccessKind::Write), 1);
202 assert_eq!(count_kind(&scope_map, "$value", AccessKind::Write), 1);
203 // They are read inside the loop.
204 assert_eq!(count_kind(&scope_map, "$key", AccessKind::Read), 1);
205 assert_eq!(count_kind(&scope_map, "$value", AccessKind::Read), 1);
206 // $items: 1 write (param) + 1 read (foreach expression).
207 assert_eq!(count_kind(&scope_map, "$items", AccessKind::Read), 1);
208}
209
210#[test]
211fn for_loop_variables() {

Callers

nothing calls this directly

Calls 1

collect_from_functionFunction · 0.85

Tested by

no test coverage detected