Skip to content

Commit 3cecd91

Browse files
committed
Tokenizers/Comment: minor tweaks
Girlscouting. * Remove an unnecessary interim variable. * Add a comment clarifying certain code. * Specify the array format in the `@return` tags.
1 parent f55c412 commit 3cecd91

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Tokenizers/Comment.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Comment
2525
* @param string $eolChar The EOL character to use for splitting strings.
2626
* @param int $stackPtr The position of the first token in the file.
2727
*
28-
* @return array
28+
* @return array<int, array<string, string|int|array<int>>>
2929
*/
3030
public function tokenizeString($string, $eolChar, $stackPtr)
3131
{
@@ -81,6 +81,7 @@ public function tokenizeString($string, $eolChar, $stackPtr)
8181
];
8282

8383
if ($closeTag['content'] === false) {
84+
// In PHP < 8.0 substr() can return `false` instead of always returning a string.
8485
$closeTag['content'] = '';
8586
}
8687

@@ -178,7 +179,7 @@ public function tokenizeString($string, $eolChar, $stackPtr)
178179
* @param int $start The position in the string to start processing.
179180
* @param int $end The position in the string to end processing.
180181
*
181-
* @return array
182+
* @return array<int, array<string, string|int>>
182183
*/
183184
private function processLine($string, $eolChar, $start, $end)
184185
{
@@ -253,7 +254,7 @@ private function processLine($string, $eolChar, $start, $end)
253254
* @param int $start The position in the string to start processing.
254255
* @param int $end The position in the string to end processing.
255256
*
256-
* @return array|null
257+
* @return array<string, string|int>|null
257258
*/
258259
private function collectWhitespace($string, $start, $end)
259260
{
@@ -270,14 +271,12 @@ private function collectWhitespace($string, $start, $end)
270271
return null;
271272
}
272273

273-
$token = [
274+
return [
274275
'content' => $space,
275276
'code' => T_DOC_COMMENT_WHITESPACE,
276277
'type' => 'T_DOC_COMMENT_WHITESPACE',
277278
];
278279

279-
return $token;
280-
281280
}//end collectWhitespace()
282281

283282

0 commit comments

Comments
 (0)