sebastianbergmann / php-token-stream

Wrapper around PHP's tokenizer extension.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Class PHP_Token_TYPELIST_LT is not defined

slashmili opened this issue · comments

Hi,

I was trying to run code coverage for hacklang code and I faced this problem:

php ../fighter/phpunit-alpha.phar -c t/phpunit.xml --coverage-html=cover t/
PHPUnit alpha-2015-01-09 by Sebastian Bergmann and contributors.
Fatal error: Class undefined: PHP_Token_TYPELIST_LT in phar://phpunit-alpha-2015-01-09.phar/php-token-stream/Token/Stream.php on line 185

Are you using hack or something else that adds supports for generics to PHP?

I'm using almost all the new features in Hacklang in my code. Like type, shape, lambda and etc.

Fair enough! Maybe php-token-stream is not a good place to add it.

FYI the coverage got fix for me by creating these classes!

class PHP_Token_TYPELIST_LT extends PHP_Token {}
class PHP_Token_TYPELIST_GT extends PHP_Token {}
class PHP_Token_TYPE extends PHP_Token {}
class PHP_Token_SHAPE extends PHP_Token {}
class PHP_Token_LAMBDA_OP extends PHP_Token {}
class PHP_Token_LAMBDA_CP extends PHP_Token {}
class PHP_Token_LAMBDA_ARROW extends PHP_Token {}

If that works (and those tokens do not require special classes) then send a pull request that adds them to the end of https://github.com/sebastianbergmann/php-token-stream/blob/master/src/Token.php with a Tokens used by Hack comment.

It would be great if you could make sure to add all tokens that Hack has but PHP has not.

/cc @ptarjan @sgolemon

Sure! I just need some time to try all new possible token and provide a sample coverage here to prove it works

I managed to add these classes and was able to pass the test with coverage option (prove sample code and build )

Just for the record the generated code coverage still is not correct and doesn't mark some obvious path. I believe we need to look back into sebastianbergmann/phpunit#1575 or maybe open an issue in hhvm repo for the fix.

I close this Issue since it's was merged.

👍 Thanks!