<commit_before><?php

namespace Flow\Node;

use Flow\Node;

class ForNode extends Node
{
    protected $seq;
    protected $key;
    protected $value;
    protected $body;
    protected $else;

    public function __construct($seq, $key, $value, $body, $else, $line)
    {
        parent::__construct($line);
        $this->seq = $seq;
        $this->key = $key;
        $this->value = $value;
        $this->body = $body;
        $this->else = $else;
    }

    public function compile($compiler, $indent = 0)
    {
        $compiler->addTraceInfo($this, $indent);

        $compiler->pushContext('loop', $indent);
        if ($this->key) {
            $compiler->pushContext($this->key, $indent);
        }
        $compiler->pushContext($this->value, $indent);

        $else = false;
        if (!is_null($this->else)) {
            $compiler->raw('if (!Flow\Helper\is_empty(', $indent);
            $this->seq->compile($compiler);
            $compiler->raw(")) {\n");
            $else = true;
        }

        $compiler->raw(
            'foreach (($context[\'loop\'] = $this->iterate($context, ',
            $else ? ($indent + 1) : $indent
        );<commit_msg>Fix broken for-else construct<commit_after><?php

namespace Flow\Node;

use Flow\Node;

class ForNode extends Node
{
    protected $seq;
    protected $key;
    protected $value;
    protected $body;
    protected $else;

    public function __construct($seq, $key, $value, $body, $else, $line)
    {
        parent::__construct($line);
        $this->seq = $seq;
        $this->key = $key;
        $this->value = $value;
        $this->body = $body;
        $this->else = $else;
    }

    public function compile($compiler, $indent = 0)
    {
        $compiler->addTraceInfo($this, $indent);

        $compiler->pushContext('loop', $indent);
        if ($this->key) {
            $compiler->pushContext($this->key, $indent);
        }
        $compiler->pushContext($this->value, $indent);

        $else = false;
        if (!is_null($this->else)) {
            $compiler->raw('if (!Flow\Helper::is_empty(', $indent);
            $this->seq->compile($compiler);
            $compiler->raw(")) {\n");
            $else = true;
        }

        $compiler->raw(
            'foreach (($context[\'loop\'] = $this->iterate($context, ',
            $else ? ($indent + 1) : $indent
        );
{'fraction_non_alphanumeric': 0.17943292424883622, 'fraction_numerical': 0.0016927634363097758, 'mean_word_length': 2.094240837696335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7359382', 'n_tokens_mistral': 728, 'n_tokens_neox': 713, 'n_words': 149}