Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Shouldn't use ReflectionParameter::hasType in case of running on HHVM #289

Closed
wants to merge 1 commit into from
Closed

Shouldn't use ReflectionParameter::hasType in case of running on HHVM #289

wants to merge 1 commit into from

Conversation

slashmili
Copy link

MockObject_Generator uses ReflectionParameter to extract the methods
information. Because ReflectionParameter can extract
the correct method type, it could possibly extracts Vector<Pair<string, string>>
as the type and then later tries to eval the generated code
with correct type. However since eval gets triggered from
MockObject_Generator in php and this syntax is not valid for PHP, the
test fails with syntax error

…288

MockObject_Generator uses ReflectionParameter to extract the methods
information. Because ReflectionParameter can extract
the correct method type, it could possibly extracts Vector<Pair<string, string>>
as the type and then later tries to eval the generated code
with correct type. However since eval gets triggered from
MockObject_Generator in php and this syntax is not valid for HHVM, the
test fails with syntax error
@nicolas-grekas
Copy link
Contributor

This will break contracts specified by interfaces, isn't it? If yes, then we need to be more clever...
Personally, I hit this issue when mocking the internal Memcache class.
What class are you mocking? A userland one coded in hack or an internal one?

@slashmili
Copy link
Author

I am testing userland hacklang code. The class is like:

class Foo
{
    public function bar(Vector<Pair<string, string>> $keyValues) {
    }
}

This will break contracts specified by interfaces, isn't it?

As you might already know, If you want to test a hacklang class in PHPUnit tests, the file should be in partial mode. So HHVM doesn't complain if the bar interface is like public function bar(\HH\Vector $keyValues)

@slashmili
Copy link
Author

Could someone provide a guide or merge this PL?

Without this change PHPUnit doesn't support HHVM 3.10 and above

@slashmili slashmili closed this Oct 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants