Skip to content

[WIP] Support for Prophecy #1

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

Closed
wants to merge 4 commits into from
Closed

[WIP] Support for Prophecy #1

wants to merge 4 commits into from

Conversation

Jean85
Copy link
Contributor

@Jean85 Jean85 commented Nov 30, 2017

Reading phpstan/phpstan#134 and wanting to try PHPStan 0.9, I wanted to try to write the extension to make PHPStan and Prophecy work along.

I'm not an expert on PHPStan internals, so I started working on this copypasting from the MockBuilder classes, and I reached a point where the reveal() method is no longer an issue for PHPStan! 🎉

Now, I need to tackle the issues reported when defining the expectation on a mock, and that's a lot trickier!

Scenario:

$mock = $this->prophesize(SUTClass::class);
$mock->methodA(...)
    ->should...()
    ->will...();

Basically you can call on the mock any method of it's base class (ObjectProphecy) but also any method of the mocked class (methodA); the problem is that those methods will accept the same stuff defined bu the original signature OR TokenInterfaces from Prophecy, OR a mix of that.; also, it will return a MethodProphecy every time.

How we should tackle this?

@ondrejmirtes
Copy link
Member

Hi, there's already an extension for that 😊 https://github.com/Jan0707/phpstan-prophecy

Discussed in depth here: phpstan/phpstan#586

Feel free to check out if it does the job better or worse than yours and try to join forces with the author 😊

@Jean85
Copy link
Contributor Author

Jean85 commented Nov 30, 2017

Damn, I missed that!
Yep, it seems to work pretty good! I'll dive into the code ASAP, thanks!

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

Successfully merging this pull request may close these issues.

2 participants