resolving inheritance
EDIT: This pose is thankfully obsolete due to the magic __autoload function!
So far all code [classes and interfaces in particular] in ZenMagick rely on the loader to ensure that extended classes and implemented interface used are loaded. So far this has worked quite well.
Reasons for doing this are:
- Late binding of the actual implementation of classes
- Having a central place that handles file loading
- In case core.php is used (merging all code into a single, stripped file) all that is not necessary
Obviously, there are downsides as well:
- The loader relies on hierachical directory structures to determine the order of loading files;
For example, if class B extends class A, then the file containing class A (A.php) needs to be at least one level higher in the directory structure than the file containing class B (B.php). - Unresolved classes throw unrecoverable exceptions in PHP. This is very unfortunate, because being able to handle those would mean it would be possible to recover at least those in case the missing class/interface is available to the loader.
- Some more that elude me right now
The next release will, for the first time, include core files that actually use ZMLoader::resolve('classname'); before the class declaration in order to avoid unloaded classes/interfaces. I o not realy like this at all, but unless I start reorganizing the directory layout (again), there is no way around this.
Comments Off
