Skip to content

Commit

Permalink
feat(symplify-cs-fixer): redesign package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
suin committed Dec 5, 2018
1 parent cd62400 commit 48ae7d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions src/Suin/Sniffs/Classes/PSR4/AutoloadabilityInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function inspect(
new PSR4UnrelatedClass();
}

private function classFileIsUnderBaseDirectory(
ClassFileUnderInspection $classFile
): bool {
return \strpos($classFile->getFileName(), $this->baseDirectory) === 0;
}

private function inspectAutoloadability(
ClassFileUnderInspection $classFile
): InspectionResult {
Expand Down Expand Up @@ -76,19 +82,13 @@ private function guessFullyQualifiedClassName(
return $this->namespacePrefix . $relativeClassName;
}

private function classFileIsUnderBaseDirectory(
ClassFileUnderInspection $classFile
): bool {
return \strpos($classFile->getFileName(), $this->baseDirectory) === 0;
private function directoryEndsWithSlash(): bool
{
return \substr($this->baseDirectory, -1) === '/';
}

private function namespaceEndsWithBackslash(): bool
{
return \substr($this->namespacePrefix, -1) === '\\';
}

private function directoryEndsWithSlash(): bool
{
return \substr($this->baseDirectory, -1) === '/';
}
}
28 changes: 14 additions & 14 deletions src/Suin/Sniffs/Classes/PSR4Sniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ final class PSR4Sniff implements Sniff
public $composerJsonPath = 'composer.json';

/**
* @var AutoloadabilityInspectors
* @var int
*/
private $autoloadabilityInspectors;
private $initialization = self::UNINITIALIZED;

/**
* @var int
* @var AutoloadabilityInspectors
*/
private $initialization = self::UNINITIALIZED;
private $autoloadabilityInspectors;

/**
* {@inheritdoc}
Expand Down Expand Up @@ -83,6 +83,16 @@ private function initializeThisSniffIfNotYet(Config $config): void
}
}

private function getClassFileOf(
File $phpcsFile,
$typePointer
): ClassFileUnderInspection {
return new ClassFileUnderInspection(
$phpcsFile->getFilename(),
ClassHelper::getFullyQualifiedName($phpcsFile, $typePointer)
);
}

private function addError(
File $phpcsFile,
NonAutoloadableClass $result,
Expand All @@ -106,14 +116,4 @@ private function getClassNameDeclarationPosition(
): ?int {
return TokenHelper::findNext($phpcsFile, \T_STRING, $typePointer + 1);
}

private function getClassFileOf(
File $phpcsFile,
$typePointer
): ClassFileUnderInspection {
return new ClassFileUnderInspection(
$phpcsFile->getFilename(),
ClassHelper::getFullyQualifiedName($phpcsFile, $typePointer)
);
}
}

0 comments on commit 48ae7d9

Please sign in to comment.