/** * Compile variable * * @param $item * @param $name * @param $attributes * @param $expected * @param bool $useEcho * @return string */ public function compileVariable($default = 'null', $expected = Lexicon::EXPECTED_STRING) { if (!in_array($default, ['true', 'false', 'null'])) { $default = "'{$default}'"; } $resolver = new ValueResolver($default); $default = $resolver->resolve(); $finder = $this->getNodeFinder(); $item = $finder->getItemSource(); $name = $finder->getName(); $attributes = $this->compileAttributes(); return "\$this->variable({$item},'{$name}',{$attributes},'',{$default},'{$expected}')"; }
/** * Compile * * @return string */ public function compile() { $this->setName($this->getContent()); $finder = $this->getNodeFinder(); $name = $finder->getName(); $item = $finder->getItemSource(); $source = null; if (!empty($name)) { $resolver = new ValueResolver($name); $source = $resolver->resolve("\$this->variable({$item}, '{$name}')"); } return $source; }