Finalize the output by appending the rest of the unprocessed text and create the root node

@return void
762298
protected function finalizeOutput()
	{
		// Output the rest of the text and close the last paragraph
		$this->outputText($this->textLen, 0, true);

		// Remove empty tag pairs, e.g. <I><U></U></I> as well as empty paragraphs
		do
		{
			$this->output = preg_replace('(<([^ />]++)[^>]*></\\1>)', '', $this->output, -1, $cnt);
		}
		while ($cnt > 0);

		// Merge consecutive <i> tags
		if (strpos($this->output, '</i><i>') !== false)
		{
			$this->output = str_replace('</i><i>', '', $this->output);
		}

		// Remove control characters from the output to ensure it's valid XML
		$this->output = preg_replace('([\\x00-\\x08\\x0B-\\x1F])', '', $this->output);

		// Encode Unicode characters that are outside of the BMP
		$this->output = Utils::encodeUnicodeSupplementaryCharacters($this->output);

		// Use a <r> root if the text is rich, or <t> for plain text (including <p></p> and <br/>)
		$tagName = ($this->isRich) ? 'r' : 't';

		// Prepare the root node with all the namespace declarations
		$tmp = '<' . $tagName;
		foreach (array_keys($this->namespaces) as $prefix)
		{
			$tmp .= ' xmlns:' . $prefix . '="urn:s9e:TextFormatter:' . $prefix . '"';
		}

		$this->output = $tmp . '>' . $this->output . '</' . $tagName . '>';
	}
1231696
public function finish()
    {
        $this->end = microtime(true);
        $this->duration = $this->end - $this->start;
        DBA::addLog($this);
    }
1031128
public function finish()
    {
        if ( $this->parserState != self::PARSE_STATE_POST_LAST )
        {
            // this should never happen
            // let's give the last parser a chance to clean up after himself
            if ( $this->currentPartParser !== null )
            {
                $part = $this->currentPartParser->finish();
                $this->partDone( $part );
                $this->currentPartParser = null;
            }
        }
        $multipart = $this->finishMultipart();
        ezcMailPartParser::parsePartHeaders( $this->headers, $multipart );
        $multipart->boundary = $this->boundary;
        return $multipart;
    }
605205
protected function _truncate()
    {
        if (!$this->getLimit()->isNull()) {
            if (is_null($this->getLimit()->getCount())) {
                $this->_output = array_splice($this->_output, $this->getLimit()->getStart());
            } else {
                $this->_output = array_splice($this->_output, $this->getLimit()->getStart(), $this->getLimit()->getCount());
            }
        }
    }
1199356
public function markComplete() {
		$this->Status = "Complete";
		$this->log("Pipeline completed successfully.");
		$this->write();
		// Some steps may pre-emptively send a success message before the pipeline itself has completed
		if($this->LastMessageSent !== self::ALERT_SUCCESS) {
			$this->sendMessage(self::ALERT_SUCCESS);
		}
	}
1098123
protected void finishCreate() {

        try {
            mConnection = createConnection(mDriver.getText(), mURL.getText(),
                                           mUser.getText(),
                                           mPassword.getText());

            dispose();
        } catch (Exception e) {
            e.printStackTrace();
            mError.setText(e.toString());
        }
    }
1065065
public function finalize()
    {
        foreach ($this->getGroups() as $group) {
            foreach ($group->getMiddleware() as $middleware) {
                array_unshift($this->middleware, $middleware);
            }
        }
        foreach ($this->getMiddleware() as $middleware) {
            $this->addMiddleware($middleware);
        }
    }
465567
protected function _makeOutputProcessing()
    {
        $output = oxNew(\OxidEsales\Eshop\Core\Output::class);
        $this->setBody($output->process($this->getBody(), "oxemail"));
        $this->setAltBody($output->process($this->getAltBody(), "oxemail"));
        $output->processEmail($this);
    }
156861
private function finish()
    {
        $this->word = Utf8::str_replace(array('á', 'í', 'ó', 'é', 'ú'), array('a', 'i', 'o', 'e', 'u'), $this->word);
    }
51701
public function complete()
    {
        $filesystem = new Filesystem;
        foreach ($this->getRootFiles() as $file) {
            try {
                $filesystem->remove(SetupHelper::getFile($file));
            } catch (Exception $exception) {
                $this->io->writeError(
                    sprintf(
                        'Could not remove file "%1$s". Reason: %2$s',
                        SetupHelper::getFile($file),
                        $exception->getMessage()
                    )
                );
            }
        }
    }
1266073
private function finalizeSheet()
    {
        $this->sheetFile->fwrite('</sheetData></worksheet>');
        $this->sheetFile->rewind();
        $this->sheetFile->fwrite(SheetXml::HEADER_XML);
        $this->sheetFile->fwrite($this->sheet->getDimensionXml());
        $this->sheetFile->fwrite($this->sheet->getSheetViewsXml());
        $this->sheetFile->fwrite($this->sheet->getColsXml());
        $this->zip->addFile($this->sheetFile->getFilePath(), 'xl/worksheets/sheet1.xml');
    }
1247684
public function finalize(): void
    {
        if ($this->currentAnnotation !== null) {
            if ($this->currentAnnotationContent === null) {
                $this->parsedAnnotations[] = $this->currentAnnotation;
            } else {
                throw new AnnotationParseException(
                    'An annotation content is not closed (you probably forget to close a parenthesis or a quote)'
                );
            }
        }
    }
1094243
public function endWrite()
    {
        if (false !== $this->firstHarvestedId) {
            $this->saveFile(
                $this->firstHarvestedId, $this->getCombinedXML($this->innerXML)
            );
        }

        if (!empty($this->deletedIds)) {
            $this->saveDeletedRecords($this->deletedIds);
        }
    }
11663
public function finalize()
    {
        list($usec, $sec) = explode(' ', microtime());
        $micro = sprintf("%06d", $usec * 1000000);
        $when = new \DateTime(date('Y-m-d H:i:s.' . $micro));
        $when->setTimezone(new \DateTimeZone('UTC'));
        $this->finalTime = $when->format('Y-m-d\TH:i:s.u\Z');
        $this->isFinalState = true;
    }
1303152
public function finalizeRows()
    {
        // Fix rows LOOP_TOTAL if parseResults() did not added all resultsCollection items to the collection array
        // see https://github.com/thelia/thelia/issues/2337
        if (true === $this->countable && $this->getResultDataCollectionCount() !== $realCount = $this->getCount()) {
            foreach ($this->collection as &$item) {
                $item->set('LOOP_TOTAL', $realCount);
            }
        }
    }
206698
def finalize_content(self):
        
        self.write_closed = True
        body = self.raw_body.decode(self.encoding)
        self._init_xml(body)
        self._form_output()
772624
function process( $text, $createRootNode = true )
    {
        $text = str_replace( "\r", '', $text);
        $text = str_replace( "\t", ' ', $text);
        // replace unicode chars that will break the XML validity
        // see http://www.w3.org/TR/REC-xml/#charsets
        $text = preg_replace( '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $text, -1, $count );
        if ( $count > 0 )
        {
            $this->Messages[] = ezpI18n::tr(
                'kernel/classes/datatypes/ezxmltext',
                "%count invalid character(s) have been found and replaced by a space",
                false,
                array( '%count' => $count )
            );
        }
        if ( !$this->ParseLineBreaks )
        {
            $text = str_replace( "\n", '', $text);
        }

        $this->Document = new $this->DOMDocumentClass( '1.0', 'utf-8' );

        if ( $createRootNode )
        {
            $this->createRootNode();
        }

        // Perform pass 1
        // Parsing the source string
        $this->performPass1( $text );

        //$this->Document->formatOutput = true;
        $debug = eZDebugSetting::isConditionTrue( 'kernel-datatype-ezxmltext', eZDebug::LEVEL_DEBUG );
        if ( $debug )
        {
            eZDebug::writeDebug( $this->Document->saveXML(), eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext', 'XML after pass 1' ) );
        }

        if ( $this->QuitProcess )
        {
            return false;
        }

        // Perform pass 2
        $this->performPass2();

        //$this->Document->formatOutput = true;
        if ( $debug )
        {
            eZDebug::writeDebug( $this->Document->saveXML(), eZDebugSetting::changeLabel( 'kernel-datatype-ezxmltext', 'XML after pass 2' ) );
        }

        if ( $this->QuitProcess )
        {
            return false;
        }

        return $this->Document;
    }