New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mock generated method signature with callable type hint #210

Merged
merged 5 commits into from May 6, 2013

Conversation

Projects
None yet
2 participants
@adriensamson
Contributor

adriensamson commented Apr 29, 2013

This PR fixes the generated mock class when one of its methods has a 'callable' type hint.

@mageekguy

This comment has been minimized.

Show comment
Hide comment
@mageekguy

mageekguy Apr 29, 2013

Contributor

Please add the unit test.

Contributor

mageekguy commented Apr 29, 2013

Please add the unit test.

@adriensamson

This comment has been minimized.

Show comment
Hide comment
@adriensamson

adriensamson Apr 29, 2013

Contributor

Done.

Contributor

adriensamson commented Apr 29, 2013

Done.

@mageekguy

This comment has been minimized.

Show comment
Hide comment
@mageekguy

mageekguy Apr 29, 2013

Contributor

I think that your test failed with PHP 5.3 because reflectionMethod::isCallable() does not exist with this version.

Contributor

mageekguy commented Apr 29, 2013

I think that your test failed with PHP 5.3 because reflectionMethod::isCallable() does not exist with this version.

@adriensamson

This comment has been minimized.

Show comment
Hide comment
@adriensamson

adriensamson Apr 30, 2013

Contributor

Yes. That's why I added a method_exists call in the generator and skipped the test for 5.3

Contributor

adriensamson commented Apr 30, 2013

Yes. That's why I added a method_exists call in the generator and skipped the test for 5.3

@mageekguy

This comment has been minimized.

Show comment
Hide comment
@mageekguy

mageekguy Apr 30, 2013

Contributor

Oh sorry, i have don't see the annotation in the test (note for later: do not review PR at midnight ;)).

Contributor

mageekguy commented Apr 30, 2013

Oh sorry, i have don't see the annotation in the test (note for later: do not review PR at midnight ;)).

Show outdated Hide outdated classes/mock/generator.php
@@ -409,6 +409,10 @@ protected static function getParameterType(\reflectionParameter $parameter)
{
$type = 'array ';
}
elseif (method_exists($parameter, 'isCallable') && $parameter->isCallable() == true)

This comment has been minimized.

@mageekguy

mageekguy Apr 30, 2013

Contributor

Please use switch(true) { case $parameter->isArray(): … instead of if… else if … else.

@mageekguy

mageekguy Apr 30, 2013

Contributor

Please use switch(true) { case $parameter->isArray(): … instead of if… else if … else.

This comment has been minimized.

@adriensamson

adriensamson May 2, 2013

Contributor

Fixed

@adriensamson

adriensamson May 2, 2013

Contributor

Fixed

mageekguy added a commit that referenced this pull request May 6, 2013

Merge pull request #210 from adriensamson/fix-mock-callable
Add callable type hint management, thanks to @adriensamson.

@mageekguy mageekguy merged commit 0ef1ea9 into atoum:master May 6, 2013

1 check passed

default The Travis build passed
Details

@adriensamson adriensamson deleted the adriensamson:fix-mock-callable branch May 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment