當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。