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


PHP Package::forName方法代码示例

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


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

示例1: addPackage

 public function addPackage($package)
 {
     if (!is_string($package) || empty($package)) {
         throw new IllegalArgumentException('$package must be a non empty string!');
     }
     $this->packages[] = Package::forName($package);
 }
开发者ID:Gamepay,项目名称:xp-contrib,代码行数:7,代码来源:DefaultValidatorProvider.class.php

示例2: configure

 /**
  * Configure router
  * 
  * @param  string setup
  * @param  string base The base URI
  */
 public function configure($setup, $base = '')
 {
     $package = Package::forName($setup);
     foreach ($package->getClasses() as $handler) {
         if ($handler->hasAnnotation('webservice')) {
             $this->addWebservice($handler, $base);
         }
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:RestDefaultRouter.class.php

示例3: assertBrokenAnnotations

 /**
  * Get annotations
  *
  * @param   string class
  */
 protected function assertBrokenAnnotations($class, $message)
 {
     try {
         $a = Package::forName('net.xp_framework.unittest.annotations')->loadClass($class)->getAnnotations();
         $this->fail('No exception raised', $a, 'lang.ClassFormatException');
     } catch (ClassFormatException $e) {
         $this->assertEquals($message, substr($e->getMessage(), 0, strlen($message)), $e->getMessage());
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:14,代码来源:BrokenAnnotationTest.class.php

示例4: main

 /**
  * Main runner method
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     if (!$args) {
         self::usage();
     }
     try {
         $class = Package::forName('xp.install')->loadClass(ucfirst($args[0]) . 'Action');
     } catch (ClassNotFoundException $e) {
         Console::$err->writeLine('*** No such action ' . $args[0] . ': ', $e);
         exit(2);
     }
     // Show help
     if (in_array('-?', $args)) {
         Console::$out->writeLine(self::textOf($class->getComment()));
         exit(3);
     }
     // Perform action
     try {
         $class->newInstance()->perform(array_slice($args, 1));
     } catch (Throwable $e) {
         Console::$err->writeLine('*** Error performing action ~ ', $e);
         exit(1);
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:29,代码来源:Runner.class.php

示例5: fixturePackage

 public static function fixturePackage()
 {
     self::$package = Package::forName('net.xp_framework.unittest.webservices.rest.srv.fixture');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:4,代码来源:RestContextTest.class.php

示例6: 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 = ClassLoader::getDefault();
     if (strstr($args[0], xp::CLASS_FILE_EXT)) {
         $class = self::findClassBy(new File($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 (ClassLoader::getLoaders() as $loader) {
                 if (!$loader->providesPackage($package)) {
                     continue;
                 }
                 Console::writeLine('@', $loader);
                 $provided = TRUE;
             }
             if ($provided) {
                 self::printPackage(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 (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:Gamepay,项目名称:xp-framework,代码行数:57,代码来源:Reflect.class.php

示例7: run

 /**
  * Runs suite
  *
  * @param   string[] args
  * @return  int exitcode
  */
 public function run(array $args)
 {
     if (!$args) {
         return $this->usage();
     }
     // Setup suite
     $suite = new TestSuite();
     // Parse arguments
     $sources = new Vector();
     $listener = TestListeners::$DEFAULT;
     $coverage = NULL;
     $arguments = array();
     $colors = NULL;
     $cmap = array('' => NULL, '=on' => TRUE, '=off' => FALSE, '=auto' => NULL);
     try {
         for ($i = 0, $s = sizeof($args); $i < $s; $i++) {
             if ('-v' == $args[$i]) {
                 $listener = TestListeners::$VERBOSE;
             } else {
                 if ('-q' == $args[$i]) {
                     $listener = TestListeners::$QUIET;
                 } else {
                     if ('-c' == $args[$i]) {
                         $coverage = new CoverageListener();
                         foreach (explode(PATH_SEPARATOR, $this->arg($args, ++$i, 'c')) as $path) {
                             $coverage->registerPath($path);
                         }
                     } else {
                         if ('-cp' == $args[$i]) {
                             foreach (explode(PATH_SEPARATOR, $this->arg($args, ++$i, 'cp')) as $element) {
                                 ClassLoader::registerPath($element, NULL);
                             }
                         } else {
                             if ('-e' == $args[$i]) {
                                 $sources->add(new xp·unittest·sources·EvaluationSource($this->arg($args, ++$i, 'e')));
                             } else {
                                 if ('-l' == $args[$i]) {
                                     $arg = $this->arg($args, ++$i, 'l');
                                     $class = XPClass::forName(strstr($arg, '.') ? $arg : 'xp.unittest.' . ucfirst($arg) . 'Listener');
                                     $arg = $this->arg($args, ++$i, 'l');
                                     if ('-?' == $arg || '--help' == $arg) {
                                         return $this->listenerUsage($class);
                                     }
                                     $output = $this->streamWriter($arg);
                                     $instance = $suite->addListener($class->newInstance($output));
                                     // Get all @arg-annotated methods
                                     $options = array();
                                     foreach ($class->getMethods() as $method) {
                                         if ($method->hasAnnotation('arg')) {
                                             $arg = $method->getAnnotation('arg');
                                             if (isset($arg['position'])) {
                                                 $options[$arg['position']] = $method;
                                             } else {
                                                 $name = isset($arg['name']) ? $arg['name'] : strtolower(preg_replace('/^set/', '', $method->getName()));
                                                 $short = isset($arg['short']) ? $arg['short'] : $name[0];
                                                 $options[$name] = $options[$short] = $method;
                                             }
                                         }
                                     }
                                     $option = 0;
                                 } else {
                                     if ('-o' == $args[$i]) {
                                         if (isset($options[$option])) {
                                             $name = '#' . ($option + 1);
                                             $method = $options[$option];
                                         } else {
                                             $name = $this->arg($args, ++$i, 'o');
                                             if (!isset($options[$name])) {
                                                 $this->err->writeLine('*** Unknown listener argument ' . $name . ' to ' . $instance->getClassName());
                                                 return 2;
                                             }
                                             $method = $options[$name];
                                         }
                                         $option++;
                                         if (0 == $method->numParameters()) {
                                             $pass = array();
                                         } else {
                                             $pass = $this->arg($args, ++$i, 'o ' . $name);
                                         }
                                         try {
                                             $method->invoke($instance, $pass);
                                         } catch (TargetInvocationException $e) {
                                             $this->err->writeLine('*** Error for argument ' . $name . ' to ' . $instance->getClassName() . ': ' . $e->getCause()->toString());
                                             return 2;
                                         }
                                     } else {
                                         if ('-?' == $args[$i] || '--help' == $args[$i]) {
                                             return $this->usage();
                                         } else {
                                             if ('-a' == $args[$i]) {
                                                 $arguments[] = $this->arg($args, ++$i, 'a');
                                             } else {
                                                 if ('--color' == substr($args[$i], 0, 7)) {
                                                     $remainder = (string) substr($args[$i], 7);
//.........这里部分代码省略.........
开发者ID:Gamepay,项目名称:xp-framework,代码行数:101,代码来源:Runner.class.php

示例8: getPackage

 /**
  * Retrieves the package associated with this class
  * 
  * @return  lang.reflect.Package
  */
 public function getPackage()
 {
     return Package::forName(substr($this->name, 0, strrpos($this->name, '.')));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:9,代码来源:XPClass.class.php

示例9: remoteInterfaceMapping

 public function remoteInterfaceMapping()
 {
     $this->serializer->mapPackage('net.xp_framework.easc.beans', Package::forName('remote.beans'));
     $this->serializer->mapping('I', new RemoteInterfaceMapping());
     $class = $this->serializer->valueOf(new SerializedData('I:12036987:{s:41:"net.xp_framework.easc.beans.BeanInterface";}'), array('handler' => 'remote.protocol.XPProtocolHandler'));
     $this->assertSubclass($class, 'lang.reflect.Proxy');
     $this->assertSubclass($class, 'remote.beans.BeanInterface');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:8,代码来源:SerializerTest.class.php

示例10: libPackageComment

 public function libPackageComment()
 {
     $this->assertEquals('Fixture libraries for package reflection tests', trim(Package::forName('net.xp_framework.unittest.reflection.lib')->getComment()));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:4,代码来源:PackageTest.class.php

示例11: setOperation

 /**
  * Set operation
  *
  * @param   xp.xar.instruction.AbstractInstruction operation
  * @param   string name
  */
 protected static function setOperation(&$operation, $name)
 {
     if (NULL !== $operation) {
         self::bail('Cannot execute more than one instruction at a time.');
     }
     $operation = Package::forName('xp.xar.instruction')->loadClass(ucfirst($name) . 'Instruction');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:13,代码来源:Runner.class.php

示例12: loadClassFileWithRecusionInStaticBlock

 public function loadClassFileWithRecusionInStaticBlock()
 {
     with($p = Package::forName('net.xp_framework.unittest.reflection.classes'));
     $two = $p->loadClass('StaticRecursionTwo');
     $one = $p->loadClass('StaticRecursionOne');
     $this->assertEquals($two, $one->getField('two')->get(NULL));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:7,代码来源:ClassLoaderTest.class.php

示例13: getPackage_returns_package_class_resides_in

 public function getPackage_returns_package_class_resides_in()
 {
     $this->assertEquals(Package::forName('net.xp_framework.unittest.reflection'), $this->fixture->getPackage());
 }
开发者ID:xp-framework,项目名称:core,代码行数:4,代码来源:XPClassTest.class.php

示例14: packageOfNewInstancedNamespacedClass

 public function packageOfNewInstancedNamespacedClass()
 {
     $i = newinstance('net.xp_framework.unittest.core.NamespacedClass', array(), '{}');
     $this->assertEquals(Package::forName('net.xp_framework.unittest.core'), $i->getClass()->getPackage());
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:5,代码来源:NamespacedClassesTest.class.php


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