@@ -42,7 +42,7 @@ public function process(File $phpcsFile, $stackPtr)
4242 $ comment = trim ($ tokens [$ stackPtr ]['content ' ]);
4343
4444 // Hash comments are not allowed.
45- if ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '# ' )
45+ if ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '# ' )
4646 {
4747 $ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '# ... ' );
4848
@@ -57,21 +57,21 @@ public function process(File $phpcsFile, $stackPtr)
5757 $ phpcsFile ->fixer ->replaceToken ($ stackPtr , $ newComment );
5858 }
5959 }
60- elseif ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '/ ' )
60+ elseif ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '/ ' )
6161 {
6262 $ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '// ... ' );
6363 $ singleLine = true ;
6464 }
65- elseif ($ tokens [$ stackPtr ]['content ' ]{ 0 } === '/ ' && $ tokens [$ stackPtr ]['content ' ]{ 1 } === '* ' )
65+ elseif ($ tokens [$ stackPtr ]['content ' ][ 0 ] === '/ ' && $ tokens [$ stackPtr ]['content ' ][ 1 ] === '* ' )
6666 {
6767 $ phpcsFile ->recordMetric ($ stackPtr , 'Inline comment style ' , '/* ... */ ' );
6868 }
6969
7070 // Always have a space between // and the start of the comment text.
7171 // 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 ] !== '} '
7575 )
7676 {
7777 $ error = 'Missing space between the // and the start of the comment text. ' ;
@@ -91,23 +91,23 @@ public function process(File $phpcsFile, $stackPtr)
9191 * the line is a continuation of a complete sentence,
9292 * the term is code and is case sensitive.(@todo)
9393 */
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 ] ))
9797 )
9898 {
9999 $ error = 'Comment must start with a capital letter; found "%s" ' ;
100100 $ previous = $ phpcsFile ->findPrevious (T_COMMENT , $ stackPtr - 1 );
101101
102102 if ($ singleLine === true )
103103 {
104- $ data = array($ comment{ 3 } );
104+ $ data = array ($ comment[ 3 ] );
105105 $ newComment = ltrim ($ tokens [$ stackPtr ]['content ' ], '\// ' );
106106 $ newComment = '// ' . ucfirst ($ newComment );
107107 }
108108 else
109109 {
110- $ data = array($ comment{ 2 } );
110+ $ data = array ($ comment[ 2 ] );
111111 $ padding = (strlen ($ tokens [$ stackPtr ]['content ' ]) - strlen ($ comment ));
112112 $ padding = str_repeat ("\t" , $ padding - 2 );
113113 $ newComment = ltrim ($ comment , '* ' );
@@ -119,7 +119,7 @@ public function process(File $phpcsFile, $stackPtr)
119119 {
120120 $ test = trim ($ tokens [$ previous ]['content ' ]);
121121
122- if ('. ' === $ test{ (strlen ($ test ) - 1 )} )
122+ if ('. ' === $ test[ (strlen ($ test ) - 1 )] )
123123 {
124124 $ fix = $ phpcsFile ->addFixableError ($ error , $ stackPtr , 'LowerCaseAfterSentenceEnd ' , $ data );
125125
0 commit comments