Exakat\Tasks\Load::processForeach PHP Method

processForeach() private method

private processForeach ( )
    private function processForeach()
    {
        $id = $this->addAtom('Foreach');
        $current = $this->id;
        ++$this->id;
        // Skip foreach
        while (!in_array($this->tokens[$this->id + 1][0], array(T_AS))) {
            $this->processNext();
        }
        $sourceId = $this->popExpression();
        $this->addLink($id, $sourceId, 'SOURCE');
        $as = $this->tokens[$this->id + 1][1];
        ++$this->id;
        // Skip as
        while (!in_array($this->tokens[$this->id + 1][0], array(T_CLOSE_PARENTHESIS, T_DOUBLE_ARROW))) {
            $this->processNext();
        }
        if ($this->tokens[$this->id + 1][0] === T_DOUBLE_ARROW) {
            $this->processNext();
        }
        $valueId = $this->popExpression();
        $this->addLink($id, $valueId, 'VALUE');
        ++$this->id;
        // Skip )
        $isColon = $this->tokens[$current][0] === T_FOREACH && $this->tokens[$this->id + 1][0] === T_COLON;
        $blockId = $this->processFollowingBlock($isColon === true ? array(T_ENDFOREACH) : array());
        $this->popExpression();
        $this->addLink($id, $blockId, 'BLOCK');
        if ($isColon === true) {
            ++$this->id;
            // skip endforeach
            $fullcode = $this->tokens[$current][1] . '(' . $this->atoms[$sourceId]['fullcode'] . ' ' . $as . ' ' . $this->atoms[$valueId]['fullcode'] . ') : ' . self::FULLCODE_SEQUENCE . ' endforeach';
        } else {
            $fullcode = $this->tokens[$current][1] . '(' . $this->atoms[$sourceId]['fullcode'] . ' ' . $as . ' ' . $this->atoms[$valueId]['fullcode'] . ')' . ($this->atoms[$blockId]['bracket'] === true ? self::FULLCODE_BLOCK : self::FULLCODE_SEQUENCE);
        }
        $this->setAtom($id, array('code' => $this->tokens[$current][1], 'fullcode' => $fullcode, 'line' => $this->tokens[$current][2], 'token' => $this->getToken($this->tokens[$current][0]), 'alternative' => $isColon));
        $this->pushExpression($id);
        $this->processSemicolon();
        if ($this->tokens[$this->id][0] === T_CLOSE_TAG) {
            --$this->id;
        }
        return $id;
    }
Load