Skip to content

Guard against null token after trailing backslash in text role#1333

Open
lacatoire wants to merge 1 commit intophpDocumentor:mainfrom
lacatoire:fix/textrole-null-backslash
Open

Guard against null token after trailing backslash in text role#1333
lacatoire wants to merge 1 commit intophpDocumentor:mainfrom
lacatoire:fix/textrole-null-backslash

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

When a text role candidate is followed by a trailing backslash at the end of the stream (or end of the block), moveNext() leaves $lexer->token as null and the next read on ->value triggers a Warning: Attempt to read property "value" on null.

Bail out of the loop in that case, matching what the other terminal branches already do. The rule then falls through to rollback() and returns null, so the input is simply not interpreted as a text role.

Fixes phpDocumentor/phpDocumentor#4082

When a text role candidate contains a backslash followed by end of
input, moveNext() leaves the lexer token as null and the next read on
->value triggered a 'Attempt to read property "value" on null' warning.

Bail out of the loop in that case, matching the other terminal branches
of the switch. The rule then falls through to rollback() and returns
null, so the input is simply not interpreted as a text role.

Fixes phpDocumentor/phpDocumentor#4082
@lacatoire lacatoire force-pushed the fix/textrole-null-backslash branch from 011b1f4 to d8c00d6 Compare April 14, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning: Attempt to read property "value" on null

1 participant