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


PHP XPClass::forName方法代码示例

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


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

示例1: genericInterface

 public function genericInterface()
 {
     $interfaces = \lang\XPClass::forName('lang.Object')->getInterfaces();
     $this->assertEquals(1, sizeof($interfaces));
     $this->assertInstanceOf('lang.XPClass', $interfaces[0]);
     $this->assertEquals('lang.Generic', $interfaces[0]->getName());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:7,代码来源:ObjectTest.class.php

示例2: putParameters

 public function putParameters()
 {
     $params = $this->fixture->getClass()->getMethod('put')->getParameters();
     $this->assertEquals(2, sizeof($params));
     $this->assertEquals(\lang\XPClass::forName('lang.types.String'), $params[0]->getType());
     $this->assertEquals(\lang\XPClass::forName('unittest.TestCase'), $params[1]->getType());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:7,代码来源:InstanceReflectionTest.class.php

示例3: compile

 /**
  * Compile class from source and return compiled type
  *
  * @param   string src
  * @return  xp.compiler.types.TypeReflection
  */
 protected function compile($src)
 {
     $unique = 'FixtureClassFor' . $this->getClass()->getSimpleName() . ucfirst($this->name);
     $r = $this->emitter->emit(Syntax::forName('xp')->parse(new MemoryInputStream(sprintf($src, $unique))), $this->scope);
     $r->executeWith([]);
     return new TypeReflection(\lang\XPClass::forName($r->type()->name()));
 }
开发者ID:xp-lang,项目名称:compiler,代码行数:13,代码来源:PropertiesTest.class.php

示例4: __construct

 /**
  * Constructor
  *
  * @param   rdbms.DSN dsn
  */
 public function __construct($dsn)
 {
     $this->dsn = $dsn;
     $this->flags = $dsn->getFlags();
     if (!$this->dsn->url->hasParam('autoconnect')) {
         $this->flags |= DB_AUTOCONNECT;
     }
     $this->setTimeout($dsn->getProperty('timeout', 0));
     // 0 means no timeout
     // Keep this for BC reasons
     $observers = $dsn->getProperty('observer', []);
     if (null !== ($cat = $dsn->getProperty('log'))) {
         $observers['util.log.LogObserver'] = $cat;
     }
     // Add observers
     foreach ($observers as $observer => $param) {
         $class = XPClass::forName($observer);
         // Check if class implements BoundLogObserver: in that case use factory method to acquire
         // instance. Otherwise, just use the constructor
         if (XPClass::forName('util.log.BoundLogObserver')->isAssignableFrom($class)) {
             $this->addObserver($class->getMethod('instanceFor')->invoke(null, [$param]));
         } else {
             $this->addObserver($class->newInstance($param));
         }
     }
     // Time zone handling
     if ($tz = $dsn->getProperty('timezone', false)) {
         $this->tz = new TimeZone($tz);
     }
 }
开发者ID:xp-framework,项目名称:rdbms,代码行数:35,代码来源:DBConnection.class.php

示例5: putParameters

 public function putParameters()
 {
     $params = $this->fixture->getClass()->getMethod('put')->getParameters();
     $this->assertEquals(2, sizeof($params));
     $this->assertEquals(Primitive::$STRING, $params[0]->getType());
     $this->assertEquals(XPClass::forName('unittest.TestCase'), $params[1]->getType());
 }
开发者ID:xp-framework,项目名称:core,代码行数:7,代码来源:InstanceReflectionTest.class.php

示例6: given_interface_class_is_implemented

 public function given_interface_class_is_implemented()
 {
     $class = $this->define(['interfaces' => [XPClass::forName(Runnable::class)]], '{
   public function run() { } 
 }');
     $this->assertTrue($class->isSubclassOf(Runnable::class));
 }
开发者ID:xp-framework,项目名称:core,代码行数:7,代码来源:RuntimeClassDefinitionTest.class.php

示例7: addPortlet

 /**
  * Add Portlets
  *
  * @param   string classname
  * @param   string layout
  * @return  xml.portlet.Portlet
  */
 public function addPortlet($classname, $layout = null)
 {
     with($portlet = \lang\XPClass::forName($classname)->newInstance());
     $portlet->setLayout($layout);
     $this->portlets[] = $portlet;
     return $portlet;
 }
开发者ID:xp-framework,项目名称:scriptlet,代码行数:14,代码来源:PortletContainer.class.php

示例8: main

 /**
  * Main
  *
  * Exitcodes used:
  * <ul>
  *   <li>127: Archive referenced in -xar [...] does not exist</li>
  *   <li>126: No manifest or manifest does not have a main-class</li>
  * </ul>
  *
  * @see     http://tldp.org/LDP/abs/html/exitcodes.html
  * @param   string[] args
  * @return  int
  */
 public static function main(array $args)
 {
     // Open archive
     $f = new File(array_shift($args));
     if (!$f->exists()) {
         Console::$err->writeLine('*** Cannot find archive ' . $f->getURI());
         return 127;
     }
     // Register class loader
     $cl = \lang\ClassLoader::registerLoader(new \lang\archive\ArchiveClassLoader(new Archive($f)));
     if (!$cl->providesResource(self::MANIFEST)) {
         Console::$err->writeLine('*** Archive ' . $f->getURI() . ' does not have a manifest');
         return 126;
     }
     // Load manifest
     $pr = Properties::fromString($cl->getResource(self::MANIFEST));
     if (null === ($class = $pr->readString('archive', 'main-class', null))) {
         Console::$err->writeLine('*** Archive ' . $f->getURI() . '\'s manifest does not have a main class');
         return 126;
     }
     // Run main()
     try {
         return \lang\XPClass::forName($class, $cl)->getMethod('main')->invoke(null, [$args]);
     } catch (\lang\reflect\TargetInvocationException $e) {
         throw $e->getCause();
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:40,代码来源:Xar.class.php

示例9: __construct

 /**
  * Creates a new instance
  *
  * @param  string $source
  * @param  xp.scriptlet.Config $config
  * @throws lang.IllegalArgumentException
  */
 public function __construct($source, Config $config = null)
 {
     if ('-' === $source) {
         $this->layout = new ServeDocumentRootStatically();
     } else {
         if (is_file($source)) {
             $this->layout = new WebConfiguration(new Properties($source), $config);
         } else {
             if (is_dir($source)) {
                 $this->layout = new BasedOnWebroot($source, $config);
             } else {
                 $name = ltrim($source, ':');
                 try {
                     $class = XPClass::forName($name);
                 } catch (ClassLoadingException $e) {
                     throw new IllegalArgumentException('Cannot load ' . $name, $e);
                 }
                 if ($class->isSubclassOf('xp.scriptlet.WebLayout')) {
                     if ($class->hasConstructor()) {
                         $this->layout = $class->getConstructor()->newInstance([$config]);
                     } else {
                         $this->layout = $class->newInstance();
                     }
                 } else {
                     if ($class->isSubclassOf('scriptlet.HttpScriptlet')) {
                         $this->layout = new SingleScriptlet($class->getName(), $config);
                     } else {
                         throw new IllegalArgumentException('Expecting either a scriptlet or a weblayout, ' . $class->getName() . ' given');
                     }
                 }
             }
         }
     }
 }
开发者ID:xp-framework,项目名称:scriptlet,代码行数:41,代码来源:Source.class.php

示例10: type_bound_to_type_provider

 public function type_bound_to_type_provider()
 {
     $inject = new Injector();
     $provider = new TypeProvider(XPClass::forName(FileSystem::class), $inject);
     $inject->bind(Storage::class, $provider);
     $this->assertInstanceOf(FileSystem::class, $inject->get(Storage::class));
 }
开发者ID:xp-forge,项目名称:inject,代码行数:7,代码来源:ProvidersTest.class.php

示例11:

 static function __static()
 {
     self::$byName['if'] = XPClass::forName('com.handlebarsjs.IfBlockHelper');
     self::$byName['unless'] = XPClass::forName('com.handlebarsjs.UnlessBlockHelper');
     self::$byName['with'] = XPClass::forName('com.handlebarsjs.WithBlockHelper');
     self::$byName['each'] = XPClass::forName('com.handlebarsjs.EachBlockHelper');
 }
开发者ID:xp-forge,项目名称:handlebars,代码行数:7,代码来源:BlockHelpers.class.php

示例12: object_return_type

 public function object_return_type()
 {
     $fixture = $this->define('{
   public function fixture(): \\lang\\Object { return new \\lang\\Object(); }
 }');
     $this->assertEquals(XPClass::forName('lang.Object'), $this->newFixture($fixture)->methods()->named('fixture')->returns());
 }
开发者ID:xp-forge,项目名称:mirrors,代码行数:7,代码来源:Php7TypesTest.class.php

示例13: matches

 /**
  * Matches implementation
  * 
  * @param   var value
  * @return  bool
  */
 public function matches($value)
 {
     if (null === $value && $this->matchNull) {
         return true;
     }
     return \xp::typeof($value) == \lang\XPClass::forName($this->type)->getName();
 }
开发者ID:xp-framework,项目名称:mocks,代码行数:13,代码来源:TypeMatcher.class.php

示例14: read

 /**
  * Creates a segment instance
  *
  * @param  string $marker
  * @param  string $bytes
  * @return self
  */
 public static function read($marker, $bytes)
 {
     if (is_array($iptc = iptcparse($bytes))) {
         return \lang\XPClass::forName('img.io.IptcSegment')->newInstance($marker, $iptc);
     } else {
         return new self($marker, $bytes);
     }
 }
开发者ID:xp-framework,项目名称:imaging,代码行数:15,代码来源:APP13Segment.class.php

示例15: interfaceImplemented

 public function interfaceImplemented()
 {
     $class = \lang\XPClass::forName('de.thekid.util.ObjectComparator');
     $interfaces = $class->getInterfaces();
     $this->assertEquals(2, sizeof($interfaces));
     $this->assertEquals('lang.Generic', $interfaces[0]->getName());
     $this->assertEquals('de.thekid.util.Comparator', $interfaces[1]->getName());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:8,代码来源:FullyQualifiedTest.class.php


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