Skip to content

Commit 1f69b0a

Browse files
committed
Merge branch 'hhvm-hashbang' of https://github.com/legoktm/PHP_CodeSniffer
2 parents 11a2545 + cd309e8 commit 1f69b0a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

CodeSniffer/Tokenizers/PHP.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,27 @@ public function tokenizeString($string, $eolChar='\n')
672672
continue;
673673
}//end if
674674

675+
/*
676+
HHVM 3.5 and 3.6 tokenizes a hashbang like #!/usr/bin/php
677+
as T_HASHANG instead of T_INLINE_HTML,so fix that.
678+
*/
679+
680+
if ($tokenIsArray === true
681+
&& token_name($token[0]) === 'T_HASHBANG'
682+
) {
683+
$finalTokens[$newStackPtr] = array(
684+
'content' => $token[1],
685+
'code' => T_INLINE_HTML,
686+
'type' => 'T_INLINE_HTML',
687+
);
688+
if (PHP_CODESNIFFER_VERBOSITY > 1) {
689+
echo "\t\t* token $stackPtr changed from T_HASHBANG to T_INLINE_HTML".PHP_EOL;
690+
}
691+
692+
$newStackPtr++;
693+
continue;
694+
}//end if
695+
675696
/*
676697
If this token has newlines in its content, split each line up
677698
and create a new token for each line. We do this so it's easier

0 commit comments

Comments
 (0)