Skip to content

Commit 04c9f44

Browse files
committed
fix
1 parent 79dd19e commit 04c9f44

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

src/Report/Xml/Facade.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private function processFile(FileNode $file, Directory $context): void
159159
strlen($this->project->projectSourceDirectory()),
160160
);
161161

162+
$this->xmlWriter->openUri($this->targetFilePath($file->id()));
162163
$fileReport = new Report($this->xmlWriter, $path);
163164

164165
$this->setTotals($file, $fileReport->totals());
@@ -191,7 +192,6 @@ private function processFile(FileNode $file, Directory $context): void
191192
$this->xmlWriter->endElement();
192193

193194
$fileReport->finalize();
194-
$this->saveDocument($fileReport->asDom(), $file->id());
195195
}
196196

197197
private function processUnit(ProcessedClassType|ProcessedTraitType $unit, Report $report): void
@@ -325,11 +325,4 @@ private function targetFilePath(string $name): string
325325
return $filename;
326326
}
327327

328-
/**
329-
* @throws XmlException
330-
*/
331-
private function saveDocument(DOMDocument $document, string $name): void
332-
{
333-
Filesystem::write($this->targetFilePath($name), Xml::asString($document));
334-
}
335328
}

src/Report/Xml/Node.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,4 @@ public function addFile(): File
4242
return new File($this->xmlWriter);
4343
}
4444

45-
protected function contextNode(): DOMElement
46-
{
47-
return $this->contextNode;
48-
}
4945
}

src/Report/Xml/Source.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,23 @@
1313
use TheSeer\Tokenizer\NamespaceUri;
1414
use TheSeer\Tokenizer\Tokenizer;
1515
use TheSeer\Tokenizer\XMLSerializer;
16+
use XMLWriter;
1617

1718
/**
1819
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
1920
*/
2021
final readonly class Source
2122
{
22-
private DOMElement $context;
23+
private XMLWriter $xmlWriter;
2324

24-
public function __construct(DOMElement $context)
25+
public function __construct(XMLWriter $xmlWriter)
2526
{
26-
$this->context = $context;
27+
$this->xmlWriter = $xmlWriter;
2728
}
2829

2930
public function setSourceCode(string $source): void
3031
{
31-
$context = $this->context;
32-
3332
$tokens = (new Tokenizer)->parse($source);
34-
$srcDom = (new XMLSerializer(new NamespaceUri(Facade::XML_NAMESPACE)))->toDom($tokens);
35-
36-
$context->parentNode->replaceChild(
37-
$context->ownerDocument->importNode($srcDom->documentElement, true),
38-
$context,
39-
);
33+
(new XMLSerializer(new NamespaceUri(Facade::XML_NAMESPACE)))->appendToWriter($this->xmlWriter, $tokens);
4034
}
4135
}

0 commit comments

Comments
 (0)