Fix problems with PHP joining

This limits the joining only to when the cursor is on the "main" line,
to avoid ambiguity.