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


PHP XPClass::nameOf方法代码示例

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


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

示例1: main

 /**
  * Main
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $way = array_shift($args);
     $argc = sizeof($args);
     // Read sourcecode from STDIN if no further argument is given
     if (0 === $argc) {
         $code = new Code(file_get_contents('php://stdin'));
     } else {
         if ('--' === $args[0]) {
             $code = new Code(file_get_contents('php://stdin'));
         } else {
             $code = new Code($args[0]);
         }
     }
     // Perform
     $argv = [XPClass::nameOf(self::class)] + $args;
     $return = eval($code->head() . $code->expression());
     switch ($way) {
         case '-w':
             Console::writeLine($return);
             break;
         case '-d':
             var_dump($return);
             break;
     }
 }
开发者ID:xp-framework,项目名称:core,代码行数:31,代码来源:Dump.class.php

示例2: 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) {
         $code = new Code(file_get_contents('php://stdin'));
     } else {
         if ('--' === $args[0]) {
             $code = new Code(file_get_contents('php://stdin'));
         } else {
             $code = new Code($args[0]);
         }
     }
     // Perform
     $argv = [XPClass::nameOf(__CLASS__)] + $args;
     return eval($code->head() . $code->fragment());
 }
开发者ID:johannes85,项目名称:core,代码行数:22,代码来源:Evaluate.class.php

示例3: __call

 public function __call($name, $args)
 {
     $t = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
     $c = PHP_VERSION >= '7.0.0' || defined('HHVM_VERSION');
     $self = $t[1 - $c]['class'];
     $scope = isset($t[2 - $c]['class']) ? $t[2 - $c]['class'] : $t[3 - $c]['class'];
     // Check scope for extension methods
     if (null != $scope && isset(\xp::$ext[$scope])) {
         foreach (\xp::$ext[$scope] as $type => $class) {
             if (!$this instanceof $type || !method_exists($class, $name)) {
                 continue;
             }
             array_unshift($args, $this);
             return call_user_func_array([$class, $name], $args);
         }
     }
     throw new \lang\Error('Call to undefined method ' . \lang\XPClass::nameOf($self) . '::' . $name . '() from scope ' . \lang\XPClass::nameOf($scope));
 }
开发者ID:johannes85,项目名称:core,代码行数:18,代码来源:lang.base.php

示例4: main

 /**
  * Main
  *
  * @param  string[] $args
  * @return int
  */
 public static function main(array $args)
 {
     // Read sourcecode from STDIN if no further argument is given
     if (empty($args)) {
         $code = new Code(file_get_contents('php://stdin'));
     } else {
         if ('--' === $args[0]) {
             $code = new Code(file_get_contents('php://stdin'));
         } else {
             if (is_file($args[0])) {
                 $code = new Code(file_get_contents($args[0]));
             } else {
                 $code = new Code($args[0]);
             }
         }
     }
     // Perform
     $argv = [XPClass::nameOf(self::class)] + $args;
     return eval($code->head() . $code->fragment());
 }
开发者ID:xp-framework,项目名称:core,代码行数:26,代码来源:Evaluate.class.php

示例5: invoke

 /**
  * Invokes the underlying method represented by this Method object, 
  * on the specified object with the specified parameters.
  *
  * Example:
  * ```php
  * $method= XPClass::forName('lang.Object')->getMethod('toString');
  * $str= $method->invoke(new Object());
  * ```
  *
  * Example (passing arguments)
  * ```php
  * $method= XPClass::forName('lang.types.String')->getMethod('concat');
  * $str= $method->invoke(new String('Hello'), ['World']);
  * ```
  *
  * Example (static invokation):
  * ```php
  * $method= XPClass::forName('util.log.Logger')->getMethod('getInstance');
  * $log= $method->invoke(null);
  * ```
  *
  * @param   lang.Object $obj
  * @param   var[] $args default []
  * @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 = [])
 {
     if (null !== $obj && !$obj instanceof $this->_class) {
         throw new IllegalArgumentException(sprintf('Passed argument is not a %s class (%s)', XPClass::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', XPClass::nameOf($this->_class), $this->_reflect->getName()));
     }
     $public = $m & MODIFIER_PUBLIC;
     if (!$public && !$this->accessible) {
         $t = debug_backtrace(0, 2);
         $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;
         }
         if (!$allow) {
             throw new IllegalAccessException(sprintf('Cannot invoke %s %s::%s from scope %s', Modifiers::stringOf($this->getModifiers()), XPClass::nameOf($this->_class), $this->_reflect->getName(), $t[1]['class']));
         }
     }
     try {
         if (!$public) {
             $this->_reflect->setAccessible(true);
         }
         return $this->_reflect->invokeArgs($obj, (array) $args);
     } catch (\lang\SystemExit $e) {
         throw $e;
     } catch (\lang\Throwable $e) {
         throw new TargetInvocationException(XPClass::nameOf($this->_class) . '::' . $this->_reflect->getName(), $e);
     } catch (\Exception $e) {
         throw new TargetInvocationException(XPClass::nameOf($this->_class) . '::' . $this->_reflect->getName(), new \lang\XPException($e->getMessage()));
     } catch (\Throwable $e) {
         throw new TargetInvocationException(XPClass::nameOf($this->_class) . '::' . $this->_reflect->getName(), new \lang\Error($e->getMessage()));
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:69,代码来源:Method.class.php

示例6: getReturnTypeName

 /**
  * Retrieve return type
  *
  * @return  string
  */
 public function getReturnTypeName()
 {
     return XPClass::nameOf($this->_class);
 }
开发者ID:johannes85,项目名称:core,代码行数:9,代码来源:Constructor.class.php

示例7: set

 /**
  * Changes the value of the field represented by this Field, on the 
  * specified object.
  *
  * @param   lang.Object instance
  * @param   var value
  * @throws  lang.IllegalArgumentException in case the passed object is not an instance of the declaring class
  * @throws  lang.IllegalAccessException in case this field is not public
  */
 public function set($instance, $value)
 {
     if (null !== $instance && !$instance instanceof $this->_class) {
         throw new IllegalArgumentException(sprintf('Passed argument is not a %s class (%s)', XPClass::nameOf($this->_class), \xp::typeOf($instance)));
     }
     // 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();
     $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;
         }
         if (!$allow) {
             throw new IllegalAccessException(sprintf('Cannot write %s %s::$%s from scope %s', Modifiers::stringOf($this->getModifiers()), XPClass::nameOf($this->_class), $this->_reflect->getName(), $t[1]['class']));
         }
     }
     try {
         $public || $this->_reflect->setAccessible(true);
         $this->_reflect->setValue($instance, $value);
     } catch (\lang\Throwable $e) {
         throw $e;
     } catch (\Exception $e) {
         throw new \lang\XPException($e->getMessage());
     }
 }
开发者ID:johannes85,项目名称:core,代码行数:40,代码来源:Field.class.php


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