Skip to content

Commit

Permalink
Fix issues identified by Psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed May 12, 2020
1 parent 5a50ecc commit 837ec4c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
8 changes: 1 addition & 7 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.11.1@8533b866ab1a46e5a69a4692ff57f10529dbfbeb">
<files psalm-version="3.11.4@58e1d8e68e5098bf4fbfdfb420c38d563f882549">
<file src="src/CodeCoverage.php">
<ArgumentTypeCoercion occurrences="2">
<code>$unit[0]</code>
Expand Down Expand Up @@ -81,12 +81,6 @@
<ArgumentTypeCoercion occurrences="1">
<code>$this-&gt;nodes[$this-&gt;position]</code>
</ArgumentTypeCoercion>
<InvalidNullableReturnType occurrences="1">
<code>AbstractNode</code>
</InvalidNullableReturnType>
<NullableReturnStatement occurrences="1">
<code>$this-&gt;valid() ? $this-&gt;nodes[$this-&gt;position] : null</code>
</NullableReturnStatement>
</file>
<file src="src/Report/Xml/BuildInformation.php">
<PossiblyNullReference occurrences="1">
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function key(): int
/**
* Returns the current element.
*/
public function current(): AbstractNode
public function current(): ?AbstractNode
{
return $this->valid() ? $this->nodes[$this->position] : null;
}
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', \date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])));
$root->appendChild($document->createElement('timestamp', (string) \date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME'])));

$stats = $document->createElement('stats');
$methodsNode = $document->createElement('methods');
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Html/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function process(CodeCoverage $coverage, string $target): void
$_SERVER['REQUEST_TIME'] = \time();
}

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

$dashboard = new Dashboard(
$this->templatePath,
Expand Down
7 changes: 5 additions & 2 deletions src/Report/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ private function printCoverageCounts(int $numberOfCoveredElements, int $totalNum
\sprintf($format, $totalNumberOfElements) . ')';
}

private function format($color, $padding, $string): string
/**
* @param false|string $string
*/
private function format(string $color, int $padding, $string): string
{
$reset = $color ? self::COLOR_RESET : '';

return $color . \str_pad($string, $padding) . $reset . \PHP_EOL;
return $color . \str_pad((string) $string, $padding) . $reset . \PHP_EOL;
}
}
4 changes: 2 additions & 2 deletions src/Report/Xml/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public function getSource(): Source
return new Source($source);
}

private function setName($name): void
private function setName(string $name): void
{
$this->getContextNode()->setAttribute('name', \basename($name));
$this->getContextNode()->setAttribute('path', \dirname($name));
}

private function getUnitObject($tagName, $name): Unit
private function getUnitObject(string $tagName, $name): Unit
{
$node = $this->getContextNode()->appendChild(
$this->getDomDocument()->createElementNS(
Expand Down

0 comments on commit 837ec4c

Please sign in to comment.