Lowercase autoload strings

Summary: PHP is undebatably the worst programming language in the world. Class names are case insensitive, so new $tHiNg = new $THing. Garbase. Now autoload has to deal with the fallout.

Reviewed By: dreiss

Test Plan: autoload enabled falcon code


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665375 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/php/src/autoload.php b/lib/php/src/autoload.php
index b5886c5..43b2470 100644
--- a/lib/php/src/autoload.php
+++ b/lib/php/src/autoload.php
@@ -16,19 +16,26 @@
  * code. The generated code will *not* include any defined Thrift classes by
  * default, except for the service interfaces. The generated code will populate
  * values into $GLOBALS['THRIFT_AUTOLOAD'] which can be used by the autoload
- * method below. If you have your own autoload system already in place, you
- * should merge the following functionality into your autoload system.
+ * method below. If you have your own autoload system already in place, rename your
+ * __autoload function to something else and then do:
+ * $GLOBALS['AUTOLOAD_HOOKS'][] = 'my_autoload_func';
  *
  * Generate this code using the -phpa Thrift generator flag.
  */
 
 $GLOBALS['THRIFT_AUTOLOAD'] = array();
+$GLOBALS['AUTOLOAD_HOOKS'] = array();
 
 if (!function_exists('__autoload')) {
   function __autoload($class) {
     global $THRIFT_AUTOLOAD;
-    if (isset($THRIFT_AUTOLOAD[$class])) {
-      include_once $GLOBALS['THRIFT_ROOT'].'/lib/packages/'.$THRIFT_AUTOLOAD[$class];
+    $classl = strtolower($classl);
+    if (isset($THRIFT_AUTOLOAD[$classl])) {
+      include_once $GLOBALS['THRIFT_ROOT'].'/packages/'.$THRIFT_AUTOLOAD[$classl];
+    } else if (!empty($GLOBALS['AUTOLOAD_HOOKS'])) {
+      foreach ($GLOBALS['AUTOLOAD_HOOKS'] as $hook) {
+        $hook($class);
+      }
     }
   }
 }