getChildren() as $child) { $child->accept($this); } } function visitTextNode(\JBBCode\TextNode $textNode) { /* Convert :) into an image tag. */ $textNode->setValue(str_replace(':)', ':)', $textNode->getValue())); } function visitElementNode(\JBBCode\ElementNode $elementNode) { /* We only want to visit text nodes within elements if the element's * code definition allows for its content to be parsed. */ if ($elementNode->getCodeDefinition()->parseContent()) { foreach ($elementNode->getChildren() as $child) { $child->accept($this); } } } }