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

Range Exception on php scripts with hhvm #3

Closed
otruffer opened this issue Feb 24, 2015 · 5 comments
Closed

Range Exception on php scripts with hhvm #3

otruffer opened this issue Feb 24, 2015 · 5 comments
Labels

Comments

@otruffer
Copy link
Contributor

Hi there

For my project i need to use hhvm as it reduces the building of the model from ~30mins to ~3mins. Everything works fine most of the time. But if i a file gets parsed that starts with:

!/usr/bin/php

@otruffer
Copy link
Contributor Author

otruffer commented Mar 4, 2015

I now have a workaround. But it hits in the nikic/php-parser library.

Index: vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php    (revision )
+++ vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php    (revision )
@@ -140,10 +140,15 @@
                     $symbol = $tokenId >= 0 && $tokenId < $this->tokenToSymbolMapSize
                         ? $this->tokenToSymbol[$tokenId]
                         : $this->invalidSymbol;
                    if ($symbol === $this->invalidSymbol) {
+
+                        //In hhvm (script)files that start with unix annotations like "#!/usr/bin/env php" crashes the lexer and this part. This is a workaround.
+                        if(substr($tokenValue, 0, 2) == "#!") {
+                            continue;
+                        }
+
                         throw new \RangeException(sprintf(
                            'The lexer returned an invalid token (id=%d, value=%s)',
                             $tokenId, $tokenValue
                         ));
                     }

@mamuz
Copy link
Owner

mamuz commented Mar 4, 2015

Hi,

sorry for late answer..a lot of todos on my side ;)
I think its a good approach to ask Nikita Popov (owner of https://github.com/nikic/PHP-Parser) directly for this issue.

BTW: Unix annotations like "#!..." are called shebang (http://en.wikipedia.org/wiki/Shebang_(Unix))

Hopefully i will find time to investigate it, too.

@mamuz mamuz added the question label Mar 4, 2015
@mamuz
Copy link
Owner

mamuz commented Mar 15, 2015

Php-Parser added hashbang support nikic/PHP-Parser@592836c

Waiting for release, after that everything should be fine.

@mamuz
Copy link
Owner

mamuz commented Mar 28, 2015

Hi @otruffer,

latest Release v0.4.1 includes dependency update to phpParser to 1.2.*

Shebang issue under hhvm should be fixed now.

@otruffer
Copy link
Contributor Author

Hi

Thanks a lot for your work!

Cheers
Oskar

@mamuz mamuz closed this as completed Mar 30, 2015
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