From 35c4fcd487b31da554378c745752d2450864b620 Mon Sep 17 00:00:00 2001 From: Carlos Alandete Sastre Date: Mon, 13 Dec 2021 19:22:52 +0100 Subject: [PATCH] Remove regex selections from origins to avoid duplicated statements --- src/Statement/StatementBuilder.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Statement/StatementBuilder.php b/src/Statement/StatementBuilder.php index 3e8e296f..f8badf5d 100644 --- a/src/Statement/StatementBuilder.php +++ b/src/Statement/StatementBuilder.php @@ -115,6 +115,8 @@ private function selectOrigins(array $includedInRule, array $excludedInRule, Ref $classNamesToValidate = $filteredClassNames; } + $classNamesToValidate = $this->removeRegexClassNames($classNamesToValidate); + return $classNamesToValidate; } @@ -143,6 +145,14 @@ private function selectDestinations( return array_values($classLikeNames); } + private function removeRegexClassNames(array $classNames): array + { + return array_filter( + $classNames, + fn (ClassLike $c) => !$this->isRegex($c->toString()) + ); + } + private function isRegex(string $str): bool { return strpos($str, '*') !== false;