Skip to content

Commit

Permalink
Fix parsing of for statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Oct 25, 2024
1 parent dcc31ad commit 12d67a0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions files/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3661,25 +3661,29 @@ function phvolt_ret_elsefor_statement(&$ret, State $state): void
];
}

function phvolt_ret_for_statement(&$ret, $variable, $key = null, array $expr = [], $if_expr = null, $block_statements = null, ?State $state = null): void
function phvolt_ret_for_statement(
&$ret,
Token $variable,
?Token $key = null,
array $expr = [],
$if_expr = null,
$block_statements = null,
?State $state = null,
): void
{
$ret = [
"type" => Compiler::PHVOLT_T_FOR,
"variable" => $variable->token,
"variable" => $variable->getValue(),
"expr" => $expr,
"block_statements" => $block_statements,
"file" => $state->getActiveFile(),
"line" => $state->getActiveLine(),
];

// Free the variable token memory
unset($variable->token);
unset($variable);

if ($key) {
$ret["key"] = $key->token;
// Free the key token memory
unset($key->token);
$ret["key"] = $key->getValue();
unset($key);
}

Expand Down

0 comments on commit 12d67a0

Please sign in to comment.