From 21e670c517eaa19905524df6babc933644739f72 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 23 Jan 2019 15:54:22 +0300 Subject: [PATCH 1/4] init IVAN --- src/CodeCoverage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 67ba40359..128f784e2 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -138,6 +138,7 @@ final class CodeCoverage */ public function __construct(Driver $driver = null, Filter $filter = null) { + //IVAN!!! if ($filter === null) { $filter = new Filter; } From a9f22c2d5e24c525991105882858f576073afe71 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 31 Jan 2019 18:05:54 +0300 Subject: [PATCH 2/4] fix --- src/CodeCoverage.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 128f784e2..8ded44501 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -378,6 +378,7 @@ public function merge(self $that): void continue; } + // we should compare the lines if any of two contains data $compareLineNumbers = \array_unique( \array_merge( @@ -386,6 +387,21 @@ public function merge(self $that): void ) ); + $dif1 = \array_keys(\array_diff_key($this->data[$file], $that->data[$file])); + $dif2 = \array_keys(\array_diff_key($that->data[$file], $this->data[$file])); + if (!empty($dif1)) { + foreach ($dif1 as $key) { + $this->data[$file][$key][] = 'Unknown'; + } + } + if (!empty($dif2)) { + foreach ($dif2 as $key) { + if (empty($this->data[$file][$key])) { + $this->data[$file][$key][] = 'Unknown'; + } + } + } + foreach ($compareLineNumbers as $line) { $thatPriority = $this->getLinePriority($that->data[$file], $line); $thisPriority = $this->getLinePriority($this->data[$file], $line); From d845909253e2c69eab4735ac8e963828e297b2e1 Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 31 Jan 2019 18:42:47 +0300 Subject: [PATCH 3/4] test --- src/CodeCoverage.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 8ded44501..6826e394c 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -387,6 +387,9 @@ public function merge(self $that): void ) ); + $aaa_lines_orig = $this->data[$file]; + $aaa_lines_second = $that->data[$file]; + $dif1 = \array_keys(\array_diff_key($this->data[$file], $that->data[$file])); $dif2 = \array_keys(\array_diff_key($that->data[$file], $this->data[$file])); if (!empty($dif1)) { @@ -396,7 +399,7 @@ public function merge(self $that): void } if (!empty($dif2)) { foreach ($dif2 as $key) { - if (empty($this->data[$file][$key])) { + if (empty($that->data[$file][$key])) { $this->data[$file][$key][] = 'Unknown'; } } From 4b750e0b5ca148dc30ab73fe57b5e513d6f5885f Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 31 Jan 2019 22:35:32 +0300 Subject: [PATCH 4/4] test 2 --- src/CodeCoverage.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php index 6826e394c..b960ea234 100644 --- a/src/CodeCoverage.php +++ b/src/CodeCoverage.php @@ -392,19 +392,34 @@ public function merge(self $that): void $dif1 = \array_keys(\array_diff_key($this->data[$file], $that->data[$file])); $dif2 = \array_keys(\array_diff_key($that->data[$file], $this->data[$file])); +// if (!empty($dif1)) { +// foreach ($dif1 as $key) { +// $this->data[$file][$key][] = 'Unknown'; +// } +// } +// if (!empty($dif2)) { +// foreach ($dif2 as $key) { +// if (empty($that->data[$file][$key])) { +// $this->data[$file][$key][] = 'Unknown'; +// } +// } +// } + if (!empty($dif1)) { foreach ($dif1 as $key) { - $this->data[$file][$key][] = 'Unknown'; + if (empty($that->data[$file][$key]) && empty($that->data[$file][$key])) { + unset($this->data[$file][$key]); + } } } if (!empty($dif2)) { foreach ($dif2 as $key) { if (empty($that->data[$file][$key])) { - $this->data[$file][$key][] = 'Unknown'; + unset($that->data[$file][$key]); } } } - + foreach ($compareLineNumbers as $line) { $thatPriority = $this->getLinePriority($that->data[$file], $line); $thisPriority = $this->getLinePriority($this->data[$file], $line);