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


PHP xp::nameOf方法代码示例

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


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

示例1: main

 /**
  * Main runner method
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     // Parse args
     $api = new RestClient('http://builds.planet-xp.net/');
     $action = null;
     $cat = null;
     for ($i = 0, $s = sizeof($args); $i < $s; $i++) {
         if ('-?' === $args[$i] || '--help' === $args[$i]) {
             break;
         } else {
             if ('-a' === $args[$i]) {
                 $api->setBase($args[++$i]);
             } else {
                 if ('-v' === $args[$i]) {
                     $cat = create(new LogCategory('console'))->withAppender(new ColoredConsoleAppender());
                 } else {
                     if ('-' === $args[$i][0]) {
                         Console::$err->writeLine('*** Unknown argument ', $args[$i]);
                         return 128;
                     } else {
                         $action = $args[$i];
                         // First non-option is the action name
                         break;
                     }
                 }
             }
         }
     }
     if (null === $action) {
         Console::$err->writeLine(self::textOf(\lang\XPClass::forName(\xp::nameOf(__CLASS__))->getComment()));
         return 1;
     }
     try {
         $class = \lang\reflect\Package::forName('xp.install')->loadClass(ucfirst($action) . 'Action');
     } catch (\lang\ClassNotFoundException $e) {
         Console::$err->writeLine('*** No such action "' . $action . '"');
         return 2;
     }
     // Show help
     if (in_array('-?', $args) || in_array('--help', $args)) {
         Console::$out->writeLine(self::textOf($class->getComment()));
         return 3;
     }
     // Perform action
     $instance = $class->newInstance($api);
     $instance->setTrace($cat);
     try {
         return $instance->perform(array_slice($args, $i + 1));
     } catch (\lang\Throwable $e) {
         Console::$err->writeLine('*** Error performing action ~ ', $e);
         return 1;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:58,代码来源:Runner.class.php

示例2: main

 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     // Read sourcecode from STDIN if no further argument is given
     if (0 === sizeof($args)) {
         $src = file_get_contents('php://stdin');
     } else {
         $src = $args[0];
     }
     $src = trim($src, ' ;') . ';';
     // Perform
     $argv = array(xp::nameOf(__CLASS__)) + $args;
     $argc = sizeof($argv);
     return eval($src);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:19,代码来源:Evaluate.class.php

示例3: invoke

 /**
  * Invokes the underlying method represented by this Method object, 
  * on the specified object with the specified parameters.
  *
  * Example:
  * <code>
  *   $method= XPClass::forName('lang.Object')->getMethod('toString');
  *
  *   var_dump($method->invoke(new Object()));
  * </code>
  *
  * Example (passing arguments)
  * <code>
  *   $method= XPClass::forName('lang.types.String')->getMethod('concat');
  *
  *   var_dump($method->invoke(new String('Hello'), array('World')));
  * </code>
  *
  * Example (static invokation):
  * <code>
  *   $method= XPClass::forName('util.log.Logger')->getMethod('getInstance');
  *
  *   var_dump($method->invoke(NULL));
  * </code>
  *
  * @param   lang.Object obj
  * @param   var[] args default array()
  * @return  var
  * @throws  lang.IllegalArgumentException in case the passed object is not an instance of the declaring class
  * @throws  lang.IllegalAccessException in case the method is not public or if it is abstract
  * @throws  lang.reflect.TargetInvocationException for any exception raised from the invoked method
  */
 public function invoke($obj, $args = array())
 {
     if (NULL !== $obj && !$obj instanceof $this->_class) {
         throw new IllegalArgumentException(sprintf('Passed argument is not a %s class (%s)', xp::nameOf($this->_class), xp::typeOf($obj)));
     }
     // Check modifiers. If caller is an instance of this class, allow
     // protected method invocation (which the PHP reflection API does
     // not).
     $m = $this->_reflect->getModifiers();
     if ($m & MODIFIER_ABSTRACT) {
         throw new IllegalAccessException(sprintf('Cannot invoke abstract %s::%s', $this->_class, $this->_reflect->getName()));
     }
     $public = $m & MODIFIER_PUBLIC;
     if (!$public && !$this->accessible) {
         $t = debug_backtrace(0);
         $decl = $this->_reflect->getDeclaringClass()->getName();
         if ($m & MODIFIER_PROTECTED) {
             $allow = $t[1]['class'] === $decl || is_subclass_of($t[1]['class'], $decl);
         } else {
             $allow = $t[1]['class'] === $decl && self::$SETACCESSIBLE_AVAILABLE;
         }
         if (!$allow) {
             throw new IllegalAccessException(sprintf('Cannot invoke %s %s::%s from scope %s', Modifiers::stringOf($this->getModifiers()), $this->_class, $this->_reflect->getName(), $t[1]['class']));
         }
     }
     // For non-public methods: Use setAccessible() / invokeArgs() combination
     // if possible, resort to __call() workaround.
     try {
         if ($public) {
             return $this->_reflect->invokeArgs($obj, (array) $args);
         }
         if (self::$SETACCESSIBLE_AVAILABLE) {
             $this->_reflect->setAccessible(TRUE);
             return $this->_reflect->invokeArgs($obj, (array) $args);
         } else {
             if ($m & MODIFIER_STATIC) {
                 return call_user_func(array($this->_class, '__callStatic'), "" . $this->_reflect->getName(), $args);
             } else {
                 return $obj->__call("" . $this->_reflect->getName(), $args);
             }
         }
     } catch (SystemExit $e) {
         throw $e;
     } catch (Throwable $e) {
         throw new TargetInvocationException($this->_class . '::' . $this->_reflect->getName(), $e);
     } catch (Exception $e) {
         throw new TargetInvocationException($this->_class . '::' . $this->_reflect->getName(), new XPException($e->getMessage()));
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:81,代码来源:Method.class.php

示例4: startApplicationServer

 public static function startApplicationServer()
 {
     // Arguments to server process
     $args = array('debugServerProtocolToFile' => NULL);
     // Start server process
     self::$serverProcess = Runtime::getInstance()->newInstance(NULL, 'class', 'net.xp_framework.unittest.remote.TestingServer', array_values($args));
     self::$serverProcess->in->close();
     // Check if startup succeeded
     $status = self::$serverProcess->out->readLine();
     if (2 != sscanf($status, '+ Service %[0-9.]:%d', self::$bindAddress[0], self::$bindAddress[1])) {
         try {
             self::shutdownApplicationServer();
         } catch (IllegalStateException $e) {
             $status .= $e->getMessage();
         }
         throw new PrerequisitesNotMetError('Cannot start EASC server: ' . $status, NULL);
     }
     // Add classloader with CalculatorBean client classes
     $a = XPClass::forName(xp::nameOf(__CLASS__))->getPackage()->getPackage('deploy')->getResourceAsStream('beans.test.CalculatorBean.xar');
     self::$clientClassesLoader = ClassLoader::registerLoader(new ArchiveClassLoader(new Archive($a)));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:21,代码来源:IntegrationTest.class.php

示例5: main

 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $argc = sizeof($args);
     // Read sourcecode from STDIN if no further argument is given
     if (0 === $argc) {
         $src = file_get_contents('php://stdin');
     } else {
         if ('--' === $args[0]) {
             $src = file_get_contents('php://stdin');
         } else {
             $src = $args[0];
         }
     }
     // Support <?php
     $src = trim($src, ' ;') . ';';
     if (0 === strncmp($src, '<?php', 5)) {
         $src = substr($src, 6);
     }
     // Perform
     $argv = array(\xp::nameOf(__CLASS__)) + $args;
     $argc = sizeof($argv);
     return eval($src);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:28,代码来源:Evaluate.class.php

示例6: main

 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $way = array_shift($args);
     // Read sourcecode from STDIN if no further argument is given
     if (0 === sizeof($args)) {
         $src = file_get_contents('php://stdin');
     } else {
         $src = $args[0];
     }
     $src = trim($src, ' ;') . ';';
     // Extract uses() and load classes
     if (0 === strncmp($src, 'uses', 4)) {
         $p = strpos($src, ');');
         $uses = substr($src, 5, $p - 5);
         // "uses("
         $src = substr($src, $p + 2);
         // ");"
         foreach (explode(',', $uses) as $class) {
             uses(trim($class, '" '));
         }
     }
     // Allow missing return
     strstr($src, 'return ') || strstr($src, 'return;') || ($src = 'return ' . $src);
     // Rewrite argc, argv
     $argv = array(\xp::nameOf(__CLASS__)) + $args;
     $argc = sizeof($argv);
     // Perform
     $return = eval($src);
     switch ($way) {
         case '-w':
             Console::writeLine($return);
             break;
         case '-d':
             var_dump($return);
             break;
     }
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:42,代码来源:Dump.class.php

示例7: usage

 /**
  * Displays usage and exists
  *
  */
 protected static function usage()
 {
     Console::$err->writeLine(self::textOf(XPClass::forName(xp::nameOf(__CLASS__))->getComment()));
     exit(1);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:9,代码来源:Runner.class.php

示例8: qualifiedClassName

 /**
  * Returns qualified class name
  *
  * @param   string class unqualified name
  * @return  string
  */
 protected function qualifiedClassName($class)
 {
     return xp::nameOf($class);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:10,代码来源:StackTraceElement.class.php

示例9: stringOf

 static function stringOf($arg, $indent = '')
 {
     static $protect = array();
     if (is_string($arg)) {
         return '"' . $arg . '"';
     } else {
         if (is_bool($arg)) {
             return $arg ? 'true' : 'false';
         } else {
             if (is_null($arg)) {
                 return 'null';
             } else {
                 if ($arg instanceof null) {
                     return '<null>';
                 } else {
                     if (is_int($arg) || is_float($arg)) {
                         return (string) $arg;
                     } else {
                         if ($arg instanceof Generic && !isset($protect[(string) $arg->hashCode()])) {
                             $protect[(string) $arg->hashCode()] = TRUE;
                             $s = $arg->toString();
                             unset($protect[(string) $arg->hashCode()]);
                             return $indent ? str_replace("\n", "\n" . $indent, $s) : $s;
                         } else {
                             if (is_array($arg)) {
                                 $ser = serialize($arg);
                                 if (isset($protect[$ser])) {
                                     return '->{:recursion:}';
                                 }
                                 $protect[$ser] = TRUE;
                                 $r = "[\n";
                                 foreach (array_keys($arg) as $key) {
                                     $r .= $indent . '  ' . $key . ' => ' . xp::stringOf($arg[$key], $indent . '  ') . "\n";
                                 }
                                 unset($protect[$ser]);
                                 return $r . $indent . ']';
                             } else {
                                 if (is_object($arg)) {
                                     $ser = serialize($arg);
                                     if (isset($protect[$ser])) {
                                         return '->{:recursion:}';
                                     }
                                     $protect[$ser] = TRUE;
                                     $r = xp::nameOf(get_class($arg)) . " {\n";
                                     $vars = (array) $arg;
                                     foreach (array_keys($vars) as $key) {
                                         $r .= $indent . '  ' . $key . ' => ' . xp::stringOf($vars[$key], $indent . '  ') . "\n";
                                     }
                                     unset($protect[$ser]);
                                     return $r . $indent . '}';
                                 } else {
                                     if (is_resource($arg)) {
                                         return 'resource(type= ' . get_resource_type($arg) . ', id= ' . (int) $arg . ')';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:63,代码来源:lang.base.php

示例10: getClassName

 /** 
  * Returns the fully qualified class name for this class 
  * (e.g. "io.File")
  * 
  * @return  string fully qualified class name
  */
 public function getClassName()
 {
     return xp::nameOf(get_class($this));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:Object.class.php

示例11: valuesFor

 /**
  * Returns values
  *
  * @param  unittest.TestCase test
  * @param  var annotation
  * @return var values a traversable structure
  */
 protected function valuesFor($test, $annotation)
 {
     if (!is_array($annotation)) {
         // values("source")
         $source = $annotation;
         $args = array();
     } else {
         if (isset($annotation['source'])) {
             // values(source= "src" [, args= ...])
             $source = $annotation['source'];
             $args = isset($annotation['args']) ? $annotation['args'] : array();
         } else {
             // values([1, 2, 3])
             return $annotation;
         }
     }
     // Route "ClassName::methodName" -> static method of the given class,
     // "self::method" -> static method of the test class, and "method"
     // -> the run test's instance method
     if (FALSE === ($p = strpos($source, '::'))) {
         return $test->getClass()->getMethod($source)->setAccessible(TRUE)->invoke($test, $args);
     }
     $ref = substr($source, 0, $p);
     if ('self' === $ref) {
         $class = $test->getClass();
     } else {
         if (strstr($ref, '.')) {
             $class = XPClass::forName($ref);
         } else {
             $class = XPClass::forName(xp::nameOf($ref));
         }
     }
     return $class->getMethod(substr($source, $p + 2))->invoke(NULL, $args);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:41,代码来源:TestSuite.class.php

示例12: __static

 static function __static()
 {
     \lang\ClassLoader::registerLoader(new \lang\archive\ArchiveClassLoader(new Archive(\lang\XPClass::forName(\xp::nameOf(__CLASS__))->getPackage()->getPackage('lib')->getResourceAsStream('fqcns.xar'))));
     \lang\XPClass::forName('info.binford6100.Date');
     \lang\XPClass::forName('de.thekid.util.ObjectComparator');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:6,代码来源:FullyQualifiedTest.class.php

示例13: setUp

 /**
  * Setup this test. Registeres class loaders deleates for the 
  * afforementioned XARs
  *
  */
 public function setUp()
 {
     $this->libraryLoader = \lang\ClassLoader::registerLoader(new \lang\archive\ArchiveClassLoader(new Archive(\lang\XPClass::forName(\xp::nameOf(__CLASS__))->getPackage()->getPackage('lib')->getResourceAsStream('three-and-four.xar'))));
     $this->brokenLoader = \lang\ClassLoader::registerLoader(new \lang\archive\ArchiveClassLoader(new Archive(\lang\XPClass::forName(\xp::nameOf(__CLASS__))->getPackage()->getPackage('lib')->getResourceAsStream('broken.xar'))));
     $this->containedLoader = \lang\ClassLoader::registerLoader(new \lang\archive\ArchiveClassLoader(new Archive($this->libraryLoader->getResourceAsStream('contained.xar'))));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:11,代码来源:ClassLoaderTest.class.php

示例14: main

 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     Console::$err->writeLine(XPClass::forName(xp::nameOf(__CLASS__))->getPackage()->getResource($args[0]));
     exit((int) $args[1]);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:10,代码来源:ShowResource.class.php

示例15: registerClientClasses

 public static function registerClientClasses()
 {
     $a = \lang\XPClass::forName(\xp::nameOf(__CLASS__))->getPackage()->getPackage('deploy')->getResourceAsStream('beans.test.CalculatorBean.xar');
     self::$clientClassesLoader = \lang\ClassLoader::registerLoader(new \lang\archive\ArchiveClassLoader(new Archive($a)));
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:5,代码来源:IntegrationTest.class.php


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