Skip to content

[TASK] Have comsumeWhiteSpace() return the consumed - #1477

Merged
oliverklee merged 2 commits into
mainfrom
refactor/consumewhitespace
Jan 24, 2026
Merged

[TASK] Have comsumeWhiteSpace() return the consumed#1477
oliverklee merged 2 commits into
mainfrom
refactor/consumewhitespace

Conversation

@JakeQZ

@JakeQZ JakeQZ commented Jan 23, 2026

Copy link
Copy Markdown
Collaborator

Instead, have the comments array passed by reference to be appended to. This avoids various methods having to do an array_merge. Also, knowing if any whitespace was consumed will be needed for #1471.

@JakeQZ JakeQZ self-assigned this Jan 23, 2026
@JakeQZ JakeQZ added the refactor For PRs that refactor code without changing functionality label Jan 23, 2026
@JakeQZ
JakeQZ marked this pull request as draft January 23, 2026 19:29
@JakeQZ
JakeQZ force-pushed the refactor/consumewhitespace branch from 98780e0 to c8662b8 Compare January 23, 2026 22:55
@coveralls

coveralls commented Jan 23, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 71.329% (+0.6%) from 70.738%
when pulling 170b373 on refactor/consumewhitespace
into 21bb0eb on main.

@JakeQZ
JakeQZ force-pushed the refactor/consumewhitespace branch 2 times, most recently from 954a108 to 299c2ea Compare January 24, 2026 01:37
Comment thread src/Parsing/ParserState.php
@JakeQZ
JakeQZ force-pushed the refactor/consumewhitespace branch from 299c2ea to aae0448 Compare January 24, 2026 02:11
@JakeQZ

JakeQZ commented Jan 24, 2026

Copy link
Copy Markdown
Collaborator Author

I hope David Gilmour will appreciate this.

@JakeQZ
JakeQZ requested a review from oliverklee January 24, 2026 02:36
@JakeQZ
JakeQZ marked this pull request as ready for review January 24, 2026 02:36
Instead, have the comments array passed by reference to be appended to.
This avoids various methods having to do an `array_merge`.  Also, knowing if
any whitespace was consumed will be needed for #1471.
@JakeQZ
JakeQZ force-pushed the refactor/consumewhitespace branch from aae0448 to bf1bff3 Compare January 24, 2026 02:39
@oliverklee

Copy link
Copy Markdown
Collaborator

I hope David Gilmour will appreciate this.

I don't understand the connection to this PR. 😢 Can you help me out?

@oliverklee oliverklee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good code-wise. Maybe we can add some human-readable description explaining how the method works.

Comment thread src/Parsing/ParserState.php
Comment thread tests/Unit/Parsing/ParserStateTest.php
Add a test to confirm non-whitespace is not consumed.
Tighten up a type annotation.
@JakeQZ

JakeQZ commented Jan 24, 2026

Copy link
Copy Markdown
Collaborator Author

Maybe we can add some human-readable description explaining how the method works.

I've added some description to the DocBlock for the method. I've also added a test to confirm non-whitespace is not consumed, and tightened up a type annotation.

@JakeQZ
JakeQZ requested a review from oliverklee January 24, 2026 15:06
@JakeQZ

JakeQZ commented Jan 24, 2026

Copy link
Copy Markdown
Collaborator Author

I hope David Gilmour will appreciate this.

I don't understand the connection to this PR. 😢 Can you help me out?

While writing the tests, I had Pink Floyd's Wish You Were Hear as an earworm, so when constructing some test comments, I put in some of the lyrics from it. (It's akin to the Hello Dolly example plugin that comes preinstalled with WordPress.)

@oliverklee
oliverklee merged commit 6455dd1 into main Jan 24, 2026
24 checks passed
@oliverklee
oliverklee deleted the refactor/consumewhitespace branch January 24, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor For PRs that refactor code without changing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants