diff --git a/CHANGELOG.md b/CHANGELOG.md index d1837d0b..e4701589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,16 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Added +- Add `ParserState::consumeWhiteSpaceWithComments()` method (#670) + ### Changed +- Redirect `ParserState::consumeWhiteSpace()` to `ParserState::consumeWhiteSpaceWithComments()` (#670) + ### Deprecated +- Deprecate `ParserState::consumeWhiteSpace()` in favor of `ParserState::consumeWhiteSpaceWithComments()` (#670) + ### Removed ### Fixed diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 07578461..3ef9c5f6 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -226,12 +226,35 @@ public function parseCharacter($bIsForIdentifier) } /** - * @return array|void + * Consumes whitespace and comments and returns a list of comments. + * + * @return list List of comments. * * @throws UnexpectedEOFException * @throws UnexpectedTokenException + * + * @deprecated From version 9.0.0 onwards this method will be undergo a breaking + * change. This method will no longer consume comments, only whitespace. + * Use `ParserState::consumeWhiteSpaceWithComments` as a replacement if you + * need the former behaviour of consuming whitespace and comments. + * + * @see `ParserState::consumeWhiteSpaceWithComments` for a version that also + * returns comments. */ public function consumeWhiteSpace() + { + return $this->consumeWhiteSpaceWithComments(); + } + + /** + * Consumes whitespace and comments and returns a list of comments. + * + * @return list List of comments. + * + * @throws UnexpectedEOFException + * @throws UnexpectedTokenException + */ + public function consumeWhiteSpaceWithComments() { $aComments = []; do {