コード例 #1
0
ファイル: ClassLoader.class.php プロジェクト: johannes85/core
 static function __static()
 {
     $modules = [];
     self::$VARIADIC = method_exists('ReflectionParameter', 'isVariadic');
     // Scan include-path, setting up classloaders for each element
     foreach (\xp::$classpath as $element) {
         if (DIRECTORY_SEPARATOR === $element[strlen($element) - 1]) {
             $cl = FileSystemClassLoader::instanceFor($element, false);
         } else {
             $cl = ArchiveClassLoader::instanceFor($element, false);
         }
         if (isset(self::$delegates[$cl->instanceId()])) {
             continue;
         }
         self::$delegates[$cl->instanceId()] = $cl;
         if ($cl->providesResource('module.xp')) {
             $modules[] = $cl;
         }
     }
     // Initialize modules
     \xp::$loader = new self();
     foreach ($modules as $cl) {
         self::$modules[$cl->instanceId()] = Module::register(self::declareModule($cl));
     }
 }
コード例 #2
0
 static function __static()
 {
     xp::$loader = new self();
     // Scan include-path, setting up classloaders for each element
     foreach (xp::$classpath as $element) {
         if ('' === $element) {
             continue;
         } else {
             if ('!' === $element[0]) {
                 $before = TRUE;
                 $element = substr($element, 1);
             } else {
                 $before = FALSE;
             }
         }
         $resolved = realpath($element);
         if (is_dir($resolved)) {
             $cl = FileSystemClassLoader::instanceFor($resolved, FALSE);
         } else {
             if (is_file($resolved)) {
                 $cl = ArchiveClassLoader::instanceFor($resolved, FALSE);
             } else {
                 if ('/' !== $element[0] && ':' !== $element[1]) {
                     // If not fully qualified
                     $element .= ' (in ' . getcwd() . ')';
                 }
                 xp::error('[bootstrap] Classpath element [' . $element . '] not found');
             }
         }
         isset(self::$delegates[$cl->instanceId()]) || self::registerLoader($cl, $before);
     }
 }
コード例 #3
0
ファイル: lang.base.php プロジェクト: johannes85/core
        };
    }
}
// }}}
// {{{ main
error_reporting(E_ALL);
set_error_handler('__error');
date_default_timezone_set(ini_get('date.timezone')) || xp::error('[xp::core] date.timezone not configured properly.');
define('MODIFIER_STATIC', 1);
define('MODIFIER_ABSTRACT', 2);
define('MODIFIER_FINAL', 4);
define('MODIFIER_PUBLIC', 256);
define('MODIFIER_PROTECTED', 512);
define('MODIFIER_PRIVATE', 1024);
xp::$null = new __null();
xp::$loader = new xp();
// Paths are passed via class loader API from *-main.php. Retaining BC:
// Paths are constructed inside an array before including this file.
if (isset($GLOBALS['paths'])) {
    xp::$classpath = $GLOBALS['paths'];
} else {
    if (0 === strpos(__FILE__, 'xar://')) {
        xp::$classpath = [substr(__FILE__, 6, -14)];
    } else {
        xp::$classpath = [__DIR__ . DIRECTORY_SEPARATOR];
    }
}
set_include_path(rtrim(implode(PATH_SEPARATOR, xp::$classpath), PATH_SEPARATOR));
spl_autoload_register(function ($class) {
    $name = strtr($class, '\\', '.');
    $cl = xp::$loader->findClass($name);
コード例 #4
0
ファイル: lang.base.php プロジェクト: Gamepay/xp-framework
function bootstrap($classpath)
{
    set_include_path($classpath);
    xp::$classpath = explode(PATH_SEPARATOR, $classpath);
    xp::$loader = new xp();
    uses('lang.Object', 'lang.Error', 'lang.XPException', 'lang.XPClass', 'lang.NullPointerException', 'lang.IllegalAccessException', 'lang.IllegalArgumentException', 'lang.IllegalStateException', 'lang.FormatException', 'lang.ClassLoader');
}