Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding#2988
Undefined offset in Squiz.Strings.ConcatenationSpacing during live coding#2988gsherwood merged 2 commits intosquizlabs:masterfrom thiemowmde:patch-1
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.
jrfnl
left a comment
There was a problem hiding this comment.
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.