Skip to content

Commit

Permalink
Closes #753
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed May 23, 2020
1 parent 7552283 commit 3ea1ec5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

* [#750](https://github.com/sebastianbergmann/php-code-coverage/pull/750): Inconsistent handling of namespaces
* [#751](https://github.com/sebastianbergmann/php-code-coverage/pull/751): Dead code is not highlighted correctly
* [#753](https://github.com/sebastianbergmann/php-code-coverage/issues/753): Do not use `$_SERVER['REQUEST_TIME']` because the test(ed) code might unset it

## [8.0.1] - 2020-02-19

Expand Down
6 changes: 4 additions & 2 deletions src/Report/Clover.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ final class Clover
*/
public function process(CodeCoverage $coverage, ?string $target = null, ?string $name = null): string
{
$time = (string) \time();

$xmlDocument = new \DOMDocument('1.0', 'UTF-8');
$xmlDocument->formatOutput = true;

$xmlCoverage = $xmlDocument->createElement('coverage');
$xmlCoverage->setAttribute('generated', (string) $_SERVER['REQUEST_TIME']);
$xmlCoverage->setAttribute('generated', $time);
$xmlDocument->appendChild($xmlCoverage);

$xmlProject = $xmlDocument->createElement('project');
$xmlProject->setAttribute('timestamp', (string) $_SERVER['REQUEST_TIME']);
$xmlProject->setAttribute('timestamp', $time);

if (\is_string($name)) {
$xmlProject->setAttribute('name', $name);
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Crap4j.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function process(CodeCoverage $coverage, ?string $target = null, ?string

$project = $document->createElement('project', \is_string($name) ? $name : '');
$root->appendChild($project);
$root->appendChild($document->createElement('timestamp', (string) \date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])));
$root->appendChild($document->createElement('timestamp', \date('Y-m-d H:i:s')));

$stats = $document->createElement('stats');
$methodsNode = $document->createElement('methods');
Expand Down
6 changes: 1 addition & 5 deletions src/Report/Html/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ public function process(CodeCoverage $coverage, string $target): void
$target = $this->getDirectory($target);
$report = $coverage->getReport();

if (!isset($_SERVER['REQUEST_TIME'])) {
$_SERVER['REQUEST_TIME'] = \time();
}

$date = (string) \date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']);
$date = (string) \date('D M j G:i:s T Y');

$dashboard = new Dashboard(
$this->templatePath,
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function process(CodeCoverage $coverage, bool $showColors = false): strin

$output .= $this->format($colors['header'], $padding, $title);
} else {
$date = \date(' Y-m-d H:i:s', $_SERVER['REQUEST_TIME']);
$date = \date(' Y-m-d H:i:s');
$title = 'Code Coverage Report:';

$output .= $this->format($colors['header'], $padding, $title);
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Xml/BuildInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function setRuntimeInformation(Runtime $runtime): void
}
}

public function setBuildTime(\DateTime $date): void
public function setBuildTime(\DateTimeImmutable $date): void
{
$this->contextNode->setAttribute('time', $date->format('D M j G:i:s T Y'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Xml/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function setBuildInformation(): void
{
$buildNode = $this->project->getBuildInformation();
$buildNode->setRuntimeInformation(new Runtime());
$buildNode->setBuildTime(\DateTime::createFromFormat('U', (string) $_SERVER['REQUEST_TIME']));
$buildNode->setBuildTime(new \DateTimeImmutable);
$buildNode->setGeneratorVersions($this->phpUnitVersion, Version::id());
}

Expand Down

0 comments on commit 3ea1ec5

Please sign in to comment.