/** * Parse this node. * Sets the variable in the current context. * * @param Context $context the context in which this node is parsed * @return array the parsed node - an empty array */ public function parse($context) { if (!$this->isDefault || !$context->hasVariable($this->name)) { $context->setVariable($this->name, $this->evaluate($this->value, $context)); } $this->parseChildren($context); // Parse any warnings return []; }
/** * Parse this node. * * @param Context $context the context in which this node is parsed * @return array parsed child nodes */ public function parse($context) { $children = []; $from = (double) $this->evaluate($this->from, $context)->value; $to = (double) $this->evaluate($this->to, $context)->value; $step = (double) $this->evaluate($this->step, $context)->value * ($to > $from ? 1 : -1); if ($this->inclusive) { $to += $from < $to ? 1 : -1; } $context = new Context($context); for ($i = $from; $from < $to ? $i < $to : $i > $to; $i += $step) { $context->setVariable($this->variable, new \PHPSass\Script\Literals\Number($i)); $children = array_merge($children, $this->parseChildren($context)); } return $children; }