Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Class undefined: PHP_Token_ASYNC #48

Closed
doublecompile opened this issue Jul 2, 2015 · 2 comments
Closed

Class undefined: PHP_Token_ASYNC #48

doublecompile opened this issue Jul 2, 2015 · 2 comments

Comments

@doublecompile
Copy link

I have unit tests for Hack classes that use the async keyword. For example:

<?hh
class Foobar
{
    public async function something(Foo $foo) : Awaitable<Bar>
    {
        await SleepWaitHandle::create(1000);
        return new Bar();
    }
}

When generating code coverage information for classes with the async keyword, an exception is thrown:

Fatal error: Class undefined: PHP_Token_ASYNC in /home/…/vendor/phpunit/php-token-stream/src/Token/Stream.php on line 184

Version Info

  • HHVM 3.7.2
  • PHPUnit 4.7.5
  • PHP_TokenStream 1.4.3

Suggested Fix

My guess is all that's needed is to add the following to src/Token.php.

class PHP_Token_ASYNC extends PHP_Token {}
class PHP_Token_AWAIT extends PHP_Token {}
@sebastianbergmann
Copy link
Owner

@doublecompile
Copy link
Author

@sebastianbergmann Hey, thanks for the quick reply, Sebastian.

I'm not sure why there aren't constants for these two keywords. I do know that when I manually added…

class PHP_Token_ASYNC extends PHP_Token {}
class PHP_Token_AWAIT extends PHP_Token {}

…everything works as expected!

I'd be glad to send a pull request if it makes things easier.

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

No branches or pull requests

2 participants