-
-
Notifications
You must be signed in to change notification settings - Fork 364
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] Use str_starts_with() and str_ends_with() over str_contains() on DoctrineAnnotationDecorator #6671
Conversation
… str_contains() on DoctrineAnnotationDecorator
All checks have passed 🎉 @TomasVotruba I am merging it to have faster feedback to test ;) |
@andrewnicols please test latest |
Alas, it does not. It works for the case where the doc is: * @copyright Example {@link https://example.com} But if there is anything immedaitely after the curly brace, for example a {{.}}: * @copyright Example {@link https://example.com}. Then it no longer works. Changing back to {{str_contains}} gets it back to passing. |
@andrewnicols thank you for verify, I will check. |
…or (rectorphp#6671) The Lexer tokenizes at whitespace and certain other characters such as `.`, and `(`, If none of these tokens are present then the tokens are not split. For example in the string here: ``` @copyright Some Value. Something.({@link https://example.com}). ``` This is tokenised into: ``` '@copyright' ' ' 'Some' ' ' 'Value' '.' ' ' 'Something' .({@link' ' ' 'https' ':' '//example.com}).' ``` Both the open, and close, curly braces may be in the middle of a string and therefore the `str_contains` must be used for these cases.
I've created #6674 with a demo and more tests. |
@andrewnicols you're fast, thank you 👍 |
…or (#6671) (#6674) The Lexer tokenizes at whitespace and certain other characters such as `.`, and `(`, If none of these tokens are present then the tokens are not split. For example in the string here: ``` @copyright Some Value. Something.({@link https://example.com}). ``` This is tokenised into: ``` '@copyright' ' ' 'Some' ' ' 'Value' '.' ' ' 'Something' .({@link' ' ' 'https' ':' '//example.com}).' ``` Both the open, and close, curly braces may be in the middle of a string and therefore the `str_contains` must be used for these cases.
@andrewnicols continue of your PR:
I am thinking that
str_ends_with()
andstr_starts_with()
can be used overstr_contains()
, which seems should only cover start and last over the whole token for more precise check, ensuring it not just part of some "string".