Skip to content

Commit f3e4686

Browse files
committed
Cleanup
1 parent faa8da3 commit f3e4686

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

SlevomatCodingStandard/Sniffs/Namespaces/AlphabeticallySortedUsesSniff.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ public function register(): array
4444
}
4545

4646
/**
47+
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
4748
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
4849
* @param \PHP_CodeSniffer\Files\File $phpcsFile
4950
* @param int $openTagPointer
5051
*/
5152
public function process(File $phpcsFile, $openTagPointer): void
5253
{
53-
$allUseStatements = UseStatementHelper::getUseStatements(
54-
$phpcsFile,
55-
$openTagPointer
56-
);
57-
foreach ($allUseStatements as $useStatements) {
54+
$fileUseStatements = UseStatementHelper::getFileUseStatements($phpcsFile);
55+
foreach ($fileUseStatements as $useStatements) {
5856
$lastUse = null;
5957
foreach ($useStatements as $useStatement) {
6058
if ($lastUse === null) {

SlevomatCodingStandard/Sniffs/Namespaces/UnusedUsesSniff.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private function getIgnoredAnnotations(): array
101101
*/
102102
public function process(File $phpcsFile, $openTagPointer): void
103103
{
104-
$allUnusedNames = UseStatementHelper::getUseStatements($phpcsFile, $openTagPointer);
104+
$fileUnusedNames = UseStatementHelper::getFileUseStatements($phpcsFile);
105105
$referencedNames = ReferencedNameHelper::getAllReferencedNames($phpcsFile, $openTagPointer);
106106

107107
$allUsedNames = [];
@@ -120,17 +120,17 @@ public function process(File $phpcsFile, $openTagPointer): void
120120
: UseStatement::getUniqueId(ReferencedName::TYPE_DEFAULT, $nameAsReferencedInFile);
121121
if (
122122
NamespaceHelper::isFullyQualifiedName($name)
123-
|| !array_key_exists($pointerBeforeUseStatements, $allUnusedNames)
124-
|| !array_key_exists($uniqueId, $allUnusedNames[$pointerBeforeUseStatements])
123+
|| !array_key_exists($pointerBeforeUseStatements, $fileUnusedNames)
124+
|| !array_key_exists($uniqueId, $fileUnusedNames[$pointerBeforeUseStatements])
125125
) {
126126
continue;
127127
}
128128

129-
if ($allUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile() !== $nameAsReferencedInFile) {
129+
if ($fileUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile() !== $nameAsReferencedInFile) {
130130
$phpcsFile->addError(sprintf(
131131
'Case of reference name "%s" and use statement "%s" does not match.',
132132
$nameAsReferencedInFile,
133-
$allUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
133+
$fileUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
134134
), $pointer, self::CODE_MISMATCHING_CASE);
135135
}
136136

@@ -156,12 +156,12 @@ public function process(File $phpcsFile, $openTagPointer): void
156156
/** @var int $pointerBeforeUseStatements */
157157
$pointerBeforeUseStatements = TokenHelper::findPrevious($phpcsFile, [T_OPEN_TAG, T_NAMESPACE], $docCommentOpenPointer - 1);
158158

159-
if (!array_key_exists($pointerBeforeUseStatements, $allUnusedNames)) {
159+
if (!array_key_exists($pointerBeforeUseStatements, $fileUnusedNames)) {
160160
$searchAnnotationsPointer = $tokens[$docCommentOpenPointer]['comment_closer'] + 1;
161161
continue;
162162
}
163163

164-
foreach ($allUnusedNames[$pointerBeforeUseStatements] as $useStatement) {
164+
foreach ($fileUnusedNames[$pointerBeforeUseStatements] as $useStatement) {
165165
$nameAsReferencedInFile = $useStatement->getNameAsReferencedInFile();
166166
$uniqueId = UseStatement::getUniqueId($useStatement->getType(), $nameAsReferencedInFile);
167167

@@ -182,7 +182,7 @@ public function process(File $phpcsFile, $openTagPointer): void
182182
$phpcsFile->addError(sprintf(
183183
'Case of reference name "%s" and use statement "%s" does not match.',
184184
$matches[1],
185-
$allUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
185+
$fileUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
186186
), $annotation->getStartPointer(), self::CODE_MISMATCHING_CASE);
187187
}
188188
}
@@ -213,7 +213,7 @@ public function process(File $phpcsFile, $openTagPointer): void
213213
$phpcsFile->addError(sprintf(
214214
'Case of reference name "%s" and use statement "%s" does not match.',
215215
$matches[1],
216-
$allUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
216+
$fileUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
217217
), $annotation->getStartPointer(), self::CODE_MISMATCHING_CASE);
218218
}
219219

@@ -268,7 +268,7 @@ public function process(File $phpcsFile, $openTagPointer): void
268268
$phpcsFile->addError(sprintf(
269269
'Case of reference name "%s" and use statement "%s" does not match.',
270270
$matches[1],
271-
$allUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
271+
$fileUnusedNames[$pointerBeforeUseStatements][$uniqueId]->getNameAsReferencedInFile()
272272
), $annotation->getStartPointer(), self::CODE_MISMATCHING_CASE);
273273
}
274274
}
@@ -279,7 +279,7 @@ public function process(File $phpcsFile, $openTagPointer): void
279279
}
280280
}
281281

282-
foreach ($allUnusedNames as $pointerBeforeUnusedNames => $unusedNames) {
282+
foreach ($fileUnusedNames as $pointerBeforeUnusedNames => $unusedNames) {
283283
$usedNames = $allUsedNames[$pointerBeforeUnusedNames] ?? [];
284284
foreach (array_diff_key($unusedNames, $usedNames) as $unusedUse) {
285285
$fullName = $unusedUse->getFullyQualifiedTypeName();

SlevomatCodingStandard/Sniffs/Namespaces/UseSpacingSniff.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,20 @@ public function register(): array
4646
}
4747

4848
/**
49+
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
4950
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
5051
* @param \PHP_CodeSniffer\Files\File $phpcsFile
5152
* @param int $openTagPointer
5253
*/
5354
public function process(File $phpcsFile, $openTagPointer): void
5455
{
55-
$allUseStatements = UseStatementHelper::getUseStatements($phpcsFile, $openTagPointer);
56+
$fileUseStatements = UseStatementHelper::getFileUseStatements($phpcsFile);
5657

57-
if (count($allUseStatements) === 0) {
58+
if (count($fileUseStatements) === 0) {
5859
return;
5960
}
6061

61-
foreach ($allUseStatements as $useStatementsByName) {
62+
foreach ($fileUseStatements as $useStatementsByName) {
6263
$useStatements = array_values($useStatementsByName);
6364

6465
$this->checkLinesBeforeFirstUse($phpcsFile, $useStatements[0]);

SlevomatCodingStandard/Sniffs/Namespaces/UselessAliasSniff.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@ public function register(): array
3030
}
3131

3232
/**
33+
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter.UnusedParameter
3334
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
3435
* @param \PHP_CodeSniffer\Files\File $phpcsFile
3536
* @param int $openTagPointer
3637
*/
3738
public function process(File $phpcsFile, $openTagPointer): void
3839
{
39-
$allUseStatements = UseStatementHelper::getUseStatements($phpcsFile, $openTagPointer);
40+
$fileUseStatements = UseStatementHelper::getFileUseStatements($phpcsFile);
4041

41-
if (count($allUseStatements) === 0) {
42+
if (count($fileUseStatements) === 0) {
4243
return;
4344
}
4445

45-
foreach ($allUseStatements as $useStatements) {
46+
foreach ($fileUseStatements as $useStatements) {
4647
foreach ($useStatements as $useStatement) {
4748
if ($useStatement->getAlias() === null) {
4849
continue;

0 commit comments

Comments
 (0)