Skip to content

[WIP] Support for Prophecy - #1

Closed
Jean85 wants to merge 4 commits into
phpstan:masterfrom
Jean85:master
Closed

Jean85 wants to merge 4 commits into
phpstan:masterfrom
Jean85:master

Conversation

@Jean85

@Jean85 Jean85 commented Nov 30, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Jean85 commented Nov 30, 2017

Copy link
Copy Markdown
Contributor Author

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