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

Unhelpful "Closing delimiter foo not found" message #142

Open
mbanck opened this issue Dec 8, 2017 · 3 comments
Open

Unhelpful "Closing delimiter foo not found" message #142

mbanck opened this issue Dec 8, 2017 · 3 comments

Comments

@mbanck
Copy link

mbanck commented Dec 8, 2017

I'm getting the above message on a file, but it doesn't tell me which line or any context. Is this some internal error, or a possibly a legit problem (php -l on the file says "no syntax errors detected"). If the former, I think php7cc should print out additional information so that the offending part can be easily identified.

@mbanck
Copy link
Author

mbanck commented Dec 8, 2017

Ok, so by manually bisecting the file I figured out it is this line:

$url = preg_replace('s/^internal:/', '', $url);

which makes sense, as it complains about s as delimiter. AIUI, the 's' is a PCRE modifier (see http://php.net/manual/en/reference.pcre.pattern.modifiers.php), is this a legit error from php7cc or a false positive?

@sstalle
Copy link
Owner

sstalle commented Dec 10, 2017

Seems like this is a legit error. I tried running your code on PHP 7.0.24 and got:

Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /var/app/test.php on line 4

Although you are right that s is a valid modifier, I don't think modifiers are allowed before the opening delimiter. You probably have to move s to the end of the regexp like this: '/^internal:/s'.

@mbanck
Copy link
Author

mbanck commented Dec 10, 2017

OK, right, I have changed the code in the meantime accordingly.

However, I still think php7cc should be more informative in this case, and report a line number e.g.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants