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

Function scope_has_changes

src/completion/variable/forward_walk.rs:6084–6106  ·  view source on GitHub ↗

Check whether the post-walk scope has any NEW or CHANGED variable types compared to the pre-loop scope. This is the Mago-style fixed-point check that runs BEFORE a re-walk: if nothing changed, there's no point walking the body again. Unlike `scopes_equal`, this is asymmetric: new variables in `after` that weren't in `before` count as changes, but variables in `before` that aren't in `after` do n

(before: &ScopeState, after: &ScopeState)

Source from the content-addressed store, hash-verified

6082/// in `before` that aren't in `after` do not (they were just not
6083/// assigned in the loop body).
6084fn scope_has_changes(before: &ScopeState, after: &ScopeState) -> bool {
6085 for (name, after_types) in &after.locals {
6086 match before.locals.get(name) {
6087 None => {
6088 // New variable assigned in the loop body.
6089 if !after_types.is_empty() {
6090 return true;
6091 }
6092 }
6093 Some(before_types) => {
6094 if after_types.len() != before_types.len() {
6095 return true;
6096 }
6097 for (at, bt) in after_types.iter().zip(before_types.iter()) {
6098 if at.type_string != bt.type_string {
6099 return true;
6100 }
6101 }
6102 }
6103 }
6104 }
6105 false
6106}
6107
6108/// Process a `foreach` statement.
6109fn process_foreach<'b>(foreach: &'b Foreach<'b>, scope: &mut ScopeState, ctx: &ForwardWalkCtx<'_>) {

Callers 4

process_foreachFunction · 0.85
process_whileFunction · 0.85
process_forFunction · 0.85
process_do_whileFunction · 0.85

Calls 3

iterMethod · 0.80
getMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected