From 4ff9b3e0ce53227e2be47c4c2dcb1fdc3e540b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 10 Oct 2024 12:38:58 +0200 Subject: [PATCH] feat(rector): Skip classes with a name too common from auto use statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- build/rector.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/rector.php b/build/rector.php index 9df995a0044..db39fb4ce48 100644 --- a/build/rector.php +++ b/build/rector.php @@ -21,7 +21,21 @@ class NextcloudNamespaceSkipVoter implements ClassNameImportSkipVoterInterface { 'OCA', 'OCP', ]; + private array $skippedClassNames = [ + 'Backend', + 'Connection', + 'Exception', + 'IManager', + 'IProvider', + 'Manager', + 'Plugin', + 'Provider', + ]; public function shouldSkip(File $file, FullyQualifiedObjectType $fullyQualifiedObjectType, Node $node) : bool { + if (in_array($fullyQualifiedObjectType->getShortName(), $this->skippedClassNames)) { + // Skip common class names to avoid confusion + return true; + } foreach ($this->namespacePrefixes as $prefix) { if (str_starts_with($fullyQualifiedObjectType->getClassName(), $prefix . '\\')) { // Import Nextcloud namespaces