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
How to spec a Class with Dynamic methods? #34
Comments
Prophecy tells you that It's both technically hard and logically wrong for mocking tool AND for human beings to understand communication based on magic methods. That's the reason why this kind of object communications considered bad practice. So in this particular case, mocking framework forces you to make implicit communication pattern explicit - through definition of explicit signatures. Is it bad or good - for you to decide, but in most cases magic methods cause more harm than good. |
Thanks for your reply, yeah I think __call is not a way to define a public API, and I think I uncommented the wrong method. (Edited above) It should have been: return $this->entity->getMemberA(); However, I understand internally, there is __call method working with it, so not good either. The reason within in my context, is that I'm building a php component that works with a large Xml API, and I'm creating classes to match those Types exposed by the API and they have lots of properties, around 100 per type. So explicitly writing getters and setters are a pain, right now, and __call is used to alleviate that load. |
@everzet Could PhpDoc block be checked for magic methods declaration? |
Moved from phpspec issue #149
Say if I have an class that uses magic setter and getters, like in Doctrine with the class Persistent Object.
If I Spec to access this member
I got this error , How could I make Prophect/PhpSpec aware of those dynamic methods?
Repository testing these issues are here: https://github.com/raul782/phpspec-playground/
The text was updated successfully, but these errors were encountered: