当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassLoader::getDefault方法代码示例

本文整理汇总了PHP中lang\ClassLoader::getDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::getDefault方法的具体用法?PHP ClassLoader::getDefault怎么用?PHP ClassLoader::getDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lang\ClassLoader的用法示例。


在下文中一共展示了ClassLoader::getDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: entry

function entry(&$argv)
{
    if (is_file($argv[0])) {
        if (0 === substr_compare($argv[0], '.class.php', -10)) {
            $uri = realpath($argv[0]);
            if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) {
                throw new \Exception('Cannot load ' . $uri . ' - not in class path');
            }
            return $cl->loadUri($uri)->literal();
        } else {
            if (0 === substr_compare($argv[0], '.xar', -4)) {
                $cl = \lang\ClassLoader::registerPath($argv[0]);
                if (!$cl->providesResource('META-INF/manifest.ini')) {
                    throw new \Exception($cl->toString() . ' does not provide a manifest');
                }
                $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini'));
                return strtr($manifest['main-class'], '.', '\\');
            } else {
                array_unshift($argv, 'eval');
                return 'xp\\runtime\\Evaluate';
            }
        }
    } else {
        return strtr($argv[0], '.', '\\');
    }
}
开发者ID:xp-runners,项目名称:main,代码行数:26,代码来源:entry.php

示例2: __construct

 /**
  * Constructor
  * 
  * @param   lang.ClassLoader classLoader
  */
 public function __construct($classLoader = null)
 {
     if (null === $classLoader) {
         $this->classLoader = ClassLoader::getDefault();
     } else {
         $this->classLoader = $classLoader;
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:13,代码来源:MockProxyBuilder.class.php

示例3: __construct

 /**
  * Creates a new class source
  *
  * @param  string $class Dotted fully qualified name
  * @throws lang.ClassFormatException
  */
 public function __construct($class)
 {
     $cl = ClassLoader::getDefault()->findClass($class);
     if ($cl instanceof IClassLoader) {
         $this->tokenize($cl->loadClassBytes($class), $class);
     } else {
         $this->tokens = null;
     }
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:15,代码来源:ClassSource.class.php

示例4: testCasesWith

 /**
  * Get all test cases
  *
  * @param   var[] arguments
  * @return  unittest.TestCase[]
  */
 public function testCasesWith($arguments)
 {
     $uri = $this->file->getURI();
     $cl = \lang\ClassLoader::getDefault()->findUri($uri);
     if (is(null, $cl)) {
         throw new IllegalArgumentException('Cannot load class from ' . $this->file->toString());
     }
     return $this->testCasesInClass($cl->loadUri($uri), $arguments);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:ClassFileSource.class.php

示例5: fixture

 /**
  * Creates a fixrture
  *
  * @return  util.PropertyManager
  */
 private function fixture()
 {
     $class = ClassLoader::getDefault()->defineClass('NonSingletonPropertyManager', PropertyManager::class, [], '{
   public static function newInstance() {
     return new self();
   }
 }');
     return $class->getMethod('newInstance')->invoke(null);
 }
开发者ID:johannes85,项目名称:core,代码行数:14,代码来源:PropertyManagerTest.class.php

示例6: __construct

 /**
  * Constructor
  *
  * @param   io.File file
  * @throws  lang.IllegalArgumentException if the given file does not exist
  */
 public function __construct(File $file)
 {
     $uri = $file->getURI();
     $cl = ClassLoader::getDefault()->findUri($uri);
     if ($cl === null) {
         throw new IllegalArgumentException('File "' . $uri . ($file->exists() ? '" is not in class path' : '" not found'));
     }
     $this->loader = $cl;
     $this->uri = $uri;
 }
开发者ID:xp-framework,项目名称:unittest,代码行数:16,代码来源:ClassFileSource.class.php

示例7: locateClass

 /**
  * Locate a class
  *
  * @param   string[] packages
  * @param   string name
  * @return  string qualified
  * @throws  lang.ElementNotFoundException
  */
 public function locateClass($packages, $local)
 {
     $cl = ClassLoader::getDefault();
     foreach ($packages as $package) {
         $qualified = $package . '.' . $local;
         if (!$cl->providesClass($qualified) && !$this->manager->findClass($qualified)) {
             continue;
         }
         return $qualified;
     }
     throw new ElementNotFoundException('Could not locate class ' . $local . ' in ' . \xp::stringOf($packages));
 }
开发者ID:xp-lang,项目名称:compiler,代码行数:20,代码来源:CompilationTask.class.php

示例8: __construct

 /**
  * Setup method.
  *
  * @param   string package
  * @param   string stateName
  * @param   string functionality
  * @param   [:var] params default array()
  */
 public function __construct($package, $stateName, $functionality, $params = [])
 {
     static $i = 0;
     parent::__construct($package);
     // Generate unique classname and put it into the environment
     // That way, the classloader will already know this class in
     // WorkflowScriptletRequest::initialize() and be able to load
     // and instantiate it.
     $stateName = 'Mock__' . $i++ . $stateName;
     $this->state = \lang\ClassLoader::getDefault()->defineClass($package . '.mock.state.' . $stateName . 'State', 'scriptlet.xml.workflow.AbstractState', [], $functionality)->newInstance();
     $_SERVER['STATE'] = $stateName;
     // Set some defaults
     $_SERVER['PRODUCT'] = 'xp';
     $_SERVER['LANGUAGE'] = 'en_US';
 }
开发者ID:xp-framework,项目名称:scriptlet,代码行数:23,代码来源:MockRequest.class.php

示例9: anyOfType

 /**
  * Accessor method for a type matcher.
  * 
  * @param   typeName string
  */
 public static function anyOfType($typeName)
 {
     $builder = new MockProxyBuilder();
     $builder->setOverwriteExisting(false);
     $interfaces = [XPClass::forName('unittest.mock.arguments.IArgumentMatcher')];
     $parentClass = null;
     $type = XPClass::forName($typeName);
     if ($type->isInterface()) {
         $interfaces[] = $type;
     } else {
         $parentClass = $type;
     }
     $proxyClass = $builder->createProxyClass(ClassLoader::getDefault(), $interfaces, $parentClass);
     return $proxyClass->newInstance(new TypeMatcher($typeName));
 }
开发者ID:johannes85,项目名称:core,代码行数:20,代码来源:Arg.class.php

示例10: createMock

 /**
  * Builds a stub instance for the specified type.
  *
  * @param   string typeName
  * @param   boolean overrideAll
  * @return  lang.Object
  */
 public function createMock($typeName, $overrideAll = true)
 {
     $type = Type::forName($typeName);
     if (!$type instanceof XPClass) {
         throw new IllegalArgumentException('Cannot mock other types than XPClass types.');
     }
     $parentClass = null;
     $interfaces = [XPClass::forName('unittest.mock.IMock')];
     if ($type->isInterface()) {
         $interfaces[] = $type;
     } else {
         $parentClass = $type;
     }
     $proxy = new MockProxyBuilder();
     $proxy->setOverwriteExisting($overrideAll);
     $proxyClass = $proxy->createProxyClass(ClassLoader::getDefault(), $interfaces, $parentClass);
     $mock = $proxyClass->newInstance(new MockProxy());
     $this->mocks[] = $mock;
     return $mock;
 }
开发者ID:johannes85,项目名称:core,代码行数:27,代码来源:MockRepository.class.php

示例11: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->marshallers = create('new util.collections.HashTable<lang.Type, webservices.rest.TypeMarshaller>');
     // Deprecated!
     if (PHP_VERSION < 7 && ClassLoader::getDefault()->providesPackage('lang.types')) {
         $strings = newinstance('webservices.rest.TypeMarshaller', [], ['marshal' => function ($t) {
             return $t->toString();
         }, 'unmarshal' => function (Type $target, $in) {
             return $target->newInstance($in);
         }]);
         $integers = newinstance('webservices.rest.TypeMarshaller', [], ['marshal' => function ($t) {
             return $t->intValue();
         }, 'unmarshal' => function (Type $target, $in) {
             return $target->newInstance($in);
         }]);
         $decimals = newinstance('webservices.rest.TypeMarshaller', [], ['marshal' => function ($t) {
             return $t->doubleValue();
         }, 'unmarshal' => function (Type $target, $in) {
             return $target->newInstance($in);
         }]);
         $booleans = newinstance('webservices.rest.TypeMarshaller', [], ['marshal' => function ($t) {
             return (bool) $t->value;
         }, 'unmarshal' => function (Type $target, $in) {
             return $target->newInstance($in);
         }]);
         $this->marshallers[XPClass::forName('lang.types.String')] = $strings;
         $this->marshallers[XPClass::forName('lang.types.Character')] = $strings;
         $this->marshallers[XPClass::forName('lang.types.Long')] = $integers;
         $this->marshallers[XPClass::forName('lang.types.Integer')] = $integers;
         $this->marshallers[XPClass::forName('lang.types.Short')] = $integers;
         $this->marshallers[XPClass::forName('lang.types.Byte')] = $integers;
         $this->marshallers[XPClass::forName('lang.types.Float')] = $decimals;
         $this->marshallers[XPClass::forName('lang.types.Double')] = $decimals;
         $this->marshallers[XPClass::forName('lang.types.Boolean')] = $booleans;
     }
     $this->marshallers[XPClass::forName('lang.Enum')] = newinstance('webservices.rest.TypeMarshaller', [], ['marshal' => function ($t) {
         return $t->name();
     }, 'unmarshal' => function (Type $target, $in) {
         return Enum::valueOf($target, (string) $in);
     }]);
 }
开发者ID:xp-framework,项目名称:rest,代码行数:44,代码来源:RestMarshalling.class.php

示例12: named

 /**
  * Find a command by a given name
  *
  * @param  string $name
  * @return lang.XPClass
  * @throws lang.ClassNotFoundException
  * @throws lang.IllegalArgumentException if class is not runnable
  */
 public static function named($name)
 {
     $cl = ClassLoader::getDefault();
     if (is_file($name)) {
         $class = $cl->loadUri($name);
     } else {
         if (strstr($name, '.')) {
             $class = $cl->loadClass($name);
         } else {
             if ($package = self::locateNamed($name)) {
                 $class = $package->loadClass($name);
             } else {
                 $class = $cl->loadClass($name);
             }
         }
     }
     // Check whether class is runnable
     if (!$class->isSubclassOf('lang.Runnable')) {
         throw new IllegalArgumentException($class->getName() . ' is not runnable');
     }
     return $class;
 }
开发者ID:xp-framework,项目名称:command,代码行数:30,代码来源:Commands.class.php

示例13: main

 /**
  * Main
  *
  * @param  string[] $args
  * @return int
  */
 public static function main($args)
 {
     $name = array_shift($args);
     if (null === $name) {
         Console::$err->writeLine('*** No class or package name given');
         return 1;
     }
     // Check whether a file, class or a package directory or name is given
     $cl = ClassLoader::getDefault();
     try {
         if (strstr($name, \xp::CLASS_FILE_EXT)) {
             $info = new TypeInformation($cl->loadUri(realpath($name)));
         } else {
             if (is_dir($name)) {
                 $info = new DirectoryInformation($name);
             } else {
                 if ($cl->providesClass($name)) {
                     $info = new TypeInformation($cl->loadClass($name));
                 } else {
                     if ($cl->providesPackage($name)) {
                         $info = new PackageInformation($name);
                     } else {
                         Console::$err->writeLine('*** No classloader provides ' . $name);
                         return 2;
                     }
                 }
             }
         }
     } catch (IllegalArgumentException $e) {
         Console::$err->writeLine('*** ' . $e->getMessage());
         return 2;
     }
     foreach ($info->sources() as $source) {
         Console::writeLine("[33m@", $source, "[0m");
     }
     $info->display(new Highlighting(Console::$out, ['/(class|enum|trait|interface|package|directory) (.+)/' => "[1;35m\$1[0m \$2", '/(extends|implements) (.+)/' => "[1;35m\$1[0m \$2", '/(public|private|protected|abstract|final|static)/' => "[1;35m\$1[0m", '/(\\$[a-zA-Z0-9_]+)/' => "[1;31m\$1[0m"]));
     return 0;
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:44,代码来源:MirrorRunner.class.php

示例14: main

 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     if (sizeof($args) < 1 || '' == $args[0]) {
         Console::$err->writeLine('*** No class or package name given');
         return 2;
     }
     // Check whether a file, class or a package directory or name is given
     $cl = \lang\ClassLoader::getDefault();
     if (strstr($args[0], \xp::CLASS_FILE_EXT)) {
         $class = $cl->loadUri(realpath($args[0]));
     } else {
         if ($cl->providesClass($args[0])) {
             $class = XPClass::forName($args[0], $cl);
         } else {
             if (strcspn($args[0], '\\/') < strlen($args[0])) {
                 $package = self::findPackageBy(new Folder($args[0]));
             } else {
                 $package = $args[0];
             }
             $provided = false;
             foreach (\lang\ClassLoader::getLoaders() as $loader) {
                 if (!$loader->providesPackage($package)) {
                     continue;
                 }
                 Console::writeLine('@', $loader);
                 $provided = true;
             }
             if ($provided) {
                 self::printPackage(\lang\reflect\Package::forName($package));
                 return 0;
             }
             // Not found
             Console::$err->writeLine('*** Failed to locate either a class or a package named "', $args[0], '", tried all of {');
             foreach (\lang\ClassLoader::getLoaders() as $loader) {
                 Console::$err->writeLine('  ', $loader);
             }
             Console::$err->writeLine('}');
             return 1;
         }
     }
     Console::writeLine('@', $class->getClassLoader());
     if ($class->isInterface()) {
         self::printInterface($class);
     } else {
         if ($class->isEnum()) {
             self::printEnum($class);
         } else {
             self::printClass($class);
         }
     }
     return 0;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:57,代码来源:Reflect.class.php

示例15: database

 /**
  * Open a database
  *
  * @return info.keepass.KeePassDatabase
  */
 protected function database()
 {
     return KeePassDatabase::open(ClassLoader::getDefault()->getResourceAsStream('fixtures/' . $this->fixture . '.kdbx')->in(), new Key($this->fixture));
 }
开发者ID:xp-forge,项目名称:keepass,代码行数:9,代码来源:AbstractDatabaseTest.class.php


注:本文中的lang\ClassLoader::getDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。