Currently I have a tool with a single registered autoload function that picks apart the class name and tries to predict where it is and then includes it.
Due to naming conventions for the project this has been pretty simple.
if has namespace
if in template namespace look in Root\Templates
else look in Root\Modules\Namespace
else
look in Root\System
if file exists include
But we are starting to include Interfaces and Traits into our codebase and it hurts me to include the type of a thing in it's name. So we are looking at instead of a single autoload function that digs through the class name and looks for the file and has increasingly complex logic to it, we are looking at having multiple autoload functions registered. But each one follows the same pattern and any time I see that I get paranoid about code copying.
function autoloadfunc
create probable filename
if filename exists include it and return true
else return false
Every autoload function will follow that pattern and the last of each function if filename exists, include return true else return false is going to be identical code. This makes me paranoid about having to update it later across the board if the file_exists include pattern we are using ever changes. Or is it just that, paranoia and the multiple functions with some identical code is the best option?
Also, we could use an autoload tag....