Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

andrewnicols
Copy link
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
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
Contributor Author

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

@samsonasik
Copy link
Member

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

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

Looks great, thank you @andrewnicols 🙏

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.

BetterPhpDocParser does not handle inline tags
3 participants