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


PHP ReflectionClass::getExtension方法代码示例

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


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

示例1: cacheEntityClass

 protected static function cacheEntityClass($classname, $reflection_classname = null)
 {
     $rc_name = $reflection_classname !== null ? $reflection_classname : $classname;
     try {
         $reflection = new \ReflectionClass($rc_name);
         $annotationset = new AnnotationSet($reflection->getDocComment());
         if (!$annotationset->hasAnnotations()) {
             throw new Exception('Empty annotationset!');
         }
     } catch (\Exception $e) {
         throw new Exception("An error occured when trying to load the database details for class {$classname}: " . $e->getMessage());
     }
     if ($reflection_classname === null) {
         self::$_cached_entity_classes[$classname] = array('columns' => array(), 'relations' => array(), 'foreign_columns' => array());
         if (!($annotation = $annotationset->getAnnotation('Table'))) {
             throw new Exception("The class '{$classname}' is missing a valid @Table annotation");
         } else {
             $tablename = $annotation->getProperty('name');
         }
         if (!\class_exists($tablename)) {
             throw new Exception("The class table class '{$tablename}' for class '{$classname}' does not exist");
         }
         self::$_cached_entity_classes[$classname]['table'] = $tablename;
         self::_populateCachedTableClassFiles($tablename);
         if (($re = $reflection->getExtension()) && ($classnames = $re->getClassNames())) {
             foreach ($classnames as $extends_classname) {
                 self::cacheEntityClass($classname, $extends_classname);
             }
         }
     }
     if (!\array_key_exists('name', self::$_cached_table_classes[self::$_cached_entity_classes[$classname]['table']])) {
         throw new Exception("The class @Table annotation in '" . self::$_cached_entity_classes[$classname]['table'] . "' is missing required 'name' property");
     }
     $column_prefix = self::$_cached_table_classes[self::$_cached_entity_classes[$classname]['table']]['name'] . '.';
     foreach ($reflection->getProperties() as $property) {
         if ($property instanceof \ReflectionProperty) {
         }
         $annotationset = new AnnotationSet($property->getDocComment());
         if ($annotationset->hasAnnotations()) {
             $property_name = $property->getName();
             if ($column_annotation = $annotationset->getAnnotation('Column')) {
                 $column_name = $column_prefix . ($column_annotation->hasProperty('name') ? $column_annotation->getProperty('name') : substr($property_name, 1));
                 $column = array('property' => $property_name, 'default_value' => $column_annotation->hasProperty('default') ? $column_annotation->getProperty('default') : null, 'not_null' => $column_annotation->hasProperty('not_null') ? $column_annotation->getProperty('not_null') : false, 'name' => $column_name, 'type' => $column_annotation->getProperty('type'));
                 switch ($column['type']) {
                     case 'varchar':
                     case 'string':
                         $column['type'] = 'varchar';
                         $column['length'] = $column_annotation->hasProperty('length') ? $column_annotation->getProperty('length') : null;
                         break;
                     case 'float':
                         $column['precision'] = $column_annotation->hasProperty('precision') ? $column_annotation->getProperty('precision') : 2;
                     case 'integer':
                         $column['auto_inc'] = $column_annotation->hasProperty('auto_increment') ? $column_annotation->getProperty('auto_increment') : false;
                         $column['unsigned'] = $column_annotation->hasProperty('unsigned') ? $column_annotation->getProperty('unsigned') : false;
                         $column['length'] = $column_annotation->hasProperty('length') ? $column_annotation->getProperty('length') : 10;
                         if ($column['type'] != 'float') {
                             $column['default_value'] = $column_annotation->hasProperty('default') ? $column_annotation->getProperty('default') : 0;
                         }
                         break;
                 }
                 self::$_cached_entity_classes[$classname]['columns'][$column_name] = $column;
             }
             if ($annotation = $annotationset->getAnnotation('Id')) {
                 self::$_cached_entity_classes[$classname]['id_column'] = $column_name;
             }
             if ($annotation = $annotationset->getAnnotation('Relates')) {
                 $value = $annotation->getProperty('class');
                 $collection = (bool) $annotation->getProperty('collection');
                 $manytomany = (bool) $annotation->getProperty('manytomany');
                 $joinclass = $annotation->getProperty('joinclass');
                 $foreign_column = $annotation->getProperty('foreign_column');
                 $orderby = $annotation->getProperty('orderby');
                 $f_column = $annotation->getProperty('column');
                 self::$_cached_entity_classes[$classname]['relations'][$property_name] = array('collection' => $collection, 'property' => $property_name, 'foreign_column' => $foreign_column, 'manytomany' => $manytomany, 'joinclass' => $joinclass, 'class' => $annotation->getProperty('class'), 'column' => $f_column, 'orderby' => $orderby);
                 if (!$collection) {
                     if (!$column_annotation) {
                         throw new Exception("The property '{$property_name}' in class '{$classname}' is missing an @Column annotation, or is improperly marked as not being a collection");
                     }
                     $column_name = $column_prefix . ($annotation->hasProperty('name') ? $annotation->getProperty('name') : substr($property_name, 1));
                     $column['class'] = self::getCachedB2DBTableClass($value);
                     $column['key'] = $annotation->hasProperty('key') ? $annotation->getProperty('key') : null;
                     self::$_cached_entity_classes[$classname]['foreign_columns'][$column_name] = $column;
                 }
             }
         }
     }
     if (self::$_cache_enabled && !self::$_debug_mode) {
         $key = 'b2db_cache_' . $classname;
         \TBGCache::add($key, self::$_cached_entity_classes[$classname], false);
         \TBGCache::fileAdd($key, self::$_cached_entity_classes[$classname], false);
     }
 }
开发者ID:oparoz,项目名称:thebuggenie,代码行数:92,代码来源:Core.class.php

示例2: getExtension

 /**
  * Returns the PHP extension reflection.
  *
  * @return \TokenReflection\Php\ReflectionExtension
  */
 public function getExtension()
 {
     return ReflectionExtension::create(parent::getExtension(), $this->broker);
 }
开发者ID:kornrunner,项目名称:PHP-Token-Reflection,代码行数:9,代码来源:ReflectionClass.php

示例3: populate_method_info

/**
 * returns an array containing a record for each defined method.
 */
function populate_method_info()
{
    $method_info = array();
    // get functions
    $all_functions = get_defined_functions();
    $internal_functions = $all_functions["internal"];
    foreach ($internal_functions as $function) {
        // populate new method record
        $function_record = array();
        $function_record[CLASS_NAME] = "Function";
        $function_record[METHOD_NAME] = $function;
        $function_record[IS_TESTED] = "no";
        $function_record[TESTS] = "";
        $function_record[IS_DUPLICATE] = false;
        // record the extension that the function belongs to
        $reflectionFunction = new ReflectionFunction($function);
        $extension = $reflectionFunction->getExtension();
        if ($extension != null) {
            $function_record[EXTENSION_NAME] = $extension->getName();
        } else {
            $function_record[EXTENSION_NAME] = "";
        }
        // insert new method record into info array
        $method_info[] = $function_record;
    }
    // get methods
    $all_classes = get_declared_classes();
    foreach ($all_classes as $class) {
        $reflectionClass = new ReflectionClass($class);
        $methods = $reflectionClass->getMethods();
        foreach ($methods as $method) {
            // populate new method record
            $new_method_record = array();
            $new_method_record[CLASS_NAME] = $reflectionClass->getName();
            $new_method_record[METHOD_NAME] = $method->getName();
            $new_method_record[IS_TESTED] = "no";
            $new_method_record[TESTS] = "";
            $extension = $reflectionClass->getExtension();
            if ($extension != null) {
                $new_method_record[EXTENSION_NAME] = $extension->getName();
            } else {
                $new_method_record[EXTENSION_NAME] = "";
            }
            // check for duplicate method names
            $new_method_record[IS_DUPLICATE] = false;
            foreach ($method_info as &$current_record) {
                if (strcmp($current_record[METHOD_NAME], $new_method_record[METHOD_NAME]) == 0) {
                    $new_method_record[IS_DUPLICATE] = true;
                    $current_record[IS_DUPLICATE] = true;
                }
            }
            // insert new method record into info array
            $method_info[] = $new_method_record;
        }
    }
    return $method_info;
}
开发者ID:cefalo19,项目名称:php-src,代码行数:60,代码来源:find_tested.php

示例4: getExtension

 function getExtension()
 {
     return ($ref = parent::getExtension()) ? ExtensionReflection::import($ref) : NULL;
 }
开发者ID:romcok,项目名称:google-translator,代码行数:4,代码来源:loader.php

示例5: ReflectionClass

<?php

$ref = new ReflectionClass('ReflectionClass');
var_dump($ref->getExtension() instanceof ReflectionExtension);
var_dump(is_string($ref->getExtensionName()));
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:ReflectionClass_extension.php


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