|
@@ -291,8 +291,22 @@ class ClassLoader
|
|
|
return $this->classMap[$class];
|
|
|
}
|
|
|
|
|
|
+ $file = $this->findFileWithExtension($class, '.php');
|
|
|
+ if ($file === null && defined('HHVM_VERSION')) {
|
|
|
+ // Indicates a Hack file (hacklang.org)
|
|
|
+ $file = $this->findFileWithExtension($class, '.hh');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($file === null) {
|
|
|
+ // Remember that this class does not exist.
|
|
|
+ return $this->classMap[$class] = false;
|
|
|
+ }
|
|
|
+ return $file;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function findFileWithExtension($class, $ext) {
|
|
|
// PSR-4 lookup
|
|
|
- $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
|
|
|
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
|
|
|
|
|
$first = $class[0];
|
|
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
|
@@ -321,7 +335,7 @@ class ClassLoader
|
|
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
|
|
} else {
|
|
|
// PEAR-like class name
|
|
|
- $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php';
|
|
|
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
|
|
}
|
|
|
|
|
|
if (isset($this->prefixesPsr0[$first])) {
|
|
@@ -348,8 +362,7 @@ class ClassLoader
|
|
|
return $file;
|
|
|
}
|
|
|
|
|
|
- // Remember that this class does not exist.
|
|
|
- return $this->classMap[$class] = false;
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|