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


PHP xp::reflect方法代码示例

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


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

示例1: defineInterface

 /**
  * Helper method
  *
  * @param   string name
  * @param   lang.XPClass class
  * @throws  unittest.AssertionFailedError
  */
 protected function defineInterface($name, $parents, $bytes)
 {
     if (interface_exists(xp::reflect($name), FALSE)) {
         $this->fail('Interface "' . $name . '" may not exist!');
     }
     return ClassLoader::defineInterface($name, $parents, $bytes);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:14,代码来源:RuntimeClassDefinitionTest.class.php

示例2: read

 /**
  * Read a record
  *
  * @param   string[] fields if omitted, class fields are used in order of appearance
  * @return  lang.Object or NULL if end of the file is reached
  */
 public function read(array $fields = array())
 {
     if (NULL === ($values = $this->readValues())) {
         return NULL;
     }
     if (!$fields) {
         foreach ($this->class->getFields() as $f) {
             $fields[] = $f->getName();
         }
     }
     // Create an object by deserialization. This enables us to also set
     // private and protected fields as well as avoids the constructor call.
     $n = xp::reflect($this->class->getName());
     $s = 'O:' . strlen($n) . ':"' . $n . '":' . sizeof($fields) . ':{';
     foreach ($fields as $i => $name) {
         $f = $this->class->getField($name);
         switch ($f->getModifiers() & (MODIFIER_PUBLIC | MODIFIER_PROTECTED | MODIFIER_PRIVATE)) {
             case MODIFIER_PUBLIC:
                 $s .= serialize($f->getName());
                 break;
             case MODIFIER_PROTECTED:
                 $s .= serialize("*" . $f->getName());
                 break;
             case MODIFIER_PRIVATE:
                 $s .= serialize("" . $n . "" . $f->getName());
                 break;
         }
         $s .= serialize($values[$i]);
     }
     $s .= '}';
     return unserialize($s);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:38,代码来源:CsvObjectReader.class.php

示例3: __static

 static function __static()
 {
     libxml_use_internal_errors(TRUE);
     // Forwards compatibility hack: In XSL, we use XSLCallback::invoke(), but
     // the class in namespaced PHP is called xml::XSLCallback. Ensure a class
     // called "XSLCallback" (without namespaces) exists instead of requiring
     // everybody to change their XSL files!
     class_exists('XSLCallback', FALSE) || eval('class XSLCallback extends ' . xp::reflect('xml.XSLCallback') . ' {}');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:9,代码来源:DomXSLProcessor.class.php

示例4: runnable

function runnable()
{
    $p = new ParamString();
    $class = xp::reflect(basename($p->value(0), '.class.php'));
    $target = array($class, 'main');
    if (!is_callable($target)) {
        xp::error('Target ' . $class . '::main() is not runnable');
        // Bails out
    }
    xp::$cn[$class] = 'Runnable$' . $class;
    exit(call_user_func($target, $p));
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:12,代码来源:class.sapi.php

示例5: qualifyName

 /**
  * Qualifies a class name by looking at known or used classes.
  *
  * @param   text.doclet.Doc doc
  * @param   string name
  * @return  string qualified name
  */
 public function qualifyName($doc, $name)
 {
     if (isset(xp::$cn[$name])) {
         foreach ($doc->usedClasses->classes as $class) {
             if (xp::reflect($class) === $name) {
                 return $class;
             }
         }
         $lookup = xp::$cn[$name];
     } else {
         $lookup = NULL;
     }
     // Nothing found!
     if (!$lookup && !($lookup = xp::nameOf($name))) {
         throw new IllegalStateException(sprintf('Could not find class %s in %s', xp::stringOf($name), xp::stringOf($this->sourcepath)));
     }
     return $lookup;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:25,代码来源:RootDoc.class.php

示例6: loadClass0

 /**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     if (isset(xp::$cl[$class])) {
         return xp::reflect($class);
     }
     // Load class
     $package = NULL;
     xp::$cl[$class] = $this->getClassName() . '://' . $this->path;
     xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         xp::$cll--;
         $decl = NULL;
         if (NULL === $package) {
             $decl = substr($class, FALSE === ($p = strrpos($class, '.')) ? 0 : $p + 1);
         } else {
             $decl = strtr($class, '.', '·');
         }
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($decl, FALSE) || interface_exists($decl, FALSE)) {
             raise('lang.ClassDependencyException', $class, array($this), $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         raise('lang.ClassLinkageException', $class, array($this), $e);
     }
     xp::$cll--;
     if (FALSE === $r) {
         unset(xp::$cl[$class]);
         throw new ClassNotFoundException($class, array($this));
     }
     // Register it
     if (NULL === $package) {
         if (FALSE === ($p = strrpos($class, '.'))) {
             $name = $class;
         } else {
             $name = substr($class, $p + 1);
             if (!class_exists($name, FALSE) && !interface_exists($name, FALSE)) {
                 $name = strtr($class, '.', '\\');
                 if (!class_exists($name, FALSE) && !interface_exists($name, FALSE)) {
                     unset(xp::$cl[$class]);
                     raise('lang.ClassFormatException', 'Class "' . $name . '" not declared in loaded file');
                 }
             } else {
                 class_alias($name, strtr($class, '.', '\\'));
             }
         }
     } else {
         $name = strtr($class, '.', '·');
         class_alias($name, strtr($class, '.', '\\'));
     }
     xp::$cn[$name] = $class;
     method_exists($name, '__static') && (xp::$cli[] = array($name, '__static'));
     if (0 === xp::$cll) {
         $invocations = xp::$cli;
         xp::$cli = array();
         foreach ($invocations as $inv) {
             call_user_func($inv);
         }
     }
     return $name;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:74,代码来源:AbstractClassLoader.class.php

示例7: __construct

 /**
  * Constructor
  *
  * @param   string rootName default 'document'
  */
 public function __construct($rootName = 'document')
 {
     parent::__construct($rootName);
     $this->nodeType = xp::reflect('xml.soap.xp.XPSoapNode');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:XPSoapMessage.class.php

示例8: __construct

 /**
  * Constructor
  *
  * @param   string rootName default 'document'
  */
 public function __construct($rootName = 'document')
 {
     $this->root = new Node($rootName);
     $this->nodeType = xp::reflect('xml.Node');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:10,代码来源:Tree.class.php

示例9: sorting

 public function sorting()
 {
     $list = array(new \util\Date('1977-12-14'), new \util\Date('2002-02-21'), new \util\Date('1980-05-28'));
     usort($list, array(\xp::reflect('util.DateUtil'), 'compare'));
     $this->assertEquals(new \util\Date('1977-12-14'), $list[0], 'offset 0') && $this->assertEquals(new \util\Date('1980-05-28'), $list[1], 'offset 1') && $this->assertEquals(new \util\Date('2002-02-21'), $list[2], 'offset 2');
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:6,代码来源:DateUtilTest.class.php

示例10: reflectedNameOfClass

 public function reflectedNameOfClass()
 {
     $class = $this->fixture->getClass();
     $this->assertEquals('net·xp_framework·unittest·core·generics·Lookup··String¸TestCase', xp::reflect($class->getName()));
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:5,代码来源:InstanceReflectionTest.class.php

示例11: reflect

 static function reflect($type)
 {
     if ('string' === $type || 'int' === $type || 'double' === $type || 'bool' == $type) {
         return '■' . $type;
     } else {
         if ('var' === $type) {
             return $type;
         } else {
             if ('[]' === substr($type, -2)) {
                 return 'д' . xp::reflect(substr($type, 0, -2));
             } else {
                 if ('[:' === substr($type, 0, 2)) {
                     return '╗' . xp::reflect(substr($type, 2, -1));
                 } else {
                     if (FALSE !== ($p = strpos($type, '<'))) {
                         $l = xp::reflect(substr($type, 0, $p)) . 'ии';
                         for ($args = substr($type, $p + 1, -1) . ',', $o = 0, $brackets = 0, $i = 0, $s = strlen($args); $i < $s; $i++) {
                             if (',' === $args[$i] && 0 === $brackets) {
                                 $l .= xp::reflect(ltrim(substr($args, $o, $i - $o))) . 'И';
                                 $o = $i + 1;
                             } else {
                                 if ('<' === $args[$i]) {
                                     $brackets++;
                                 } else {
                                     if ('>' === $args[$i]) {
                                         $brackets--;
                                     }
                                 }
                             }
                         }
                         return substr($l, 0, -1);
                     } else {
                         $l = array_search($type, xp::$cn, TRUE);
                         return $l ?: substr($type, FALSE === ($p = strrpos($type, '.')) ? 0 : $p + 1);
                     }
                 }
             }
         }
     }
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:40,代码来源:lang.base.php

示例12: generateHead

 /**
  * Generates the class header.
  * "class <name> extends <baseClass> implements IProxy, <interfaces> {"
  *
  * @param lang.XPClass baseClass
  * @param lang.XPClass[] interfaces
  * @return string 
  */
 private function generateHead($baseClass, $interfaces)
 {
     // Create proxy class' name, using a unique identifier and a prefix
     $name = $this->getProxyName();
     $bytes = 'class ' . $name . ' extends ' . xp::reflect($baseClass->getName()) . ' implements IMockProxy, ';
     for ($j = 0; $j < sizeof($interfaces); $j++) {
         $bytes .= xp::reflect($interfaces[$j]->getName()) . ', ';
     }
     $bytes = substr($bytes, 0, -2) . " {\n";
     return $bytes;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:19,代码来源:MockProxyBuilder.class.php

示例13: loadClass0

 /**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     if (isset(xp::$cl[$class])) {
         return xp::reflect($class);
     }
     // Load class
     $package = NULL;
     xp::$cl[$class] = $this->getClassName() . '://' . $this->path;
     xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         xp::$cll--;
         $decl = NULL;
         if (NULL === $package) {
             $decl = substr($class, FALSE === ($p = strrpos($class, '.')) ? 0 : $p + 1);
         } else {
             $decl = strtr($class, '.', '·');
         }
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($decl, FALSE) || interface_exists($decl, FALSE)) {
             raise('lang.ClassDependencyException', $class, array($this), $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         raise('lang.ClassLinkageException', $class, array($this), $e);
     }
     xp::$cll--;
     if (FALSE === $r) {
         unset(xp::$cl[$class]);
         $e = new ClassNotFoundException($class, array($this));
         xp::gc(__FILE__);
         throw $e;
     }
     // Register class name / literal mapping, which is one of the following:
     //
     // * No dot in the qualified class name -> ClassName
     // * Dotted version declares $package -> com·example·ClassName
     // * Dotted version resolves to a namespaced class -> com\example\ClassName
     // * Dotted version resolves to class in the global namespace -> ClassName
     //
     // Create aliases for dotted versions not resolving to namespaces
     if (FALSE === ($p = strrpos($class, '.'))) {
         $name = $class;
     } else {
         if (NULL !== $package) {
             $name = strtr($class, '.', '·');
             class_alias($name, strtr($class, '.', '\\'));
         } else {
             if (($ns = strtr($class, '.', '\\')) && (class_exists($ns, FALSE) || interface_exists($ns, FALSE))) {
                 $name = $ns;
             } else {
                 if (($cl = substr($class, $p + 1)) && (class_exists($cl, FALSE) || interface_exists($cl, FALSE))) {
                     $name = $cl;
                     class_alias($name, strtr($class, '.', '\\'));
                 } else {
                     unset(xp::$cl[$class]);
                     raise('lang.ClassFormatException', 'Class "' . $class . '" not declared in loaded file');
                 }
             }
         }
     }
     xp::$cn[$name] = $class;
     method_exists($name, '__static') && (xp::$cli[] = array($name, '__static'));
     if (0 === xp::$cll) {
         $invocations = xp::$cli;
         xp::$cli = array();
         foreach ($invocations as $inv) {
             call_user_func($inv);
         }
     }
     return $name;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:84,代码来源:AbstractClassLoader.class.php

示例14: generateMethod

 /**
  * Generates code for a method.
  * 
  * @param lang.reflect.Method method
  * @return string
  */
 private function generateMethod($method)
 {
     $bytes = '';
     // Build signature and argument list
     if ($method->hasAnnotation('overloaded')) {
         $signatures = $method->getAnnotation('overloaded', 'signatures');
         $methodax = 0;
         $cases = array();
         foreach ($signatures as $signature) {
             $args = sizeof($signature);
             $methodax = max($methodax, $args - 1);
             if (isset($cases[$args])) {
                 continue;
             }
             $cases[$args] = 'case ' . $args . ': ' . 'return $this->' . $this->getHandlerName() . '->invoke($this, \'' . $method->getName(TRUE) . '\', array(' . ($args ? '$_' . implode(', $_', range(0, $args - 1)) : '') . '));';
         }
         // Create method
         $bytes .= 'public function ' . $method->getName() . '($_' . implode('= NULL, $_', range(0, $methodax)) . '= NULL) { ' . 'switch (func_num_args()) {' . implode("\n", $cases) . ' default: throw new IllegalArgumentException(\'Illegal number of arguments\'); }' . '}' . "\n";
     } else {
         $signature = $args = '';
         foreach ($method->getParameters() as $param) {
             $restriction = $param->getTypeRestriction();
             $signature .= ', ' . ($restriction ? xp::reflect($restriction->getName()) : '') . ' $' . $param->getName();
             $args .= ', $' . $param->getName();
             $param->isOptional() && ($signature .= '= ' . var_export($param->getDefaultValue(), TRUE));
         }
         $signature = substr($signature, 2);
         $args = substr($args, 2);
         // Create method
         $bytes .= 'public function ' . $method->getName() . '(' . $signature . ') { ' . 'return $this->' . $this->getHandlerName() . '->invoke($this, \'' . $method->getName(TRUE) . '\', func_get_args()); ' . '}' . "\n";
     }
     return $bytes;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:39,代码来源:MockProxyBuilder.class.php

示例15: getPackages

 /**
  * Returns a list of subpackages in this package.
  *
  * @return  lang.reflect.Package[]
  */
 public function getPackages()
 {
     return array_map(array(xp::reflect('lang.reflect.Package'), 'forName'), $this->getPackageNames());
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:9,代码来源:Package.class.php


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