Skip to content

[CLEANUP] Fix some type annotations in ParserState #1130

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 2 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
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
24 changes: 0 additions & 24 deletions config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -102,36 +102,12 @@ parameters:
count: 2
path: ../src/CSSList/KeyFrame.php

-
message: '#^Default value of the parameter \#2 \$bIncludeEnd \(false\) of method Sabberworm\\CSS\\Parsing\\ParserState\:\:consumeUntil\(\) is incompatible with type string\.$#'
identifier: parameter.defaultValue
count: 1
path: ../src/Parsing/ParserState.php

-
message: '#^Default value of the parameter \#3 \$consumeEnd \(false\) of method Sabberworm\\CSS\\Parsing\\ParserState\:\:consumeUntil\(\) is incompatible with type string\.$#'
identifier: parameter.defaultValue
count: 1
path: ../src/Parsing/ParserState.php

-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
count: 1
path: ../src/Parsing/ParserState.php

-
message: '#^Only booleans are allowed in a negated boolean, string given\.$#'
identifier: booleanNot.exprNotBoolean
count: 1
path: ../src/Parsing/ParserState.php

-
message: '#^Only booleans are allowed in an if condition, string given\.$#'
identifier: if.condNotBoolean
count: 1
path: ../src/Parsing/ParserState.php

-
message: '#^PHPDoc tag @return with type array\<int, Sabberworm\\CSS\\Comment\\Comment\>\|void is not subtype of native type array\.$#'
identifier: return.phpDocType
Expand Down
8 changes: 4 additions & 4 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,16 @@ public function isEnd(): bool

/**
* @param array<array-key, string>|string $stopCharacters
* @param string $bIncludeEnd
* @param string $consumeEnd
* @param bool $includeEnd
* @param bool $consumeEnd
* @param array<int, Comment> $comments
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public function consumeUntil(
$stopCharacters,
$bIncludeEnd = false,
$includeEnd = false,
$consumeEnd = false,
array &$comments = []
): string {
Expand All @@ -355,7 +355,7 @@ public function consumeUntil(
while (!$this->isEnd()) {
$character = $this->consume(1);
if (\in_array($character, $stopCharacters, true)) {
if ($bIncludeEnd) {
if ($includeEnd) {
$consumedCharacters .= $character;
} elseif (!$consumeEnd) {
$this->currentPosition -= $this->strlen($character);
Expand Down