From 18bb62242cfa7a705861a6a96663e1297590ae6d Mon Sep 17 00:00:00 2001 From: dmajka Date: Mon, 12 Aug 2024 11:03:59 +0200 Subject: [PATCH] Blacklist: Fix building of the excludes list Reason: The "+" operator compares keys from two arrays, which, while building the excludes list, results in some paths being skipped. Implementation: Replaced array union operator with simple array_merge. Unfortunately, this approach might generate duplicate paths, so an array_unique call was added. Side effects: None. --- src/Listener/CodeCoverageListener.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index c43c1e1..9c10461 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -154,15 +154,19 @@ public function beforeSuite(SuiteEvent $event): void foreach ($this->options['blacklist'] as $option) { $settings = $this->filterDirectoryParams($option); if (!empty($settings['suffix']) || !empty($settings['prefix'])) { - $excludes = $excludes + (new FileIteratorFacade())->getFilesAsArray( - $settings['directory'], - $settings['suffix'], - $settings['prefix'] + $excludes = array_merge( + $excludes, + (new FileIteratorFacade())->getFilesAsArray( + $settings['directory'], + $settings['suffix'], + $settings['prefix'] + ) ); } else { $excludes[] = $settings['directory']; } } + $excludes = array_unique($excludes); foreach ($this->options['whitelist'] as $option) { $settings = $this->filterDirectoryParams($option);