Skip to main content

php_block_assigned_variable_names

Function php_block_assigned_variable_names 

Source
pub fn php_block_assigned_variable_names(php_source: &str) -> HashSet<String>
Expand description

Best-effort variable-name extraction for a @php block translate_php_block couldn’t translate - used only by a top-level @php failure (scan.rs’s "php" arm) to populate ConvertContext::tainted_vars, so later references to these names degrade instead of translating into a reference to a binding that no longer exists. Deliberately more lenient than translate_php_block: walks the entire tree, not just top-level statement_expressions, since a block this phase can’t translate is exactly the kind that has assignments nested inside an if/loop the real, motivating case for this whole mechanism (guest.blade.php’s @php block reassigns $brandName inside a nested if ($isEnterpriseEdition) { if (...) { ... } }). Tolerant of a tree with parse errors (never propagates one) - over-collecting a name is always safe here (a spot that degrades that didn’t strictly need to), under-collecting is not.