Skip to content

[CLEANUP] Avoid Hungarian notation for stopCharacters #1124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,27 @@ public function isEnd(): bool
}

/**
* @param array<array-key, string>|string $aEnd
* @param array<array-key, string>|string $stopCharacters
* @param string $bIncludeEnd
* @param string $consumeEnd
* @param array<int, Comment> $comments
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, array &$comments = []): string
{
$aEnd = \is_array($aEnd) ? $aEnd : [$aEnd];
public function consumeUntil(
$stopCharacters,
$bIncludeEnd = false,
$consumeEnd = false,
array &$comments = []
): string {
$stopCharacters = \is_array($stopCharacters) ? $stopCharacters : [$stopCharacters];
$out = '';
$start = $this->currentPosition;

while (!$this->isEnd()) {
$char = $this->consume(1);
if (\in_array($char, $aEnd, true)) {
if (\in_array($char, $stopCharacters, true)) {
if ($bIncludeEnd) {
$out .= $char;
} elseif (!$consumeEnd) {
Expand All @@ -364,13 +368,13 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a
}
}

if (\in_array(self::EOF, $aEnd, true)) {
if (\in_array(self::EOF, $stopCharacters, true)) {
return $out;
}

$this->currentPosition = $start;
throw new UnexpectedEOFException(
'One of ("' . \implode('","', $aEnd) . '")',
'One of ("' . \implode('","', $stopCharacters) . '")',
$this->peek(5),
'search',
$this->lineNumber
Expand Down