From 70eb7a2508a951dded23e229df6025d2cab22d7a Mon Sep 17 00:00:00 2001 From: Herberto Graca Date: Sat, 29 Jul 2023 10:43:48 +0200 Subject: [PATCH] Replace `array` for `string ...` This provides better typing --- src/Analyzer/ClassDescription.php | 2 +- src/Rules/ArchRule.php | 2 +- tests/Unit/Analyzer/ClassDescriptionTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Analyzer/ClassDescription.php b/src/Analyzer/ClassDescription.php index 0a2719f2..7d49407c 100644 --- a/src/Analyzer/ClassDescription.php +++ b/src/Analyzer/ClassDescription.php @@ -93,7 +93,7 @@ public function namespaceMatches(string $pattern): bool return $this->FQCN->matches($pattern); } - public function namespaceMatchesOneOfTheseNamespaces(array $classesToBeExcluded): bool + public function namespaceMatchesOneOfTheseNamespaces(string ...$classesToBeExcluded): bool { foreach ($classesToBeExcluded as $classToBeExcluded) { if ($this->namespaceMatches($classToBeExcluded)) { diff --git a/src/Rules/ArchRule.php b/src/Rules/ArchRule.php index 2909d417..cb29d8f3 100644 --- a/src/Rules/ArchRule.php +++ b/src/Rules/ArchRule.php @@ -38,7 +38,7 @@ public function __construct( public function check(ClassDescription $classDescription, Violations $violations): void { - if ($classDescription->namespaceMatchesOneOfTheseNamespaces($this->classesToBeExcluded)) { + if ($classDescription->namespaceMatchesOneOfTheseNamespaces(...$this->classesToBeExcluded)) { return; } diff --git a/tests/Unit/Analyzer/ClassDescriptionTest.php b/tests/Unit/Analyzer/ClassDescriptionTest.php index 4726d027..fd6da96a 100644 --- a/tests/Unit/Analyzer/ClassDescriptionTest.php +++ b/tests/Unit/Analyzer/ClassDescriptionTest.php @@ -36,7 +36,7 @@ public function test_should_return_true_if_there_class_is_in_namespace_array(): { $cd = $this->builder->build(); - $this->assertTrue($cd->namespaceMatchesOneOfTheseNamespaces(['Fruit'])); + $this->assertTrue($cd->namespaceMatchesOneOfTheseNamespaces('Fruit')); } public function test_should_return_true_if_is_annotated_with(): void