public static function find($class, $namespace = null, $rootns = null)
{
$e = explode('\\', $class);
if ($e[0] === '') {
return $class;
}
if ('Pool' === $class || 'TransportContext' === $class) {
return '\\PHPDaemon\\Core\\' . $class;
}
if (mb_orig_strpos($class, '\\') === false && $namespace === null) {
if ('Example' === substr($class, 0, 7)) {
array_unshift($e, 'Examples');
}
if ('Server' === substr($class, -6)) {
$path = '\\PHPDaemon\\Servers\\' . substr($class, 0, -6) . '\\Pool';
$r = str_replace('\\Servers\\Servers', '\\Servers', $path);
Daemon::log('ClassFinder: \'' . $class . '\' -> \'' . $r . '\', you should change your code.');
return $r;
}
if ('Client' === substr($class, -6)) {
$path = '\\PHPDaemon\\Clients\\' . substr($class, 0, -6) . '\\Pool';
$r = str_replace('\\Clients\\Clients', '\\Clients', $path);
Daemon::log('ClassFinder: \'' . $class . '\' -> \'' . $r . '\', you should change your code.');
return $r;
}
if ('ClientAsync' === substr($class, -11)) {
$path = '\\PHPDaemon\\Clients\\' . substr($class, 0, -11) . '\\Pool';
$r = str_replace('\\Client\\Clients', '\\Clients', $path);
Daemon::log('ClassFinder: \'' . $class . '\' -> \'' . $r . '\', you should change your code.');
return $r;
}
}
if ($namespace !== null && sizeof($e) < 2) {
array_unshift($e, $namespace);
}
array_unshift($e, '\\' . ($rootns !== null ? $rootns : Daemon::$config->defaultns->value));
return implode('\\', $e);
}