<?php
 abstract class vB_Utility_Template_ParserNode_Curly extends vB_Utility_Template_ParserNode { protected function attributeToString(string|int|float|bool|null|vB_CurlyNode $attribute) : string { if ($attribute instanceof vB_CurlyNode) { return $this->createNode($attribute)->compile(); } else { return var_export($attribute, true); } } protected function getArgumentsFromAttributes(int $start = 0) : string { return implode(', ', $this->getRenderedAttributes($start)); } protected function getRenderedAttributes(int $start = 0) : array { $attributes = $this->main_node->attributes; if ($start > 0) { $attributes = array_slice($attributes, $start); } return array_map([$this, 'attributeToString'], $attributes); } protected function getRenderedNamedAttributes(int $start = 0) : array { $separator = '='; $arguments = []; for ($i = $start; $i < count($this->main_node->attributes); $i++) { $argument = $this->main_node->attributes[$i]; if ($argument instanceof vB_CurlyNode OR strpos($argument, $separator) === false) { $arguments[] = $this->attributeToString($argument); } else { if ($argument[strlen($argument)-1] === $separator) { $key = substr($argument, 0, -1); $attribute = $this->main_node->attributes[$i + 1] ?? null; if ($attribute instanceof vB_CurlyNode) { $i++; $value = $this->attributeToString($attribute); } else { $value = "''"; } } else { [$key, $value] = explode($separator, $argument); $value = var_export($value, true); } $arguments[] = var_export($key, true) . ' => ' . $value; } } return $arguments; } protected function nodename() : string { return '{vb:' . $this->main_node->value . '}'; } } 