feat(rector): Skip classes with a name too common from auto use statement

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/48371/head
Côme Chilliet 2024-10-10 12:38:58 +07:00
parent 28153443a5
commit 4ff9b3e0ce
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
1 changed files with 14 additions and 0 deletions

@ -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