protected function walkIf(IfNode $if) { $this->walkEachDisallow($if->getBody(), "if"); foreach ((array) $if->getElseifs() as $elseif) { /** @var IfNode $elseif */ $this->walkEachDisallow($elseif->getBody(), "elseif"); } $this->walkEachDisallow($if->getElseBody(), "else"); }
protected function walkIf(IfNode $if) { $ret = ""; $ret .= "if(" . $this->walk($if->getCondition()) . "){"; $ret .= implode("", $this->walkEach($if->getBody())); $ret .= "}"; foreach ((array) $if->getElseifs() as $elseif) { /** @var IfNode $elseif */ $ret .= "elseif(" . $this->walk($elseif->getCondition()) . "){"; $ret .= implode("", $this->walkEach($elseif->getBody())); $ret .= "}"; } if ($if->hasElseBody()) { $ret .= "else{" . implode("", $this->walkEach($if->getElseBody())) . "}"; } return $ret; }
protected function walkIf(IfNode $if) { return new IfNode($this->walk($if->getCondition()), $this->walkEach($if->getBody()), $this->walkEach($if->getElseifs()), $if->hasElseBody() ? $this->walkEach($if->getElseBody()) : null); }
protected function walkIf(IfNode $if) { $variableNames = array(); foreach ($if->getBody() as $statement) { foreach ($this->walk($statement) as $name => $_) { $variableNames[$name] = true; } } foreach ($if->getElseifs() as $elseif) { foreach ($elseif->getBody() as $statement) { foreach ($this->walk($statement) as $name => $_) { $variableNames[$name] = true; } } } foreach ($if->getElseBody() as $statement) { foreach ($this->walk($statement) as $name => $_) { $variableNames[$name] = true; } } return $variableNames; }