Closed otruffer closed 9 years ago
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
));
}
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.
Php-Parser added hashbang support https://github.com/nikic/PHP-Parser/commit/592836c4dc9ca96e8843ed96fd1cac82a74c4df1
Waiting for release, after that everything should be fine.
Hi @otruffer,
latest Release v0.4.1 includes dependency update to phpParser to 1.2.*
Shebang issue under hhvm should be fixed now.
Hi
Thanks a lot for your work!
Cheers Oskar
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
<?php [...]
Then i get the following Exception:
Notice: Undefined index: 438 in /home/otruffer/dicto/bin/tools/phpda/vendor/nikic/php-parser/lib/PhpParser/Lexer.php on line 121
Notice: Undefined index: in /home/otruffer/dicto/bin/tools/phpda/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 141
[RangeException]
The lexer returned an invalid token (id=0, value=#!/usr/bin/php
)
Note that it only happens if I run the analyzing script with hhvm. Any ideas on how to fix this are greatly appreciated!