Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Marc Morera:
Namespaces in Traits
Oct 16, 2015 @ 18:53:14

In this post to his site Marc Morera talks about traits, namespaces and how they fit together (or don't).

Some projects using PHP 5.4 are actually using Traits. If you don’t know yet what a trait is, there are some interesting links for you. [...] This post is about the usage of "use statements" in Traits.

He starts with an overall picture of what he's trying to accomplish in a contribution to an open source project (with a word of caution). He talks about how you can make traits and classes more "friendly" with a refactoring example of his initial code snippet. In the end, though, he recommends basically avoiding namespaces if possible in traits, reducing headaches that could be caused either by conflicts or missing dependencies.

tagged: traits namespace difficulty dependency interaction

Link: http://mmoreram.com/blog/2015/10/16/namespaces-in-traits/


Trending Topics: