protected function addSpecialAttr(\DOMElement $node, $varName, array $code) { $node->setAttribute("__attr__", $varName); $ref = $node; foreach (array_reverse($code) as $line) { $node->parentNode->insertBefore($line, $ref); $ref = $line; } }