Skip to content

Using traits

Greg Bowler edited this page May 16, 2016 · 1 revision

// TODO: Explain how native PHP's libxml implementation is extended using registerNodeClass, but how this limits object oriented design - phpgt's dom classes must extend the base libxml classes, so in turn can't extend anything else.

// TODO: Explain how traits can be used to share common functionality to objects.

// TODO: Explain how objects can use traits to adopt their functionality, but if two traits expose the same function name, special (and confusing) syntax is required. This includes magic methods like __get and __set. One underlying principal of the DOM is that nodes can have "live properties", requiring getters and setters, so to allow getters and setters to be used across traits, the LiveProperty trait is used. See the page on Live properties for more information.