Skip to content

Commit 6ff8cdb

Browse files
committed
Fix CS and signatures.
1 parent 75a23af commit 6ff8cdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+140
-146
lines changed

PSR2R/Sniffs/Classes/BraceOnSameLineSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function register(): array {
2828
/**
2929
* @inheritDoc
3030
*/
31-
public function process(File $phpcsFile, $stackPtr) {
31+
public function process(File $phpcsFile, int $stackPtr): void {
3232
$tokens = $phpcsFile->getTokens();
3333
$errorData = [strtolower($tokens[$stackPtr]['content'])];
3434

PSR2R/Sniffs/Classes/InterfaceNameSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function register(): array {
2020
/**
2121
* @inheritDoc
2222
*/
23-
public function process(File $phpcsFile, $stackPtr) {
23+
public function process(File $phpcsFile, int $stackPtr): void {
2424
$tokens = $phpcsFile->getTokens();
2525

2626
$nameIndex = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);

PSR2R/Sniffs/Classes/TraitNameSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function register(): array {
2020
/**
2121
* @inheritDoc
2222
*/
23-
public function process(File $phpcsFile, $stackPtr) {
23+
public function process(File $phpcsFile, int $stackPtr): void {
2424
$tokens = $phpcsFile->getTokens();
2525

2626
$nameIndex = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);

PSR2R/Sniffs/Commenting/DocBlockEndingSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function register(): array {
2424
/**
2525
* @inheritDoc
2626
*/
27-
public function process(File $phpcsFile, $stackPtr) {
27+
public function process(File $phpcsFile, int $stackPtr): void {
2828
$tokens = $phpcsFile->getTokens();
2929

3030
// We are only interested in function/class/interface doc block comments.

PSR2R/Sniffs/Commenting/DocBlockNoEmptySniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function register(): array {
2222
/**
2323
* @inheritDoc
2424
*/
25-
public function process(File $phpcsFile, $stackPtr) {
25+
public function process(File $phpcsFile, int $stackPtr): void {
2626
$tokens = $phpcsFile->getTokens();
2727

2828
if (empty($tokens[$stackPtr]['comment_closer'])) {

PSR2R/Sniffs/Commenting/DocBlockParamArraySniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public function register(): array {
2929
/**
3030
* @inheritDoc
3131
*/
32-
public function process(File $phpCsFile, $stackPointer): void {
33-
$tokens = $phpCsFile->getTokens();
32+
public function process(File $phpcsFile, int $stackPointer): void {
33+
$tokens = $phpcsFile->getTokens();
3434

35-
$docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
35+
$docBlockEndIndex = $this->findRelatedDocBlock($phpcsFile, $stackPointer);
3636

3737
if (!$docBlockEndIndex) {
3838
return;
@@ -74,7 +74,7 @@ public function process(File $phpCsFile, $stackPointer): void {
7474

7575
$error = 'Doc Block param type `array` not needed on top of `...[]`';
7676
// For now just report
77-
$fix = $phpCsFile->addFixableError($error, $classNameIndex, 'TypeDuplicated');
77+
$fix = $phpcsFile->addFixableError($error, $classNameIndex, 'TypeDuplicated');
7878
if (!$fix) {
7979
continue;
8080
}
@@ -85,9 +85,9 @@ public function process(File $phpCsFile, $stackPointer): void {
8585
}
8686
$content = implode('|', $pieces);
8787

88-
$phpCsFile->fixer->beginChangeset();
89-
$phpCsFile->fixer->replaceToken($classNameIndex, $content . $appendix);
90-
$phpCsFile->fixer->endChangeset();
88+
$phpcsFile->fixer->beginChangeset();
89+
$phpcsFile->fixer->replaceToken($classNameIndex, $content . $appendix);
90+
$phpcsFile->fixer->endChangeset();
9191
}
9292
}
9393

PSR2R/Sniffs/Commenting/DocBlockParamNoOpSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public function register(): array {
2525
/**
2626
* @inheritDoc
2727
*/
28-
public function process(File $phpCsFile, $stackPointer): void {
29-
$tokens = $phpCsFile->getTokens();
28+
public function process(File $phpcsFile, int $stackPointer): void {
29+
$tokens = $phpcsFile->getTokens();
3030

31-
$docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
31+
$docBlockEndIndex = $this->findRelatedDocBlock($phpcsFile, $stackPointer);
3232

3333
if (!$docBlockEndIndex) {
3434
return;
@@ -66,7 +66,7 @@ public function process(File $phpCsFile, $stackPointer): void {
6666

6767
$error = 'Possible doc block error: `' . $content
6868
. '` as only param type does not seem right. Makes this a no-op.';
69-
$phpCsFile->addWarning($error, $i, 'ParamNoOp');
69+
$phpcsFile->addWarning($error, $i, 'ParamNoOp');
7070
}
7171
}
7272

PSR2R/Sniffs/Commenting/DocBlockParamNotJustNullSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ public function register(): array {
3030
/**
3131
* @inheritDoc
3232
*/
33-
public function process(File $phpCsFile, $stackPointer): void {
34-
$tokens = $phpCsFile->getTokens();
33+
public function process(File $phpcsFile, int $stackPointer): void {
34+
$tokens = $phpcsFile->getTokens();
3535

36-
$docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
36+
$docBlockEndIndex = $this->findRelatedDocBlock($phpcsFile, $stackPointer);
3737

3838
if (!$docBlockEndIndex) {
3939
return;
4040
}
4141

42-
$methodSignature = $this->getMethodSignature($phpCsFile, $stackPointer);
42+
$methodSignature = $this->getMethodSignature($phpcsFile, $stackPointer);
4343
if (!$methodSignature) {
4444
return;
4545
}
@@ -77,7 +77,7 @@ public function process(File $phpCsFile, $stackPointer): void {
7777
continue;
7878
}
7979

80-
$phpCsFile->addError('"null" as only param type does not make sense', $classNameIndex, 'NotJustNull');
80+
$phpcsFile->addError('"null" as only param type does not make sense', $classNameIndex, 'NotJustNull');
8181
}
8282
}
8383

PSR2R/Sniffs/Commenting/DocBlockParamSniff.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ public function register(): array {
3030
/**
3131
* @inheritDoc
3232
*/
33-
public function process(File $phpCsFile, $stackPointer): void {
34-
$tokens = $phpCsFile->getTokens();
33+
public function process(File $phpcsFile, int $stackPointer): void {
34+
$tokens = $phpcsFile->getTokens();
3535

36-
$docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
36+
$docBlockEndIndex = $this->findRelatedDocBlock($phpcsFile, $stackPointer);
3737

3838
if (!$docBlockEndIndex) {
3939
return;
4040
}
4141

4242
$docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener'];
4343

44-
if ($this->hasInheritDoc($phpCsFile, $docBlockStartIndex, $docBlockEndIndex)) {
44+
if ($this->hasInheritDoc($phpcsFile, $docBlockStartIndex, $docBlockEndIndex)) {
4545
return;
4646
}
4747

48-
$methodSignature = $this->getMethodSignature($phpCsFile, $stackPointer);
48+
$methodSignature = $this->getMethodSignature($phpcsFile, $stackPointer);
4949
if (!$methodSignature) {
5050
return;
5151
}
@@ -62,7 +62,7 @@ public function process(File $phpCsFile, $stackPointer): void {
6262
$classNameIndex = $i + 2;
6363

6464
if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
65-
$phpCsFile->addError('Missing type in param doc block', $i, 'MissingParamType');
65+
$phpcsFile->addError('Missing type in param doc block', $i, 'MissingParamType');
6666

6767
continue;
6868
}
@@ -89,7 +89,7 @@ public function process(File $phpCsFile, $stackPointer): void {
8989
}
9090

9191
if (count($docBlockParams) !== count($methodSignature)) {
92-
$phpCsFile->addError('Doc Block params do not match method signature', $stackPointer, 'ParamTypeMismatch');
92+
$phpcsFile->addError('Doc Block params do not match method signature', $stackPointer, 'ParamTypeMismatch');
9393

9494
return;
9595
}
@@ -108,10 +108,10 @@ public function process(File $phpCsFile, $stackPointer): void {
108108

109109
$error = 'Doc Block param variable `' . $docBlockParam['variable'] . '` should be `' . $variableName . '`';
110110
// For now just report (buggy yet)
111-
$phpCsFile->addError($error, $docBlockParam['index'], 'VariableWrong');
111+
$phpcsFile->addError($error, $docBlockParam['index'], 'VariableWrong');
112112

113113
/*
114-
$fix = $phpCsFile->addFixableError($error, $docBlockParam['index'], 'VariableWrong');
114+
$fix = $phpcsFile->addFixableError($error, $docBlockParam['index'], 'VariableWrong');
115115
if ($fix) {
116116
if ($docBlockParam['variable']) {
117117
$appendix = str_replace($docBlockParam['variable'], '', $docBlockParam['appendix']);
@@ -120,7 +120,7 @@ public function process(File $phpCsFile, $stackPointer): void {
120120
$appendix = ' ' . $variableName . $docBlockParam['appendix'];
121121
}
122122
$content = $docBlockParam['type'] . $appendix;
123-
$phpCsFile->fixer->replaceToken($docBlockParam['index'], $content);
123+
$phpcsFile->fixer->replaceToken($docBlockParam['index'], $content);
124124
}
125125
*/
126126
}
@@ -129,34 +129,34 @@ public function process(File $phpCsFile, $stackPointer): void {
129129
/**
130130
* //TODO: Replace with SignatureTrait
131131
*
132-
* @param \PHP_CodeSniffer\Files\File $phpCsFile
132+
* @param \PHP_CodeSniffer\Files\File $phpcsFile
133133
* @param int $stackPtr
134134
*
135135
* @return array
136136
*/
137-
private function getMethodSignature(File $phpCsFile, int $stackPtr): array {
138-
$tokens = $phpCsFile->getTokens();
137+
private function getMethodSignature(File $phpcsFile, int $stackPtr): array {
138+
$tokens = $phpcsFile->getTokens();
139139

140-
$startIndex = $phpCsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr + 1);
140+
$startIndex = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr + 1);
141141
$endIndex = $tokens[$startIndex]['parenthesis_closer'];
142142

143143
$arguments = [];
144144
$i = $startIndex;
145-
while ($nextVariableIndex = $phpCsFile->findNext(T_VARIABLE, $i + 1, $endIndex)) {
145+
while ($nextVariableIndex = $phpcsFile->findNext(T_VARIABLE, $i + 1, $endIndex)) {
146146
$typehint = $default = null;
147147
$possibleTypeHint =
148-
$phpCsFile->findPrevious([T_ARRAY, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3);
148+
$phpcsFile->findPrevious([T_ARRAY, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3);
149149
if ($possibleTypeHint) {
150150
$typehint = $possibleTypeHint;
151151
}
152152
if ($possibleTypeHint) {
153153
$typehint = $possibleTypeHint;
154154
}
155155

156-
$possibleEqualIndex = $phpCsFile->findNext([T_EQUAL], $nextVariableIndex + 1, $nextVariableIndex + 2);
156+
$possibleEqualIndex = $phpcsFile->findNext([T_EQUAL], $nextVariableIndex + 1, $nextVariableIndex + 2);
157157
if ($possibleEqualIndex) {
158158
$possibleDefaultValue =
159-
$phpCsFile->findNext(
159+
$phpcsFile->findNext(
160160
[T_STRING, T_TRUE, T_FALSE, T_NULL, T_ARRAY],
161161
$possibleEqualIndex + 1,
162162
$possibleEqualIndex + 2,

PSR2R/Sniffs/Commenting/DocBlockReturnSelfSniff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function register(): array {
2929
/**
3030
* @inheritDoc
3131
*/
32-
public function process(File $phpCsFile, $stackPointer): void {
33-
$tokens = $phpCsFile->getTokens();
32+
public function process(File $phpcsFile, int $stackPointer): void {
33+
$tokens = $phpcsFile->getTokens();
3434
if (($stackPointer > 1) && ($tokens[$stackPointer - 2]['code'] === T_STATIC)) {
3535
return; // Skip static function declarations
3636
}
@@ -39,7 +39,7 @@ public function process(File $phpCsFile, $stackPointer): void {
3939
return;
4040
}
4141

42-
$docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer);
42+
$docBlockEndIndex = $this->findRelatedDocBlock($phpcsFile, $stackPointer);
4343

4444
if (!$docBlockEndIndex) {
4545
return;
@@ -79,7 +79,7 @@ public function process(File $phpCsFile, $stackPointer): void {
7979
}
8080

8181
$parts = explode('|', $content);
82-
$this->fixParts($phpCsFile, $classNameIndex, $parts, $appendix);
82+
$this->fixParts($phpcsFile, $classNameIndex, $parts, $appendix);
8383
}
8484
}
8585

@@ -108,14 +108,14 @@ protected function isNonChainable(array $tokens, int $stackPointer): bool {
108108
}
109109

110110
/**
111-
* @param \PHP_CodeSniffer\Files\File $phpCsFile
111+
* @param \PHP_CodeSniffer\Files\File $phpcsFile
112112
* @param int $classNameIndex
113113
* @param array<string> $parts
114114
* @param string $appendix
115115
*
116116
* @return void
117117
*/
118-
protected function fixParts(File $phpCsFile, int $classNameIndex, array $parts, string $appendix): void {
118+
protected function fixParts(File $phpcsFile, int $classNameIndex, array $parts, string $appendix): void {
119119
$result = [];
120120
foreach ($parts as $key => $part) {
121121
if ($part !== 'self') {
@@ -135,13 +135,13 @@ protected function fixParts(File $phpCsFile, int $classNameIndex, array $parts,
135135
$message[] = $part . ' => ' . $useStatement;
136136
}
137137

138-
$fix = $phpCsFile->addFixableError(implode(', ', $message), $classNameIndex, 'ReturnSelf');
138+
$fix = $phpcsFile->addFixableError(implode(', ', $message), $classNameIndex, 'ReturnSelf');
139139
if (!$fix) {
140140
return;
141141
}
142142

143143
$newContent = implode('|', $parts);
144-
$phpCsFile->fixer->replaceToken($classNameIndex, $newContent . $appendix);
144+
$phpcsFile->fixer->replaceToken($classNameIndex, $newContent . $appendix);
145145
}
146146

147147
}

0 commit comments

Comments
 (0)