-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding #2988
Conversation
This can happen when PHPCS runs on a file that is currently being worked on, but not yet completed. The file might end with a dot. We can not assume there are always 2 more tokens after a dot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @thiemowmde I see what you are trying to do here. I'd like to suggest a change though, and that is to bow out completely when $tokens[($stackPtr + 1)]
isn't set as doing any checking for the space after the concatenation operator if there isn't a next token is futile.
What do you think ?
Nice catch. Indeed, my original proposal would create awkward reports that don't make much sense if the line of code is not even complete. I changed it to don't report anything in such a situation. |
That's not what I intended. The "spacing before" could still be safely reported/fixed in that case. It's only the spacing after where the problem lies. |
There is no separate message for "spacing before". There are only messages that talk about "Concat operator must [not] be surrounded by …". All these messages are confusing when the line of code that ends with something like |
@thiemowmde You're right. Sorry, I was getting confused by the metrics which are recorded separately |
Thanks a lot for this PR |
This can happen when PHPCS runs on a file that is currently being worked on, but not yet completed. The file might end with a dot. We can not assume there are always 2 more tokens after a dot.