PHPCfg\Printer::renderOp PHP Method

renderOp() protected method

protected renderOp ( Op $op )
$op Op
    protected function renderOp(Op $op)
    {
        $result = $op->getType();
        if ($op instanceof Op\CallableOp) {
            $func = $op->getFunc();
            $result .= "<" . $func->name . ">";
        }
        if ($op instanceof Op\Expr\Assertion) {
            $result .= "<" . $this->renderAssertion($op->assertion) . ">";
        }
        foreach ($op->getVariableNames() as $varName) {
            $vars = $op->{$varName};
            if (is_array($vars)) {
                foreach ($vars as $key => $var) {
                    if (!$var) {
                        continue;
                    }
                    $result .= "\n    {$varName}[{$key}]: ";
                    $result .= $this->indent($this->renderOperand($var));
                }
            } elseif ($vars) {
                $result .= "\n    {$varName}: ";
                $result .= $this->indent($this->renderOperand($vars));
            }
        }
        $childBlocks = [];
        foreach ($op->getSubBlocks() as $blockName) {
            $sub = $op->{$blockName};
            if (is_array($sub)) {
                foreach ($sub as $key => $subBlock) {
                    if (!$subBlock) {
                        continue;
                    }
                    $this->enqueueBlock($subBlock);
                    $childBlocks[] = ["block" => $subBlock, "name" => $blockName . "[" . $key . "]"];
                }
            } elseif ($sub) {
                $this->enqueueBlock($sub);
                $childBlocks[] = ["block" => $sub, "name" => $blockName];
            }
        }
        return ["op" => $op, "label" => $result, "childBlocks" => $childBlocks];
    }