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