Skip to content

Commit

Permalink
Document assumption that we have a DOMElement object
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 8, 2024
1 parent 4c5a8a2 commit f779aa7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Report/Xml/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\CodeCoverage\Report\Xml;

use function assert;
use DOMDocument;
use DOMElement;

Expand Down Expand Up @@ -39,6 +40,8 @@ public function totals(): Totals
);
}

assert($totalsContainer instanceof DOMElement);

return new Totals($totalsContainer);
}

Expand All @@ -65,6 +68,8 @@ public function lineCoverage(string $line): Coverage
),
);

assert($lineNode instanceof DOMElement);

return new Coverage($lineNode, $line);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Report/Xml/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\CodeCoverage\Report\Xml;

use function assert;
use DOMDocument;
use DOMElement;

Expand Down Expand Up @@ -43,6 +44,8 @@ public function totals(): Totals
);
}

assert($totalsContainer instanceof DOMElement);

return new Totals($totalsContainer);
}

Expand Down
6 changes: 6 additions & 0 deletions src/Report/Xml/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
*/
namespace SebastianBergmann\CodeCoverage\Report\Xml;

use function assert;
use DOMDocument;
use DOMElement;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down Expand Up @@ -43,6 +45,8 @@ public function buildInformation(): BuildInformation
);
}

assert($buildNode instanceof DOMElement);

return new BuildInformation($buildNode);
}

Expand All @@ -62,6 +66,8 @@ public function tests(): Tests
);
}

assert($testsNode instanceof DOMElement);

return new Tests($testsNode);
}

Expand Down
8 changes: 8 additions & 0 deletions src/Report/Xml/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
*/
namespace SebastianBergmann\CodeCoverage\Report\Xml;

use function assert;
use function basename;
use function dirname;
use DOMDocument;
use DOMElement;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Expand Down Expand Up @@ -47,6 +49,8 @@ public function functionObject($name): Method
),
);

assert($node instanceof DOMElement);

return new Method($node, $name);
}

Expand Down Expand Up @@ -76,6 +80,8 @@ public function source(): Source
);
}

assert($source instanceof DOMElement);

return new Source($source);
}

Expand All @@ -94,6 +100,8 @@ private function unitObject(string $tagName, $name): Unit
),
);

assert($node instanceof DOMElement);

return new Unit($node, $name);
}
}
2 changes: 2 additions & 0 deletions src/Report/Xml/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function addMethod(string $name): Method
),
);

assert($node instanceof DOMElement);

return new Method($node, $name);
}

Expand Down

0 comments on commit f779aa7

Please sign in to comment.