Skip to content

Commit

Permalink
Fix CS/WS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 16, 2017
1 parent eabfc87 commit 699b15e
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 128 deletions.
22 changes: 11 additions & 11 deletions src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ public function start($id, $clear = false)
* @param array $linesToBeUsed
* @param bool $ignoreForceCoversAnnotation
*
* @return array
*
* @throws \SebastianBergmann\CodeCoverage\RuntimeException
* @throws InvalidArgumentException
*
* @return array
*/
public function stop($append = true, $linesToBeCovered = [], array $linesToBeUsed = [], $ignoreForceCoversAnnotation = false)
{
Expand Down Expand Up @@ -746,9 +746,9 @@ private function addUncoveredFilesFromWhitelist()
*
* @param string $filename
*
* @return array
*
* @throws InvalidArgumentException
*
* @return array
*/
private function getLinesToBeIgnored($filename)
{
Expand Down Expand Up @@ -823,7 +823,7 @@ private function getLinesToBeIgnored($filename)
}

if ($this->disableIgnoredLines) {
$this->ignoredLines[$filename] = array_unique($this->ignoredLines[$filename]);
$this->ignoredLines[$filename] = \array_unique($this->ignoredLines[$filename]);
\sort($this->ignoredLines[$filename]);

return $this->ignoredLines[$filename];
Expand Down Expand Up @@ -923,7 +923,7 @@ private function getLinesToBeIgnored($filename)
$this->ignoredLines[$filename]
);

$this->ignoredLines[$filename] = array_unique($this->ignoredLines[$filename]);
$this->ignoredLines[$filename] = \array_unique($this->ignoredLines[$filename]);
\sort($this->ignoredLines[$filename]);

return $this->ignoredLines[$filename];
Expand Down Expand Up @@ -1040,9 +1040,9 @@ private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed)
}

/**
* @return Driver
*
* @throws RuntimeException
*
* @return Driver
*/
private function selectDriver()
{
Expand All @@ -1066,9 +1066,9 @@ private function selectDriver()
/**
* @param array $unintentionallyCoveredUnits
*
* @return array
*
* @throws \ReflectionException
*
* @return array
*/
private function processUnintentionallyCoveredUnits(array $unintentionallyCoveredUnits)
{
Expand Down Expand Up @@ -1102,7 +1102,7 @@ private function processUnintentionallyCoveredUnits(array $unintentionallyCovere
*
* @throws \SebastianBergmann\CodeCoverage\RuntimeException
*/
protected function initializeData()
private function initializeData()
{
$this->isInitialized = true;

Expand Down
6 changes: 3 additions & 3 deletions src/Node/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class Directory extends AbstractNode implements \IteratorAggregate
/**
* @var array
*/
private $linesOfCode = null;
private $linesOfCode;

/**
* @var int
Expand Down Expand Up @@ -163,9 +163,9 @@ public function addDirectory($name)
* @param array $testData
* @param bool $cacheTokens
*
* @return File
*
* @throws InvalidArgumentException
*
* @return File
*/
public function addFile($name, array $coverageData, array $testData, $cacheTokens)
{
Expand Down
14 changes: 7 additions & 7 deletions src/Node/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class File extends AbstractNode
/**
* @var int
*/
private $numClasses = null;
private $numClasses;

/**
* @var int
Expand All @@ -70,7 +70,7 @@ final class File extends AbstractNode
/**
* @var int
*/
private $numTraits = null;
private $numTraits;

/**
* @var int
Expand All @@ -80,17 +80,17 @@ final class File extends AbstractNode
/**
* @var int
*/
private $numMethods = null;
private $numMethods;

/**
* @var int
*/
private $numTestedMethods = null;
private $numTestedMethods;

/**
* @var int
*/
private $numTestedFunctions = null;
private $numTestedFunctions;

/**
* @var array
Expand Down Expand Up @@ -705,7 +705,7 @@ protected function processFunctions(\PHP_Token_Stream $tokens)
protected function crap($ccn, $coverage)
{
if ($coverage == 0) {
return (string) (\pow($ccn, 2) + $ccn);
return (string) ($ccn ** 2 + $ccn);
}

if ($coverage >= 95) {
Expand All @@ -714,7 +714,7 @@ protected function crap($ccn, $coverage)

return \sprintf(
'%01.2F',
\pow($ccn, 2) * \pow(1 - $coverage / 100, 3) + $ccn
$ccn ** 2 * (1 - $coverage / 100) ** 3 + $ccn
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Report/Html/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ private function copyFiles($target)
/**
* @param string $directory
*
* @return string
*
* @throws RuntimeException
*
* @return string
*/
private function getDirectory($directory)
{
Expand Down
7 changes: 4 additions & 3 deletions src/Report/Html/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,13 @@ protected function getColorLevel($percent)
{
if ($percent <= $this->lowUpperBound) {
return 'danger';
} elseif ($percent > $this->lowUpperBound &&
}
if ($percent > $this->lowUpperBound &&
$percent < $this->highLowerBound) {
return 'warning';
} else {
return 'success';
}

return 'success';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Report/Html/Renderer/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected function insufficientCoverage(array $classes, $baseLink)
}

foreach ($leastTestedMethods as $methodName => $coverage) {
list($class, $method) = \explode('::', $methodName);
[$class, $method] = \explode('::', $methodName);

$result['method'] .= \sprintf(
' <tr><td><a href="%s"><abbr title="%s">%s</abbr></a></td><td class="text-right">%d%%</td></tr>' . "\n",
Expand Down Expand Up @@ -279,7 +279,7 @@ protected function projectRisks(array $classes, $baseLink)
}

foreach ($methodRisks as $methodName => $crap) {
list($class, $method) = \explode('::', $methodName);
[$class, $method] = \explode('::', $methodName);

$result['method'] .= \sprintf(
' <tr><td><a href="%s"><abbr title="%s">%s</abbr></a></td><td class="text-right">%d</td></tr>' . "\n",
Expand Down
3 changes: 2 additions & 1 deletion src/Report/Html/Renderer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ protected function renderFunctionItems(array $functions, \Text_Template $templat

/**
* @param \Text_Template $template
* @param mixed $indent
*
* @return string
*/
Expand Down Expand Up @@ -454,7 +455,7 @@ protected function loadFile($file)
continue;
}

list($token, $value) = $token;
[$token, $value] = $token;

$value = \str_replace(
["\t", ' '],
Expand Down
4 changes: 2 additions & 2 deletions src/Report/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function process(CodeCoverage $coverage, $target = null)

if ($target !== null) {
return \file_put_contents($target, $output);
} else {
return $output;
}

return $output;
}
}
7 changes: 4 additions & 3 deletions src/Report/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function process(CodeCoverage $coverage, $showColors = false)
return $output . PHP_EOL;
}

protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElements)
private function getCoverageColor($numberOfCoveredElements, $totalNumberOfElements)
{
$coverage = Util::percent(
$numberOfCoveredElements,
Expand All @@ -227,14 +227,15 @@ protected function getCoverageColor($numberOfCoveredElements, $totalNumberOfElem

if ($coverage >= $this->highLowerBound) {
return $this->colors['green'];
} elseif ($coverage > $this->lowUpperBound) {
}
if ($coverage > $this->lowUpperBound) {
return $this->colors['yellow'];
}

return $this->colors['red'];
}

protected function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $precision)
private function printCoverageCounts($numberOfCoveredElements, $totalNumberOfElements, $precision)
{
$format = '%' . $precision . 's';

Expand Down
36 changes: 18 additions & 18 deletions src/Report/Xml/BuildInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ public function setRuntimeInformation(Runtime $runtime)
}
}

/**
* @param \DateTime $date
*/
public function setBuildTime(\DateTime $date)
{
$this->contextNode->setAttribute('time', $date->format('D M j G:i:s T Y'));
}

/**
* @param string $phpUnitVersion
* @param string $coverageVersion
*/
public function setGeneratorVersions($phpUnitVersion, $coverageVersion)
{
$this->contextNode->setAttribute('phpunit', $phpUnitVersion);
$this->contextNode->setAttribute('coverage', $coverageVersion);
}

/**
* @param $name
*
Expand All @@ -74,22 +92,4 @@ private function getNodeByName($name)

return $node;
}

/**
* @param \DateTime $date
*/
public function setBuildTime(\DateTime $date)
{
$this->contextNode->setAttribute('time', $date->format('D M j G:i:s T Y'));
}

/**
* @param string $phpUnitVersion
* @param string $coverageVersion
*/
public function setGeneratorVersions($phpUnitVersion, $coverageVersion)
{
$this->contextNode->setAttribute('phpunit', $phpUnitVersion);
$this->contextNode->setAttribute('coverage', $coverageVersion);
}
}
6 changes: 3 additions & 3 deletions src/Report/Xml/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function setBuildInformation()
/**
* @param string $directory
*/
protected function initTargetDirectory($directory)
private function initTargetDirectory($directory)
{
if (\file_exists($directory)) {
if (!\is_dir($directory)) {
Expand Down Expand Up @@ -265,12 +265,12 @@ private function setTotals(AbstractNode $node, Totals $totals)
/**
* @return string
*/
protected function getTargetDirectory()
private function getTargetDirectory()
{
return $this->target;
}

protected function saveDocument(\DOMDocument $document, $name)
private function saveDocument(\DOMDocument $document, $name)
{
$filename = \sprintf('%s/%s.xml', $this->getTargetDirectory(), $name);

Expand Down
32 changes: 16 additions & 16 deletions src/Report/Xml/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ public function __construct(\DOMElement $context)
$this->contextNode = $context;
}

/**
* @return \DOMElement
*/
protected function getContextNode()
{
return $this->contextNode;
}

/**
* @return \DOMDocument
*/
protected function getDomDocument()
{
return $this->dom;
}

public function getTotals()
{
$totalsContainer = $this->contextNode->firstChild;
Expand Down Expand Up @@ -85,4 +69,20 @@ public function getLineCoverage($line)

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

/**
* @return \DOMElement
*/
protected function getContextNode()
{
return $this->contextNode;
}

/**
* @return \DOMDocument
*/
protected function getDomDocument()
{
return $this->dom;
}
}
10 changes: 5 additions & 5 deletions src/Report/Xml/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ public function __construct(\DOMElement $context, $name)
$this->setName($name);
}

private function setName($name)
{
$this->contextNode->setAttribute('name', $name);
}

public function setSignature($signature)
{
$this->contextNode->setAttribute('signature', $signature);
Expand All @@ -54,4 +49,9 @@ public function setCrap($crap)
{
$this->contextNode->setAttribute('crap', $crap);
}

private function setName($name)
{
$this->contextNode->setAttribute('name', $name);
}
}
Loading

0 comments on commit 699b15e

Please sign in to comment.