Skip to content

Commit f03e99d

Browse files
committed
fix
1 parent cf4e3f1 commit f03e99d

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

src/Report/Xml/Facade.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function process(CodeCoverage $coverage, string $target): void
7070

7171
$report = $coverage->getReport();
7272

73+
$this->xmlWriter->openUri($this->targetFilePath('index'));
7374
$this->project = new Project(
7475
$this->xmlWriter,
7576
$coverage->getReport()->name(),
@@ -79,7 +80,7 @@ public function process(CodeCoverage $coverage, string $target): void
7980
$this->processTests($coverage->getTests());
8081
$this->processDirectory($report, $this->project);
8182

82-
$this->saveDocument($this->project->asDom(), 'index');
83+
$this->project->finalize();
8384
}
8485

8586
private function setBuildInformation(): void
@@ -241,6 +242,8 @@ private function processUnit(ProcessedClassType|ProcessedTraitType $unit, Report
241242

242243
private function processFunction(ProcessedFunctionType $function, Report $report): void
243244
{
245+
$this->xmlWriter->startElement('function');
246+
244247
$report->functionObject(
245248
$function->functionName,
246249
$function->signature,
@@ -251,6 +254,8 @@ private function processFunction(ProcessedFunctionType $function, Report $report
251254
(string) $function->coverage,
252255
$function->crap,
253256
);
257+
258+
$this->xmlWriter->endElement();
254259
}
255260

256261
/**

src/Report/Xml/Project.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ final class Project extends Node
2323

2424
public function __construct(XMLWriter $xmlWriter, string $directory)
2525
{
26+
$this->directory = $directory;
27+
2628
parent::__construct($xmlWriter);
2729

2830
$this->xmlWriter->openMemory();
@@ -31,8 +33,6 @@ public function __construct(XMLWriter $xmlWriter, string $directory)
3133
$this->xmlWriter->startElementNs(null, 'phpunit', Facade::XML_NAMESPACE);
3234
$this->xmlWriter->startElement('project');
3335
$this->xmlWriter->writeAttribute('source', $this->directory);
34-
35-
$this->directory = $directory;
3636
}
3737

3838
public function projectSourceDirectory(): string
@@ -60,10 +60,10 @@ public function tests(): Tests
6060
return new Tests($this->xmlWriter);
6161
}
6262

63-
public function asDom(): DOMDocument
63+
public function finalize(): void
6464
{
6565
$this->xmlWriter->endElement();
66-
67-
return $this->dom;
66+
$this->xmlWriter->endDocument();
67+
$this->xmlWriter->flush();
6868
}
6969
}

src/Report/Xml/Report.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,8 @@ public function functionObject(
6161
string $coverage,
6262
string $crap
6363
): void {
64-
$node = $this->contextNode()->appendChild(
65-
$this->dom->createElementNS(
66-
Facade::XML_NAMESPACE,
67-
'function',
68-
),
69-
);
70-
71-
assert($node instanceof DOMElement);
72-
7364
new Method(
74-
$node,
65+
$this->xmlWriter,
7566
$name,
7667
$signature,
7768
$start,

0 commit comments

Comments
 (0)