4
4
5
5
namespace InfinityloopCodingStandard \Sniffs \Classes ;
6
6
7
+ use \SlevomatCodingStandard \Helpers \FunctionHelper ;
8
+ use \SlevomatCodingStandard \Helpers \SniffSettingsHelper ;
9
+ use \SlevomatCodingStandard \Helpers \TokenHelper ;
10
+
7
11
class ConstructorPropertyPromotionSpacingSniff implements \PHP_CodeSniffer \Sniffs \Sniff
8
12
{
9
13
public const CONSTRUCTOR_PARAMETER_SAME_LINE = 'ConstructorParametersOnSameLine ' ;
@@ -15,19 +19,19 @@ public function register() : array
15
19
16
20
public function process (\PHP_CodeSniffer \Files \File $ phpcsFile , $ functionPointer ) : void
17
21
{
18
- if (!\ SlevomatCodingStandard \ Helpers \ SniffSettingsHelper::isEnabledByPhpVersion (null , 80000 )) {
22
+ if (!SniffSettingsHelper::isEnabledByPhpVersion (null , 80000 )) {
19
23
return ;
20
24
}
21
25
22
26
$ tokens = $ phpcsFile ->getTokens ();
23
27
24
- $ namePointer = \ SlevomatCodingStandard \ Helpers \ TokenHelper::findNextEffective ($ phpcsFile , $ functionPointer + 1 );
28
+ $ namePointer = TokenHelper::findNextEffective ($ phpcsFile , $ functionPointer + 1 );
25
29
26
30
if (\strtolower ($ tokens [$ namePointer ]['content ' ]) !== '__construct ' ) {
27
31
return ;
28
32
}
29
33
30
- if (\ SlevomatCodingStandard \ Helpers \ FunctionHelper::isAbstract ($ phpcsFile , $ functionPointer )) {
34
+ if (FunctionHelper::isAbstract ($ phpcsFile , $ functionPointer )) {
31
35
return ;
32
36
}
33
37
@@ -40,13 +44,13 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
40
44
$ containsPropertyPromotion = false ;
41
45
42
46
foreach ($ parameterPointers as $ parameterPointer ) {
43
- $ pointerBefore = \ SlevomatCodingStandard \ Helpers \ TokenHelper::findPrevious (
47
+ $ pointerBefore = TokenHelper::findPrevious (
44
48
$ phpcsFile ,
45
49
[\T_COMMA , \T_OPEN_PARENTHESIS ],
46
50
$ parameterPointer - 1 ,
47
51
);
48
52
49
- $ visibilityPointer = \ SlevomatCodingStandard \ Helpers \ TokenHelper::findNextEffective ($ phpcsFile , $ pointerBefore + 1 );
53
+ $ visibilityPointer = TokenHelper::findNextEffective ($ phpcsFile , $ pointerBefore + 1 );
50
54
51
55
if (\in_array ($ tokens [$ visibilityPointer ]['code ' ], \PHP_CodeSniffer \Util \Tokens::$ scopeModifiers , true )) {
52
56
$ containsPropertyPromotion = true ;
@@ -58,7 +62,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
58
62
}
59
63
60
64
if (\count ($ parameterPointers ) === 1 ) {
61
- $ pointerBefore = \ SlevomatCodingStandard \ Helpers \ TokenHelper::findPrevious (
65
+ $ pointerBefore = TokenHelper::findPrevious (
62
66
$ phpcsFile ,
63
67
[\T_COMMA , \T_OPEN_PARENTHESIS ],
64
68
$ parameterPointers [0 ],
@@ -110,7 +114,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $functionPointer
110
114
111
115
$ phpcsFile ->fixer ->beginChangeset ();
112
116
113
- $ pointerBefore = \ SlevomatCodingStandard \ Helpers \ TokenHelper::findPrevious (
117
+ $ pointerBefore = TokenHelper::findPrevious (
114
118
$ phpcsFile ,
115
119
[\T_COMMA , \T_OPEN_PARENTHESIS ],
116
120
$ parameterPointer - 1 ,
@@ -126,7 +130,7 @@ private function getParameterPointers(\PHP_CodeSniffer\Files\File $phpcsFile, in
126
130
{
127
131
$ tokens = $ phpcsFile ->getTokens ();
128
132
129
- return \ SlevomatCodingStandard \ Helpers \ TokenHelper::findNextAll (
133
+ return TokenHelper::findNextAll (
130
134
$ phpcsFile ,
131
135
\T_VARIABLE ,
132
136
$ tokens [$ functionPointer ]['parenthesis_opener ' ] + 1 ,
0 commit comments