private function executeCompiler(BBCodeToken $parent) { $text = ''; $childs = $parent->getChilds(); foreach ($childs as $child) { if ($parent->getTagName() != 'viscacha_root_node' && $parent->isValidChild($child) == false) { if ($child instanceof BBCodeToken) { // Invalid child, add as text only $text .= $child->totext(); } // Else: Invalid child, remove it (applies also on strings) } else { if (is_string($child)) { // Valid child, add the text $text .= $child; } elseif ($child instanceof BBCodeToken) { // Valid child, add the compiled token $text .= $child->getTagObject()->compile($child); } } } return $text; }