Skip to content

Commit b01cc27

Browse files
committed
fix for empty array
1 parent 4536cfb commit b01cc27

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

bin/phar/codacycoverage.phar

171 Bytes
Binary file not shown.

src/Codacy/Coverage/Parser/CloverParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Codacy\Coverage\Parser;
44

5-
use Codacy\Coverage\Report\FileReport;
65
use Codacy\Coverage\Report\CoverageReport;
6+
use Codacy\Coverage\Report\FileReport;
77

88
/**
99
* Parses Clover XML file and produces a CoverageReport object.
@@ -104,14 +104,14 @@ private function makeFileReportsFromPackages(\SimpleXMLElement $node, $fileRepor
104104
*/
105105
private function getLineCoverage(\SimpleXMLElement $node)
106106
{
107-
$lineCoverage = array();
107+
$lineCoverage = (object)array();
108108
foreach ($node as $line) {
109109
$count = intval($line['count']);
110110
// iterate all lines in that file
111111
if ($line['type'] == 'stmt' && $count > 0) {
112112
$lineNr = (string)$line['num'];
113113
$hit = $count;
114-
$lineCoverage[$lineNr] = $hit;
114+
$lineCoverage->$lineNr = $hit;
115115
}
116116
}
117117
return $lineCoverage;

src/Codacy/Coverage/Parser/PhpUnitXmlParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Codacy\Coverage\Parser;
44

5-
use Codacy\Coverage\Report\FileReport;
65
use Codacy\Coverage\Report\CoverageReport;
6+
use Codacy\Coverage\Report\FileReport;
77

88
/**
99
* Parses XML file, result of phpunit --coverage-xml, and produces
@@ -78,13 +78,13 @@ public function makeReport()
7878
*/
7979
private function getLineCoverage(\SimpleXMLElement $node)
8080
{
81-
$lineCoverage = array();
81+
$lineCoverage = (object)array();
8282
if ($node->file->coverage) {
8383
foreach ($node->file->coverage->line as $line) {
8484
$count = $line->covered->count();
8585
if ($count > 0) {
8686
$nr = (string)$line["nr"];
87-
$lineCoverage[$nr] = $count;
87+
$lineCoverage->$nr = $count;
8888
}
8989
}
9090
}

tests/Codacy/Coverage/Parser/CloverParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private function _canParseClover($path, $rootDir)
5252
$fileReports = $report->getFileReports();
5353
$fileReport = $fileReports[1];
5454

55-
$expLineCoverage = array(11 => 1, 12 => 1, 13 => 1, 16 => 1);
55+
$expLineCoverage = (object)array(11 => 1, 12 => 1, 13 => 1, 16 => 1);
5656
$this->assertEquals($fileReport->getLineCoverage(), $expLineCoverage);
5757

5858
$this->assertEquals("src/Codacy/Coverage/Parser/Parser.php", $parserFileName);

tests/Codacy/Coverage/Parser/ParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testParsersProduceSameResult()
1515
$cloverParser = new CloverParser('tests/res/phpunit-clover/clover.xml', '/home/jacke/Desktop/codacy-php');
1616
$xunitParser = new PhpUnitXmlParser('tests/res/phpunit-clover/index.xml', '/home/jacke/Desktop/codacy-php');
1717
$xunitParser->setDirOfFileXmls('tests/res/phpunit-clover');
18-
$expectedJson = $file = file_get_contents('tests/res/expected.json', true);
18+
$expectedJson = file_get_contents('tests/res/expected.json', true);
1919

2020
$jsonProducer = new JsonProducer();
2121

tests/Codacy/Coverage/Parser/PhpUnitXmlParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testCanParsePhpUnitXmlReport()
3737
$this->assertEquals(95, $cloverParserFileReport->getTotal());
3838

3939
$lineCoverage = $configFileReport->getLineCoverage();
40-
$expLineCoverage = array(24 => 4, 25 => 4, 26 => 4, 27 => 4, 28 => 4, 29 => 4);
40+
$expLineCoverage = (object)array(24 => 4, 25 => 4, 26 => 4, 27 => 4, 28 => 4, 29 => 4);
4141
$this->assertEquals($lineCoverage, $expLineCoverage);
4242

4343
$configFileName = $configFileReport->getFileName();

0 commit comments

Comments
 (0)