Skip to content
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

[Bug] Empty heredocs/nowdocs lead to Unexpected 'EndOfFile' (P1001) error #3075

Open
miquelfire opened this issue Sep 25, 2024 · 1 comment
Labels

Comments

@miquelfire
Copy link

Describe the bug
I came across this error recently. I used an empty nowdoc to eventually add some SQL code later one (other stuff needed to be done before I wrote it), and after other distractions, when I came back to the code, I saw this error. A php -l file command doesn't report an error with the same code. Only common when someone is going to put in a large string, but outside forces results in them not having the string to put in the heredoc or now doc

To Reproduce
nowdoc

<?php
class Test {
   private string $string = <<<'EOD'
   EOD;
}

heredoc

<?php
class Test {
   private string $string = <<<EOD
   EOD;
}

Expected behavior
There should be no error in this case.

Platform and version
Windows 11
Intelephense 1.12.6

@miquelfire
Copy link
Author

Just after posting, I found the root cause. Just having the end indented is enough to trigger the error:

<?php
   $string = <<<'EOD'
   EOD;

Also, if you found this in a search, this does work:

<?php
   $string = <<<'EOD'

   EOD;

@bmewburn bmewburn added the bug label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants