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
Undefined method in traits #9
Comments
This actually points out problem in your code 😊 If you use the trait in a Correct solution is to define the bar method in the trait as abstract so I want to write an article about this - we have several traits used by On Friday, 22 July 2016, Patrik Votoček notifications@github.com wrote:
Ondřej Mirtes |
Thank you. I know it's a bad idea to ignore not implemented methods in traits. It's first time when I use traits in my project. Abstract function is a good idea. I'll try it. |
@ondrejmirtes imho using abstract methods in traits is more hack than a solution because it does not actually enforce existence of the method with the same signature. You would need sth like https://docs.hhvm.com/hack/other-features/trait-and-interface-requirements |
@JanTvrdik I didn't know the signature isn't enforced (https://3v4l.org/YHMU0) but I still think the approach with abstract methods in traits is better than nothing at all... |
Example code:
Call to an undefined method MyTrait::bar().
The text was updated successfully, but these errors were encountered: