So, I'm kind of stumped by this one, and I'm unable to find many other folks experiencing it.

I'm extending the "largo" theme for a site we're getting ready to launch, and am working within the child theme. The issue is that frequently (not always) when I open a file in PHPStorm to edit it, after deploying it to vagrant, I get an error like:

Parse error: syntax error, unexpected '';' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in /srv/www/sitename/public_html/wp-content/themes/largo-child/inc/post-tags.php on line 413

To clarify - it isn't always this specific error, but some unexpected character.

Adding a closing PHP tag fixes it, at which point I can clear cache, remove the closing PHP tag, and all seems well (until it happens again). This was happening just with the wp-config.php file initially, so I thought there might be a hidden character in that file or something similar. Now that I'm moving out and building out other parts of the theme, this is happening somewhat consistently across the codebase.

The file in question has nothing odd in it, and is unchanged. Here's the end of the file where the error is thrown (for completeness) - but I'm guessing this isn't where the issue lies. Here is the offending line 413 (line numbers added in parens):

     * Output largo_edited_date() on the single post template
     * This is disabled in Largo by default. To add it to your child theme, paste in this:
     *     #add_action( 'largo_after_hero', 'largo_after_hero_largo_edited_date', 5 );
     * @since 0.5.5
     * @action largo_after_hero
     * @uses largo_edited_date
     * @link https://github.com/INN/Largo/issues/1341
(406)    function largo_after_hero_largo_edited_date() {
(407)       if ( largo_post_was_updated() ) {
(408)           echo '<div class="entry-content clearfix">';
(409)           largo_edited_date();
(410)           echo '</div>';
(411)       }
(412)    }

It also seems like it can be reliably fixed by copying/pasting the contents of the file out into sublime, and then pasting them back in - which makes me wonder if this is something being added in by PHPStorm when I open a file?

Grateful for any help or guidance you all can suggest - thanks in advance.

** edited to add line numbers to above example **

  • Could you upload a screenshot of the line 413 and of the code it seems to be getting an error from? (From the console on the browser) – Jesse Jun 8 at 3:45
  • The code snippet above is the end of that file (line 413), but I can add a screenshot as well if that is helpful. I'll also better label the snippet in case it just wasn't clear that the offending code is included. – slothluvchunk Jun 8 at 4:12
  • I believe there is something before that line that is causing the issue to seem like it appears on the last line. What is the code before? – Jesse Jun 8 at 5:20
  • @Jesse - It's happening across the codebase in multiple files, all of which are totally fine if copy/pasted into a text editor and back (without changing anything), as well as being fixed immediately by adding in a closing PHP tag, so I don't think the issue is in the visible file contents at all. In fact - I can remove all logic from the file and still have the same error (though the "unexpected" string changes). I think this has to do with something not visible - (ex: line endings, though I think I've accounted for those). If I open wp-config, the same will happen with that file. – slothluvchunk Jun 8 at 5:32
  • Hmm, sounds very odd indeed. I use Sublime to do all my code editing and have never had any issues. (Except for the odd mistakenly added commas or braces haha) I hope you can figure out the issue you are experiencing, as I do not believe I can help in this situation. Happy coding! – Jesse Jun 8 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.