Deduplicate loop analysis
Also fixed some risky truthy falsy comparisons.
@weirdan Does anything prevent merging this?
@theodorejb I've been meaning to play with it locally, but haven't found the time yet. One thing that caught my eye is the type change for $protected_var_ids - perhaps there's a reason for that, but it's not immediately apparent.
@weirdan array<string, bool|int> seems to be the correct type for $protected_var_ids, since it's assigned to from a property with the same name in LoopScope, which has that type. The LoopScope property has that type because in one place it's assigned to from an array merge with $assigned_var_ids, which has a type of array<string, int>.