Use interfaces and closures and abstracts and anonymous functions and all the fancy OOP PHP stuff.