Merge remote-tracking branch 'fredemmott/hh-support'
commit
a6531f6fd3
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class ClassMapGenerator
|
|||
if (is_file($path)) {
|
||||
$path = array(new \SplFileInfo($path));
|
||||
} elseif (is_dir($path)) {
|
||||
$path = Finder::create()->files()->followLinks()->name('/\.(php|inc)$/')->in($path);
|
||||
$path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
|
||||
} else {
|
||||
throw new \RuntimeException(
|
||||
'Could not scan for classes inside "'.$path.
|
||||
|
@ -68,7 +68,7 @@ class ClassMapGenerator
|
|||
foreach ($path as $file) {
|
||||
$filePath = $file->getRealPath();
|
||||
|
||||
if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc'))) {
|
||||
if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue