Skip to content

Commit

Permalink
[automated] Apply Coding Standard (#6269)
Browse files Browse the repository at this point in the history
Co-authored-by: TomasVotruba <[email protected]>
  • Loading branch information
TomasVotruba and TomasVotruba authored Sep 1, 2024
1 parent 4eacb1c commit 1eb04d6
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions rules/CodingStyle/ClassNameImport/ClassNameImportSkipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,6 @@ public function shouldSkipNameForFullyQualifiedObjectType(
return false;
}

private function shouldSkipShortName(FullyQualified $fullyQualified): bool
{
// is scalar name?
if (in_array($fullyQualified->toLowerString(), ['true', 'false', 'bool'], true)) {
return true;
}

if ($fullyQualified->isSpecialClassName()) {
return true;
}

if ($this->isFunctionOrConstantImport($fullyQualified)) {
return true;
}

// Importing root namespace classes (like \DateTime) is optional
return ! SimpleParameterProvider::provideBoolParameter(Option::IMPORT_SHORT_CLASSES);
}

private function isFunctionOrConstantImport(FullyQualified $fullyQualified): bool
{
if ($fullyQualified->getAttribute(AttributeKey::IS_CONSTFETCH_NAME) === true) {
return true;
}

return $fullyQualified->getAttribute(AttributeKey::IS_FUNCCALL_NAME) === true;
}

/**
* @param array<Use_|GroupUse> $uses
*/
Expand Down Expand Up @@ -115,6 +87,34 @@ public function shouldSkipName(FullyQualified $fullyQualified, array $uses): boo
return false;
}

private function shouldSkipShortName(FullyQualified $fullyQualified): bool
{
// is scalar name?
if (in_array($fullyQualified->toLowerString(), ['true', 'false', 'bool'], true)) {
return true;
}

if ($fullyQualified->isSpecialClassName()) {
return true;
}

if ($this->isFunctionOrConstantImport($fullyQualified)) {
return true;
}

// Importing root namespace classes (like \DateTime) is optional
return ! SimpleParameterProvider::provideBoolParameter(Option::IMPORT_SHORT_CLASSES);
}

private function isFunctionOrConstantImport(FullyQualified $fullyQualified): bool
{
if ($fullyQualified->getAttribute(AttributeKey::IS_CONSTFETCH_NAME) === true) {
return true;
}

return $fullyQualified->getAttribute(AttributeKey::IS_FUNCCALL_NAME) === true;
}

private function isConflictedShortNameInUse(
UseUse $useUse,
string $useName,
Expand Down

0 comments on commit 1eb04d6

Please sign in to comment.