PHPCfg\Visitor\Simplifier::replaceOpVariable PHP Method

replaceOpVariable() private method

private replaceOpVariable ( Operand $from, Operand $to, Op $op )
$from PHPCfg\Operand
$to PHPCfg\Operand
$op PHPCfg\Op
    private function replaceOpVariable(Operand $from, Operand $to, Op $op)
    {
        foreach ($op->getVariableNames() as $name) {
            if (is_null($op->{$name})) {
                continue;
            }
            if (is_array($op->{$name})) {
                // SIGH, PHP won't let me do this directly (parses as $op->($name[$key]))
                $result = $op->{$name};
                $new = [];
                foreach ($result as $key => $value) {
                    if ($value === $from) {
                        $new[$key] = $to;
                        if ($op->isWriteVariable($name)) {
                            $to->addWriteOp($op);
                        } else {
                            $to->addUsage($op);
                        }
                    } else {
                        $new[$key] = $value;
                    }
                }
                $op->{$name} = $new;
            } elseif ($op->{$name} === $from) {
                $op->{$name} = $to;
                if ($op->isWriteVariable($name)) {
                    $to->addWriteOp($op);
                } else {
                    $to->addUsage($op);
                }
            }
        }
    }