Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,29 +174,29 @@ public function process(File $phpcsFile, $openTagPointer) : void
$lineLength = \strlen(TokenHelper::getContent($phpcsFile, $start, $end));

if (!$shouldBeUsed
|| ($this->count !== null && $referenced[$canonicalName] < $this->count)
&& ($this->length !== null && $this->length > \strlen($canonicalName))
&& ($this->lineLength !== null && $this->lineClassLength !== null && ($this->lineClassLength >= \strlen($canonicalName)
|| $this->lineLength >= $lineLength))
|| ($this->count === null || $this->count > $referenced[$canonicalName])
&& ($this->length === null || $this->length > \strlen($canonicalName))
&& ($this->lineLength === null || $this->lineClassLength === null || $this->lineClassLength > \strlen($canonicalName)
|| $this->lineLength > $lineLength)
) {
continue;
}

$reason = '';

if ($referenced[$canonicalName] >= $this->count) {
if ($this->count !== null && $referenced[$canonicalName] >= $this->count) {
$reason = 'because it\'s used more than ' . $this->count . ' times.';
}

if ($this->length !== null && $this->length < \strlen($canonicalName)) {
if ($this->length !== null && $this->length <= \strlen($canonicalName)) {
$reason = $reason === ''
? 'because it\'s length is more than ' . $this->length . ' symbols.'
: 'because it\'s used more than ' . $this->count . ' times and it\'s length is more than '
. $this->length . ' symbols.';
. $this->length . ' symbols.';
}

if ($this->lineLength !== null && $this->lineClassLength !== null && \strlen($canonicalName) > $this->lineClassLength
&& $lineLength > $this->lineLength) {
if ($this->lineLength !== null && $this->lineClassLength !== null && \strlen($canonicalName) >= $this->lineClassLength
&& $lineLength >= $this->lineLength) {
$reason = 'because line length is more than ' . $this->lineLength
. ' symbols and class length is more than ' . $this->lineClassLength . ' symbols.';
}
Expand Down Expand Up @@ -485,7 +485,7 @@ private function getUniqueNameFromNamespace(string $first, string $second) : arr
private function getNormalizedClassName(string $name, array $useStatements, File $phpcsFile) : array
{
$unqualifiedName = NamespaceHelper::getUnqualifiedNameFromFullyQualifiedName($name);
$className = ClassHelper::getName($phpcsFile, TokenHelper::findNext($phpcsFile, \T_CLASS, 0));
$className = ClassHelper::getName($phpcsFile, TokenHelper::findNext($phpcsFile, [\T_CLASS, \T_INTERFACE, \T_TRAIT], 0));

if ($className === $unqualifiedName) {
return $this->getUniqueNameFromNamespace(
Expand Down