@@ -19,35 +19,35 @@ class Comment
1919 /**
2020 * Splits a single doc block comment token up into something that can be easily iterated over.
2121 *
22- * @param string $string The doc block comment string to parse.
22+ * @param string $comment The doc block comment string to parse.
2323 * @param string $eolChar The EOL character to use for splitting strings.
2424 * @param int $stackPtr The position of the token in the "new"/final token stream.
2525 *
2626 * @return array<int, array<string, string|int|array<int>>>
2727 */
28- public function tokenizeString ($ string , $ eolChar , $ stackPtr )
28+ public function tokenizeString ($ comment , $ eolChar , $ stackPtr )
2929 {
3030 if (PHP_CODESNIFFER_VERBOSITY > 1 ) {
3131 StatusWriter::write ('*** START COMMENT TOKENIZING *** ' , 2 );
3232 }
3333
3434 $ tokens = [];
35- $ numChars = strlen ($ string );
35+ $ numChars = strlen ($ comment );
3636
3737 /*
3838 Doc block comments start with /*, but typically contain an
3939 extra star when they are used for function and class comments.
4040 */
4141
42- $ char = ($ numChars - strlen (ltrim ($ string , '/* ' )));
43- $ lastChars = substr ($ string , -2 );
42+ $ char = ($ numChars - strlen (ltrim ($ comment , '/* ' )));
43+ $ lastChars = substr ($ comment , -2 );
4444 if ($ char === $ numChars && $ lastChars === '*/ ' ) {
4545 // Edge case: docblock without whitespace or contents.
46- $ openTag = substr ($ string , 0 , -2 );
47- $ string = $ lastChars ;
46+ $ openTag = substr ($ comment , 0 , -2 );
47+ $ comment = $ lastChars ;
4848 } else {
49- $ openTag = substr ($ string , 0 , $ char );
50- $ string = ltrim ($ string , '/* ' );
49+ $ openTag = substr ($ comment , 0 , $ char );
50+ $ comment = ltrim ($ comment , '/* ' );
5151 }
5252
5353 $ tokens [$ stackPtr ] = [
@@ -73,7 +73,7 @@ public function tokenizeString($string, $eolChar, $stackPtr)
7373 */
7474
7575 $ closeTag = [
76- 'content ' => substr ($ string , strlen (rtrim ($ string , '/* ' ))),
76+ 'content ' => substr ($ comment , strlen (rtrim ($ comment , '/* ' ))),
7777 'code ' => T_DOC_COMMENT_CLOSE_TAG ,
7878 'type ' => 'T_DOC_COMMENT_CLOSE_TAG ' ,
7979 'comment_opener ' => $ openPtr ,
@@ -84,7 +84,7 @@ public function tokenizeString($string, $eolChar, $stackPtr)
8484 $ closeTag ['content ' ] = '' ;
8585 }
8686
87- $ string = rtrim ($ string , '/* ' );
87+ $ string = rtrim ($ comment , '/* ' );
8888
8989 /*
9090 Process each line of the comment.
@@ -181,32 +181,32 @@ public function tokenizeString($string, $eolChar, $stackPtr)
181181 /**
182182 * Process a single line of a comment.
183183 *
184- * @param string $string The comment string being tokenized.
184+ * @param string $comment The comment string being tokenized.
185185 * @param string $eolChar The EOL character to use for splitting strings.
186186 * @param int $start The position in the string to start processing.
187187 * @param int $end The position in the string to end processing.
188188 *
189189 * @return array<int, array<string, string|int>>
190190 */
191- private function processLine ($ string , $ eolChar , $ start , $ end )
191+ private function processLine ($ comment , $ eolChar , $ start , $ end )
192192 {
193193 $ tokens = [];
194194
195195 // Collect content padding.
196- $ space = $ this ->collectWhitespace ($ string , $ start , $ end );
196+ $ space = $ this ->collectWhitespace ($ comment , $ start , $ end );
197197 if ($ space !== null ) {
198198 $ tokens [] = $ space ;
199199 $ start += strlen ($ space ['content ' ]);
200200 }
201201
202- if (isset ($ string [$ start ]) === false ) {
202+ if (isset ($ comment [$ start ]) === false ) {
203203 return $ tokens ;
204204 }
205205
206- if ($ string [$ start ] === '@ ' ) {
206+ if ($ comment [$ start ] === '@ ' ) {
207207 // The content up until the first whitespace is the tag name.
208208 $ matches = [];
209- preg_match ('/@[^\s]+/ ' , $ string , $ matches , 0 , $ start );
209+ preg_match ('/@[^\s]+/ ' , $ comment , $ matches , 0 , $ start );
210210 if (isset ($ matches [0 ]) === true
211211 && substr (strtolower ($ matches [0 ]), 0 , 7 ) !== '@phpcs: '
212212 ) {
@@ -219,7 +219,7 @@ private function processLine($string, $eolChar, $start, $end)
219219 ];
220220
221221 // Then there will be some whitespace.
222- $ space = $ this ->collectWhitespace ($ string , $ start , $ end );
222+ $ space = $ this ->collectWhitespace ($ comment , $ start , $ end );
223223 if ($ space !== null ) {
224224 $ tokens [] = $ space ;
225225 $ start += strlen ($ space ['content ' ]);
@@ -228,22 +228,22 @@ private function processLine($string, $eolChar, $start, $end)
228228 }//end if
229229
230230 // Process the rest of the line.
231- $ eol = strpos ($ string , $ eolChar , $ start );
231+ $ eol = strpos ($ comment , $ eolChar , $ start );
232232 if ($ eol === false ) {
233233 $ eol = $ end ;
234234 }
235235
236236 if ($ eol > $ start ) {
237237 $ tokens [] = [
238- 'content ' => substr ($ string , $ start , ($ eol - $ start )),
238+ 'content ' => substr ($ comment , $ start , ($ eol - $ start )),
239239 'code ' => T_DOC_COMMENT_STRING ,
240240 'type ' => 'T_DOC_COMMENT_STRING ' ,
241241 ];
242242 }
243243
244244 if ($ eol !== $ end ) {
245245 $ tokens [] = [
246- 'content ' => substr ($ string , $ eol , strlen ($ eolChar )),
246+ 'content ' => substr ($ comment , $ eol , strlen ($ eolChar )),
247247 'code ' => T_DOC_COMMENT_WHITESPACE ,
248248 'type ' => 'T_DOC_COMMENT_WHITESPACE ' ,
249249 ];
@@ -257,21 +257,21 @@ private function processLine($string, $eolChar, $start, $end)
257257 /**
258258 * Collect consecutive whitespace into a single token.
259259 *
260- * @param string $string The comment string being tokenized.
261- * @param int $start The position in the string to start processing.
262- * @param int $end The position in the string to end processing.
260+ * @param string $comment The comment string being tokenized.
261+ * @param int $start The position in the string to start processing.
262+ * @param int $end The position in the string to end processing.
263263 *
264264 * @return array<string, string|int>|null
265265 */
266- private function collectWhitespace ($ string , $ start , $ end )
266+ private function collectWhitespace ($ comment , $ start , $ end )
267267 {
268268 $ space = '' ;
269269 for ($ start ; $ start < $ end ; $ start ++) {
270- if ($ string [$ start ] !== ' ' && $ string [$ start ] !== "\t" ) {
270+ if ($ comment [$ start ] !== ' ' && $ comment [$ start ] !== "\t" ) {
271271 break ;
272272 }
273273
274- $ space .= $ string [$ start ];
274+ $ space .= $ comment [$ start ];
275275 }
276276
277277 if ($ space === '' ) {
0 commit comments