Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
[CodingStandard] ClassStringtoClassConstantFixer - run only for names…
Browse files Browse the repository at this point in the history
…paced classes, run after NoLeadinSlashImport and after OrderedImports
  • Loading branch information
TomasVotruba committed Jul 14, 2017
1 parent 7166976 commit 9df20a0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class ClassStringToClassConstantFixer implements DefinedFixerInterface
/**
* @var string
*/
private const CLASS_OR_INTERFACE_PATTERN = '#^[A-Z]\w*[a-z]\w*(\\\\[A-Z]\w*[a-z]\w*)*\z#';
private const CLASS_OR_INTERFACE_PATTERN = '#^[A-Z]\w*[a-z]\w*(\\\\[A-Z]\w*[a-z]\w*)+\z#';

public function getDefinition(): FixerDefinitionInterface
{
Expand Down Expand Up @@ -82,8 +82,8 @@ public function getName(): string

public function getPriority(): int
{
// @todo combine with namespace import fixer/sniff
return 0;
// should be run before the OrderedImportsFixer, after the NoLeadingImportSlashFixer
return -25;
}

public function supports(SplFileInfo $file): bool
Expand All @@ -93,7 +93,9 @@ public function supports(SplFileInfo $file): bool

private function isClassOrInterface(string $potentialClassOrInterface): bool
{
return (bool) preg_match(self::CLASS_OR_INTERFACE_PATTERN, $potentialClassOrInterface);
return class_exists($potentialClassOrInterface)
|| interface_exists($potentialClassOrInterface)
|| (bool) preg_match(self::CLASS_OR_INTERFACE_PATTERN, $potentialClassOrInterface);
}

/**
Expand Down

0 comments on commit 9df20a0

Please sign in to comment.