Class_Exists, __autoload & third-party code

I had some problems with my new PHP framework. I was trying (for the first time in this framework) to use a third-party library in my code ( SimplePie). And that turned out to be a problem. See, my framework uses __autoload to dynamically load classes that aren’t yet included. And SimplePie (like many other libraries) uses the Class_Exists function to check if some component is present or not (which is great).

Now the problem is, that Class_Exists, for reasons I can’t comprehend, calls the __autoload function you define. Yes there is a second parameter that disables this behaviour, but are you expecting me to dig trough ten’s of thousands lines of SimplePie (or any other) code to change the second parameter to false? Madness. And that’s not even the point. The function Class_Exists (as name suggests) checks if a given class is loaded and can be used. Why on earth would you go on and try to load the class if it isn’t?

Now you might say: “you should check if the file you are trying to include in your __autoload function actually exists”. “But why?”, I ask? Why should I? If something vital as a file with a class your code is trying to use doesn’t exists, then something is wrong and the application should crash, there is no point in sugar-coting the error.

I hope they fix this in the future so we don’t have to use ugly hack’s in our code to make our code compatibale with third-party code