@@ -42,7 +42,7 @@ public function process(File $phpcsFile, $stackPtr)
42
42
$ comment = trim ($ tokens [$ stackPtr ]['content ' ]);
43
43
44
44
// Hash comments are not allowed.
45
- if ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '# ' )
45
+ if ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '# ' )
46
46
{
47
47
$ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '# ... ' );
48
48
@@ -57,21 +57,21 @@ public function process(File $phpcsFile, $stackPtr)
57
57
$ phpcsFile ->fixer ->replaceToken ($ stackPtr , $ newComment );
58
58
}
59
59
}
60
- elseif ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '/ ' )
60
+ elseif ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '/ ' )
61
61
{
62
62
$ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '// ... ' );
63
63
$ singleLine = true ;
64
64
}
65
- elseif ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '* ' )
65
+ elseif ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '* ' )
66
66
{
67
67
$ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '/* ... */ ' );
68
68
}
69
69
70
70
// Always have a space between // and the start of the comment text.
71
71
// The exception to this is if the preceding line consists of a single open bracket.
72
- if ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '/ ' && isset ($ tokens [$ stackPtr ]['content ' ]{ 2 } )
73
- && $ tokens [$ stackPtr ]['content ' ]{ 2 } !== ' ' && isset ($ tokens [($ stackPtr - 1 )]['content ' ]{ 0 } )
74
- && $ tokens [($ stackPtr - 1 )]['content ' ]{ 0 } !== '} '
72
+ if ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '/ ' && isset ($ tokens [$ stackPtr ]['content ' ][ 2 ] )
73
+ && $ tokens [$ stackPtr ]['content ' ][ 2 ] !== ' ' && isset ($ tokens [($ stackPtr - 1 )]['content ' ][ 0 ] )
74
+ && $ tokens [($ stackPtr - 1 )]['content ' ][ 0 ] !== '} '
75
75
)
76
76
{
77
77
$ error = 'Missing space between the // and the start of the comment text. ' ;
@@ -91,23 +91,23 @@ public function process(File $phpcsFile, $stackPtr)
91
91
* the line is a continuation of a complete sentence,
92
92
* the term is code and is case sensitive.(@todo)
93
93
*/
94
- if (($ singleLine === true && isset($ tokens [$ stackPtr ]['content ' ]{ 3 } ) && $ tokens [$ stackPtr ]['content ' ]{ 2 } === ' '
95
- && $ tokens [$ stackPtr ]['content ' ]{ 3 } !== strtoupper($ tokens [$ stackPtr ]['content ' ]{ 3 } )) || (isset($ comment{ 2 } ) && $ comment{ 0 } === '* '
96
- && $ comment{ 1 } === ' ' && $ comment{ 2 } !== strtoupper ($ comment{ 2 } ))
94
+ if (($ singleLine === true && isset ($ tokens [$ stackPtr ]['content ' ][ 3 ] ) && $ tokens [$ stackPtr ]['content ' ][ 2 ] === ' '
95
+ && $ tokens [$ stackPtr ]['content ' ][ 3 ] !== strtoupper ($ tokens [$ stackPtr ]['content ' ][ 3 ] )) || (isset ($ comment[ 2 ] ) && $ comment[ 0 ] === '* '
96
+ && $ comment[ 1 ] === ' ' && $ comment[ 2 ] !== strtoupper ($ comment[ 2 ] ))
97
97
)
98
98
{
99
99
$ error = 'Comment must start with a capital letter; found "%s" ' ;
100
100
$ previous = $ phpcsFile ->findPrevious (T_COMMENT , $ stackPtr - 1 );
101
101
102
102
if ($ singleLine === true )
103
103
{
104
- $ data = array($ comment{ 3 } );
104
+ $ data = array ($ comment[ 3 ] );
105
105
$ newComment = ltrim ($ tokens [$ stackPtr ]['content ' ], '\// ' );
106
106
$ newComment = '// ' . ucfirst ($ newComment );
107
107
}
108
108
else
109
109
{
110
- $ data = array($ comment{ 2 } );
110
+ $ data = array ($ comment[ 2 ] );
111
111
$ padding = (strlen ($ tokens [$ stackPtr ]['content ' ]) - strlen ($ comment ));
112
112
$ padding = str_repeat ("\t" , $ padding - 2 );
113
113
$ newComment = ltrim ($ comment , '* ' );
@@ -119,7 +119,7 @@ public function process(File $phpcsFile, $stackPtr)
119
119
{
120
120
$ test = trim ($ tokens [$ previous ]['content ' ]);
121
121
122
- if ('. ' === $ test{ (strlen ($ test ) - 1 )} )
122
+ if ('. ' === $ test[ (strlen ($ test ) - 1 )] )
123
123
{
124
124
$ fix = $ phpcsFile ->addFixableError ($ error , $ stackPtr , 'LowerCaseAfterSentenceEnd ' , $ data );
125
125
0 commit comments