arrayItemNodes = $arrayItemNodes; Assert::allIsInstanceOf($this->arrayItemNodes, ArrayItemNode::class); parent::__construct($this->arrayItemNodes); } public function __toString() : string { // possibly list items return $this->implode($this->values); } /** * @param mixed[] $array */ private function implode(array $array) : string { $itemContents = ''; \end($array); $lastItemKey = \key($array); foreach ($array as $key => $value) { if (\is_int($key)) { $itemContents .= (string) $value; } else { $itemContents .= $key . '=' . $value; } if ($lastItemKey !== $key) { $itemContents .= ', '; } } return '{' . $itemContents . '}'; } }