Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 24 additions & 1 deletion src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,35 @@ public function parseCharacter($bIsForIdentifier)
}

/**
* @return array<int, Comment>|void
* Consumes whitespace and comments and returns a list of comments.
*
* @return list<Comment> 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<Comment> List of comments.
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public function consumeWhiteSpaceWithComments()
{
$aComments = [];
do {
Expand Down