Skip to content

[BetterPhpDocParser] Check for closing brace in text content (#8977)#6670

Merged
samsonasik merged 1 commit intorectorphp:mainfrom
andrewnicols:rector8977
Jan 16, 2025
Merged

[BetterPhpDocParser] Check for closing brace in text content (#8977)#6670
samsonasik merged 1 commit intorectorphp:mainfrom
andrewnicols:rector8977

Conversation

@andrewnicols
Copy link
Copy Markdown
Contributor

@andrewnicols andrewnicols commented Jan 15, 2025

This is a possibel fix for #8977, but it may not be the correct fix.

I feel that the bug is probably the phpstan Lexer as I would expect the closing brace to be picked up as its own token.

Dumping the regex used by the Lexer into regex101 shows that the lexer only tokenises the closing brace if there is whitespace before it, which is not necessarily the case for inline doc tags:
https://regex101.com/r/4TPY7V/2

Closes rectorphp/rector#8977

@TomasVotruba
Copy link
Copy Markdown
Member

Wow, you've found a way to fix it! That's great

Could you add test fixture from the phpunit one, so we can see if it's passing?
Just copy e.g. this directory and replace the rule in config:
https://github.com/rectorphp/rector-src/tree/main/tests/Issues/ChangeSwitchTernary

@andrewnicols
Copy link
Copy Markdown
Contributor Author

Sure thing - I've amended the commit to add this test (and confirmed it was failing before the patch).

@samsonasik
Copy link
Copy Markdown
Member

Let's give it a try, thank you @andrewnicols

@samsonasik samsonasik merged commit 6085713 into rectorphp:main Jan 16, 2025
@andrewnicols andrewnicols deleted the rector8977 branch January 16, 2025 00:13
@TomasVotruba
Copy link
Copy Markdown
Member

Looks great, thank you @andrewnicols 🙏

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BetterPhpDocParser does not handle inline tags

3 participants