Consolidate functions into class files

Not all legacy applications use a large set of classes. Often, instead of classes, there is a significant number of user-defined functions for core logic.

Using functions is not a problem in itself, but it does mean that we need to include the files where the functions are defined. But autoloading only works for classes. It would be good to find a way to automatically load the function files as well as the class files. That would help us remove even more include calls.

The solution here is to move the functions into class files, and call the functions as static methods on those classes. That way, the autoloader can load up the class file for us, and then we can call the methods in that class.

This procedure ...

Get Modernizing Legacy Applications in PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.