Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit faf48e1

Browse files
authored
Merge pull request #18 from vossik/use
added ReferenceUsedNamesAfterUsageSniff
2 parents 4a5fc2f + 174b8cc commit faf48e1

File tree

9 files changed

+553
-44
lines changed

9 files changed

+553
-44
lines changed

‎InfinityloopCodingStandard/Sniffs/Classes/ConstructorPropertyPromotionSpacingSniff.php‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
namespace InfinityloopCodingStandard\Sniffs\Classes;
66

7+
use \SlevomatCodingStandard\Helpers\FunctionHelper;
8+
use \SlevomatCodingStandard\Helpers\SniffSettingsHelper;
9+
use \SlevomatCodingStandard\Helpers\TokenHelper;
10+
711
class ConstructorPropertyPromotionSpacingSniff implements \PHP_CodeSniffer\Sniffs\Sniff
812
{
913
public const CONSTRUCTOR_PARAMETER_SAME_LINE = 'ConstructorParametersOnSameLine';
@@ -15,19 +19,19 @@ public function register() : array
1519

1620
public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer) : void
1721
{
18-
if (!\SlevomatCodingStandard\Helpers\SniffSettingsHelper::isEnabledByPhpVersion(null, 80000)) {
22+
if (!SniffSettingsHelper::isEnabledByPhpVersion(null, 80000)) {
1923
return;
2024
}
2125

2226
$tokens = $phpcsFile->getTokens();
2327

24-
$namePointer = \SlevomatCodingStandard\Helpers\TokenHelper::findNextEffective($phpcsFile, $functionPointer + 1);
28+
$namePointer = TokenHelper::findNextEffective($phpcsFile, $functionPointer + 1);
2529

2630
if (\strtolower($tokens[$namePointer]['content']) !== '__construct') {
2731
return;
2832
}
2933

30-
if (\SlevomatCodingStandard\Helpers\FunctionHelper::isAbstract($phpcsFile, $functionPointer)) {
34+
if (FunctionHelper::isAbstract($phpcsFile, $functionPointer)) {
3135
return;
3236
}
3337

@@ -40,13 +44,13 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
4044
$containsPropertyPromotion = false;
4145

4246
foreach ($parameterPointers as $parameterPointer) {
43-
$pointerBefore = \SlevomatCodingStandard\Helpers\TokenHelper::findPrevious(
47+
$pointerBefore = TokenHelper::findPrevious(
4448
$phpcsFile,
4549
[\T_COMMA, \T_OPEN_PARENTHESIS],
4650
$parameterPointer - 1,
4751
);
4852

49-
$visibilityPointer = \SlevomatCodingStandard\Helpers\TokenHelper::findNextEffective($phpcsFile, $pointerBefore + 1);
53+
$visibilityPointer = TokenHelper::findNextEffective($phpcsFile, $pointerBefore + 1);
5054

5155
if (\in_array($tokens[$visibilityPointer]['code'], \PHP_CodeSniffer\Util\Tokens::$scopeModifiers, true)) {
5256
$containsPropertyPromotion = true;
@@ -58,7 +62,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
5862
}
5963

6064
if (\count($parameterPointers) === 1) {
61-
$pointerBefore = \SlevomatCodingStandard\Helpers\TokenHelper::findPrevious(
65+
$pointerBefore = TokenHelper::findPrevious(
6266
$phpcsFile,
6367
[\T_COMMA, \T_OPEN_PARENTHESIS],
6468
$parameterPointers[0],
@@ -110,7 +114,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
110114

111115
$phpcsFile->fixer->beginChangeset();
112116

113-
$pointerBefore = \SlevomatCodingStandard\Helpers\TokenHelper::findPrevious(
117+
$pointerBefore = TokenHelper::findPrevious(
114118
$phpcsFile,
115119
[\T_COMMA, \T_OPEN_PARENTHESIS],
116120
$parameterPointer - 1,
@@ -126,7 +130,7 @@ private function getParameterPointers(\PHP_CodeSniffer\Files\File $phpcsFile, in
126130
{
127131
$tokens = $phpcsFile->getTokens();
128132

129-
return \SlevomatCodingStandard\Helpers\TokenHelper::findNextAll(
133+
return TokenHelper::findNextAll(
130134
$phpcsFile,
131135
\T_VARIABLE,
132136
$tokens[$functionPointer]['parenthesis_opener'] + 1,

‎InfinityloopCodingStandard/Sniffs/ControlStructures/RequireMultiLineNullCoalesceSniff.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace InfinityloopCodingStandard\Sniffs\ControlStructures;
66

7+
use \PHP_CodeSniffer\Files\File;
78
use \SlevomatCodingStandard\Helpers\TokenHelper;
89

910
class RequireMultiLineNullCoalesceSniff implements \PHP_CodeSniffer\Sniffs\Sniff
@@ -24,7 +25,7 @@ public function register() : array
2425
}
2526

2627
//@phpcs:ignore Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
27-
public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $coalescePointer) : void
28+
public function process(File $phpcsFile, $coalescePointer) : void
2829
{
2930
$tokens = $phpcsFile->getTokens();
3031

‎InfinityloopCodingStandard/Sniffs/ControlStructures/SwitchCommentSpacingSniff.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace InfinityloopCodingStandard\Sniffs\ControlStructures;
66

7+
use \PHP_CodeSniffer\Files\File;
78
use \SlevomatCodingStandard\Helpers\TokenHelper;
89

910
class SwitchCommentSpacingSniff implements \PHP_CodeSniffer\Sniffs\Sniff
@@ -21,7 +22,7 @@ public function register() : array
2122
}
2223

2324
//@phpcs:ignore Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
24-
public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) : void
25+
public function process(File $phpcsFile, $stackPtr) : void
2526
{
2627
$tokens = $phpcsFile->getTokens();
2728

@@ -127,7 +128,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) : voi
127128
}
128129
}
129130

130-
private function findNextCase(\PHP_CodeSniffer\Files\File $phpcsFile, int|bool|null $stackPtr, ?int $end = null) : bool|int
131+
private function findNextCase(File $phpcsFile, int|bool|null $stackPtr, ?int $end = null) : bool|int
131132
{
132133
$tokens = $phpcsFile->getTokens();
133134

@@ -145,7 +146,7 @@ private function findNextCase(\PHP_CodeSniffer\Files\File $phpcsFile, int|bool|n
145146
return $stackPtr;
146147
}
147148

148-
private function getEndOfLineBefore(\PHP_CodeSniffer\Files\File $phpcsFile, int $pointer) : int
149+
private function getEndOfLineBefore(File $phpcsFile, int $pointer) : int
149150
{
150151
$tokens = $phpcsFile->getTokens();
151152

@@ -193,7 +194,7 @@ private function getEndOfLineBefore(\PHP_CodeSniffer\Files\File $phpcsFile, int
193194
return $endOfLineBefore;
194195
}
195196

196-
private function getIndentation(\PHP_CodeSniffer\Files\File $phpcsFile, int $endOfLinePointer) : string
197+
private function getIndentation(File $phpcsFile, int $endOfLinePointer) : string
197198
{
198199
$pointerAfterWhitespace = TokenHelper::findNextExcluding($phpcsFile, \T_WHITESPACE, $endOfLinePointer + 1);
199200
$actualIndentation = TokenHelper::getContent($phpcsFile, $endOfLinePointer + 1, $pointerAfterWhitespace - 1);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /