Skip to content

Commit

Permalink
Tokenizers/Comment: minor tweaks
Browse files Browse the repository at this point in the history
Girlscouting.

* Remove an unnecessary interim variable.
* Add a comment clarifying certain code.
* Specify the array format in the `@return` tags.
  • Loading branch information
jrfnl committed May 18, 2024
1 parent 252675c commit bef6fff
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Tokenizers/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Comment
* @param string $eolChar The EOL character to use for splitting strings.
* @param int $stackPtr The position of the first token in the file.
*
* @return array
* @return array<int, array<string, string|int|array<int>>>
*/
public function tokenizeString($string, $eolChar, $stackPtr)
{
Expand Down Expand Up @@ -81,6 +81,7 @@ public function tokenizeString($string, $eolChar, $stackPtr)
];

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

Expand Down Expand Up @@ -178,7 +179,7 @@ public function tokenizeString($string, $eolChar, $stackPtr)
* @param int $start The position in the string to start processing.
* @param int $end The position in the string to end processing.
*
* @return array
* @return array<int, array<string, string|int>>
*/
private function processLine($string, $eolChar, $start, $end)
{
Expand Down Expand Up @@ -253,7 +254,7 @@ private function processLine($string, $eolChar, $start, $end)
* @param int $start The position in the string to start processing.
* @param int $end The position in the string to end processing.
*
* @return array|null
* @return array<string, string|int>|null
*/
private function collectWhitespace($string, $start, $end)
{
Expand All @@ -270,14 +271,12 @@ private function collectWhitespace($string, $start, $end)
return null;
}

$token = [
return [
'content' => $space,
'code' => T_DOC_COMMENT_WHITESPACE,
'type' => 'T_DOC_COMMENT_WHITESPACE',
];

return $token;

}//end collectWhitespace()


Expand Down

0 comments on commit bef6fff

Please sign in to comment.