@@ -39,7 +39,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
3939 $ comment = trim ($ tokens [$ stackPtr ]['content ' ]);
4040
4141 // Hash comments are not allowed.
42- if ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '# ' )
42+ if ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '# ' )
4343 {
4444 $ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '# ... ' );
4545
@@ -54,21 +54,21 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
5454 $ phpcsFile ->fixer ->replaceToken ($ stackPtr , $ newComment );
5555 }
5656 }
57- elseif ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '/ ' )
57+ elseif ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '/ ' )
5858 {
5959 $ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '// ... ' );
6060 $ singleLine = true ;
6161 }
62- elseif ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '* ' )
62+ elseif ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '* ' )
6363 {
6464 $ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '/* ... */ ' );
6565 }
6666
6767 // Always have a space between // and the start of the comment text.
6868 // 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 ] !== '} '
7272 )
7373 {
7474 $ error = 'Missing space between the // and the start of the comment text. ' ;
@@ -88,23 +88,23 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
8888 * the line is a continuation of a complete sentence,
8989 * the term is code and is case sensitive.(@todo)
9090 */
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 ] ))
9494 )
9595 {
9696 $ error = 'Comment must start with a capital letter; found "%s" ' ;
9797 $ previous = $ phpcsFile ->findPrevious (T_COMMENT , $ stackPtr - 1 );
9898
9999 if ($ singleLine === true )
100100 {
101- $ data = array($ comment{ 3 } );
101+ $ data = array ($ comment[ 3 ] );
102102 $ newComment = ltrim ($ tokens [$ stackPtr ]['content ' ], '\// ' );
103103 $ newComment = '// ' . ucfirst ($ newComment );
104104 }
105105 else
106106 {
107- $ data = array($ comment{ 2 } );
107+ $ data = array ($ comment[ 2 ] );
108108 $ padding = (strlen ($ tokens [$ stackPtr ]['content ' ]) - strlen ($ comment ));
109109 $ padding = str_repeat ("\t" , $ padding - 2 );
110110 $ newComment = ltrim ($ comment , '* ' );
@@ -116,7 +116,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
116116 {
117117 $ test = trim ($ tokens [$ previous ]['content ' ]);
118118
119- if ('. ' === $ test{ (strlen ($ test ) - 1 )} )
119+ if ('. ' === $ test[ (strlen ($ test ) - 1 )] )
120120 {
121121 $ fix = $ phpcsFile ->addFixableError ($ error , $ stackPtr , 'LowerCaseAfterSentenceEnd ' , $ data );
122122
0 commit comments