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


PHP ReflectionExtension::getClasses方法代码示例

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


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

示例1: exportFiles

 /**
  * Exports all PHP files for this extension
  *
  * @param string $directory
  * @param bool   $create_sub_directories
  *
  * @throws \Exception
  * @throws \InvalidArgumentException
  */
 public function exportFiles($directory, $create_sub_directories = true)
 {
     $dir = realpath($directory);
     if (empty($dir) || !file_exists($dir)) {
         throw new \InvalidArgumentException("Directory does not exist: {$directory}");
     }
     foreach ($this->_extension->getClasses() as $class) {
         $reflection_class = new ReflectionClass($class);
         $current_dir = $dir;
         if ($create_sub_directories) {
             $namespaces = explode('\\', $class->getNamespaceName());
             array_shift($namespaces);
             $sub_dirs = join(DIRECTORY_SEPARATOR, $namespaces);
             if (!empty($sub_dirs)) {
                 $current_dir = $dir . DIRECTORY_SEPARATOR . $sub_dirs;
                 if (!file_exists($current_dir) && !@mkdir($current_dir, 0755, true)) {
                     throw new \Exception('Could not create sub directories: ' . $sub_dirs);
                 }
             }
         }
         $filename = $reflection_class->getClassName() . '.php';
         $file_path = $current_dir . DIRECTORY_SEPARATOR . $filename;
         $result = file_put_contents($file_path, $reflection_class->exportCode());
         if ($result === false) {
             throw new \Exception('Could not create file: ' . $file_path);
         }
     }
 }
开发者ID:michalkoslab,项目名称:Helpers,代码行数:37,代码来源:ReflectionExtension.php

示例2: getClasses

 /**
  * Returns an array containing ezcReflectionClass objects for all
  * classes of this extension
  * @return ezcReflectionClass[]
  */
 public function getClasses()
 {
     if ($this->reflectionSource) {
         $classes = $this->reflectionSource->getClasses();
     } else {
         $classes = parent::getClasses();
     }
     $result = array();
     foreach ($classes as $class) {
         $result[] = new ezcReflectionClass($class);
     }
     return $result;
 }
开发者ID:naderman,项目名称:pflow,代码行数:18,代码来源:extension.php

示例3: getTagsForExtension

 /**
  * @return array
  */
 protected function getTagsForExtension($name)
 {
     if (!extension_loaded($name)) {
         return array();
     }
     $tags = array();
     $module = new \ReflectionExtension($name);
     // Export constants.
     foreach ($module->getConstants() as $name => $value) {
         $tags[] = new Tag($name, 'constant', Tag::DEFINITION);
     }
     // Export functions.
     foreach ($module->getFunctions() as $function) {
         $tags[] = new Tag($function->getName(), 'function', TAG::DEFINITION);
     }
     // Export classes.
     foreach ($module->getClasses() as $class) {
         $tags[] = new Tag($class->getName(), 'class', TAG::DEFINITION);
         foreach ($class->getMethods() as $method) {
             $tags[] = new Tag(sprintf('%s::%s', $class->getName(), $method->getName()), 'function', TAG::DEFINITION);
         }
         foreach ($class->getProperties() as $property) {
             $tags[] = new Tag(sprintf('%s::%s', $class->getName(), $property->getName()), 'variable', TAG::DEFINITION);
         }
         foreach ($class->getConstants() as $constant => $value) {
             $tags[] = new Tag(sprintf('%s::%s', $class->getName(), $constant), 'constant', TAG::DEFINITION);
         }
     }
     return $tags;
 }
开发者ID:hexmode,项目名称:phptags,代码行数:33,代码来源:ExtensionTags.php

示例4: prepare_storage

 public function prepare_storage()
 {
     // Generate tables
     midgard_storage::create_base_storage();
     // And update as necessary
     $re = new ReflectionExtension('midgard2');
     $classes = $re->getClasses();
     foreach ($classes as $refclass) {
         if ($refclass->isAbstract() || $refclass->isInterface()) {
             continue;
         }
         $type = $refclass->getName();
         if (!is_subclass_of($type, 'MidgardDBObject')) {
             continue;
         }
         if (midgard_storage::class_storage_exists($type)) {
             // FIXME: Skip updates until http://trac.midgard-project.org/ticket/1426 is fixed
             continue;
             if (!midgard_storage::update_class_storage($type)) {
                 $this->markTestSkipped('Could not update ' . $type . ' tables in test database');
             }
             continue;
         }
         if (!midgard_storage::create_class_storage($type)) {
             $this->markTestSkipped('Could not create ' . $type . ' tables in test database');
         }
     }
     // And update as necessary
     return;
     if (!midgard_user::auth('root', 'password')) {
         echo "auth failed\n";
         $this->markTestSkipped('Could not authenticate as ROOT');
     }
 }
开发者ID:bergie,项目名称:midgardmvc_core,代码行数:34,代码来源:midgard.php

示例5: getClasses

 public function getClasses()
 {
     $classes = parent::getClasses();
     $result = array();
     foreach ($classes as $class) {
         $result[] = new MyReflectionClass($class->getName());
     }
     return $result;
 }
开发者ID:zetacomponents,项目名称:reflection,代码行数:9,代码来源:MyReflectionExtension.php

示例6: __construct

 public function __construct()
 {
     parent::__construct();
     foreach (get_loaded_extensions() as $ext) {
         $re = new \ReflectionExtension($ext);
         $extensions = $this->append(NULL, array($ext, $re));
         $this->addFunctions($extensions, $re->getFunctions());
         $this->addClasses($extensions, $re->getClasses());
     }
 }
开发者ID:johannes,项目名称:php-explorer,代码行数:10,代码来源:ExtensionTree.php

示例7: getClasses

 public function getClasses()
 {
     $phpReflections = parent::getClasses();
     $zendReflections = array();
     while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
         $zendReflections[] = new ZendL_Reflection_Class($phpReflection->getName());
         unset($phpReflection);
     }
     unset($phpReflections);
     return $zendReflections;
 }
开发者ID:lortnus,项目名称:zf1,代码行数:11,代码来源:Extension.php

示例8: getClasses

 /**
  * Get all this extensions classes
  *
  * @return    Nerd\Design\Collection     Enumerable array of extension classes
  */
 public function getClasses()
 {
     if ($this->classes === null) {
         $classes = parent::getClasses();
         foreach ($classes as $key => $class) {
             $classes[$key] = new Klass($class->getName());
         }
         $this->classes = new Collection($classes);
     }
     return $this->classes;
 }
开发者ID:nerdsrescueme,项目名称:Core,代码行数:16,代码来源:extension.php

示例9: getClasses

 /**
  * Get extension class reflection objects
  *
  * @param  string $reflectionClass Name of reflection class to use
  * @return array Array of Zend_Reflection_Class objects
  */
 public function getClasses($reflectionClass = 'Zend_Reflection_Class')
 {
     $phpReflections = parent::getClasses();
     $zendReflections = array();
     while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
         $instance = new $reflectionClass($phpReflection->getName());
         if (!$instance instanceof Zend_Reflection_Class) {
             throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class');
         }
         $zendReflections[] = $instance;
         unset($phpReflection);
     }
     unset($phpReflections);
     return $zendReflections;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:21,代码来源:Extension.php

示例10: getTypes

 private function getTypes()
 {
     $mgdschemas = array();
     $re = new \ReflectionExtension('midgard2');
     $classes = $re->getClasses();
     foreach ($classes as $refclass) {
         $parent_class = $refclass->getParentClass();
         if (!$parent_class) {
             continue;
         }
         if ($parent_class->getName() != 'midgard_object') {
             continue;
         }
         $mgdschemas[$include_views][] = $refclass->getName();
     }
     return $mgdschemas;
 }
开发者ID:rambo,项目名称:jackalope,代码行数:17,代码来源:Midgard2.php

示例11: get_mgdschema_classes

 public function get_mgdschema_classes()
 {
     static $mgdschemas = array();
     if (empty($mgdschemas)) {
         // Get the classes from PHP5 reflection
         $re = new ReflectionExtension('midgard2');
         $classes = $re->getClasses();
         foreach ($classes as $refclass) {
             $parent_class = $refclass->getParentClass();
             if (!$parent_class) {
                 continue;
             }
             if ($parent_class->getName() == 'midgard_object') {
                 $mgdschemas[] = $refclass->getName();
             }
         }
     }
     return $mgdschemas;
 }
开发者ID:piotras,项目名称:midgardmvc_core,代码行数:19,代码来源:mjolnir.php

示例12: introspect

 public function introspect(\ReflectionExtension $extension)
 {
     $classes = $functions = $constants = array();
     foreach ($extension->getClasses() as $class) {
         assert($class instanceof \ReflectionClass);
         $phpClass = PhpClass::fromReflection($class);
         $classes[] = $phpClass;
     }
     foreach ($extension->getFunctions() as $function) {
         assert($function instanceof \ReflectionFunction);
         $phpFunction = PhpFunction::fromReflection($function);
         $functions[] = $phpFunction;
     }
     foreach ($extension->getConstants() as $name => $value) {
         $phpConstant = new PhpConstant($name);
         $phpConstant->setValue($value);
         $constants[] = $phpConstant;
     }
     return array('classes' => $classes, 'functions' => $functions, 'constants' => $constants);
 }
开发者ID:norrs,项目名称:php-stubs,代码行数:20,代码来源:ExtensionIntrospector.php

示例13: export_ext

function export_ext($ext)
{
    $rf_ext = new ReflectionExtension($ext);
    $funcs = $rf_ext->getFunctions();
    $classes = $rf_ext->getClasses();
    $consts = $rf_ext->getConstants();
    $version = $rf_ext->getVersion();
    $defines = '';
    $sp4 = str_repeat(' ', 4);
    $fdefs = getFuncDef($funcs, $version);
    $class_def = '';
    foreach ($consts as $k => $v) {
        if (!is_numeric($v)) {
            $v = "'{$v}'";
        }
        $defines .= "define('{$k}',{$v});\n";
    }
    foreach ($classes as $k => $v) {
        $prop_str = '';
        $props = $v->getProperties();
        array_walk($props, function ($v, $k) {
            global $prop_str, $sp4;
            $modifiers = implode(' ', Reflection::getModifierNames($v->getModifiers()));
            $prop_str .= "{$sp4}/**\n{$sp4}*@var \$" . $v->name . " " . $v->class . "\n{$sp4}*/\n{$sp4} {$modifiers}  \$" . $v->name . ";\n\n";
        });
        if ($v->getParentClass()) {
            $k .= ' extends ' . $v->getParentClass()->name;
        }
        $modifier = 'class';
        if ($v->isInterface()) {
            $modifier = 'interface';
        }
        $mdefs = getMethodsDef($v->getMethods(), $version);
        $class_def .= sprintf("/**\n*@since %s\n*/\n%s %s{\n%s%s\n}\n", $version, $modifier, $k, $prop_str, $mdefs);
    }
    if (!file_exists('./ext')) {
        mkdir('./ext', 777, TRUE);
    }
    file_put_contents("./ext/" . $ext . ".php", "<?php\n" . $defines . $fdefs . $class_def);
}
开发者ID:CraryPrimitiveMan,项目名称:code-examples,代码行数:40,代码来源:getExtFuncs.php

示例14: openpsa_prepare_database

/**
 * Prepares a mgd2 database
 */
function openpsa_prepare_database($config)
{
    if (!$config->create_blobdir()) {
        throw new Exception("Failed to create file attachment storage directory to {$config->blobdir}:" . midgard_connection::get_instance()->get_error_string());
    }
    // Create storage
    if (!midgard_storage::create_base_storage()) {
        if (midgard_connection::get_instance()->get_error_string() != 'MGD_ERR_OK') {
            throw new Exception("Failed to create base database structures" . midgard_connection::get_instance()->get_error_string());
        }
    }
    $re = new ReflectionExtension('midgard2');
    $classes = $re->getClasses();
    foreach ($classes as $refclass) {
        if (!$refclass->isSubclassOf('midgard_object')) {
            continue;
        }
        $type = $refclass->getName();
        midgard_storage::create_class_storage($type);
        midgard_storage::update_class_storage($type);
    }
}
开发者ID:nemein,项目名称:openpsa,代码行数:25,代码来源:bootstrap.php

示例15: export

 function export()
 {
     /**
      * 获取所有define常量
      */
     $consts = $this->rf_ext->getConstants();
     $defines = '';
     foreach ($consts as $className => $ref) {
         if (!is_numeric($ref)) {
             $ref = "'{$ref}'";
         }
         $defines .= "define('{$className}', {$ref});\n";
     }
     file_put_contents(OUTPUT_DIR . '/constants.php', "<?php\n" . $defines);
     /**
      * 获取所有函数
      */
     $funcs = $this->rf_ext->getFunctions();
     $fdefs = $this->getFunctionsDef($funcs);
     file_put_contents(OUTPUT_DIR . '/functions.php', "<?php\n" . $fdefs);
     /**
      * 获取所有类
      */
     $classes = $this->rf_ext->getClasses();
     $class_alias = "<?php\n";
     foreach ($classes as $className => $ref) {
         //命名空间
         if (strchr($className, '\\')) {
             $this->exportNamespaceClass($className, $ref);
             continue;
         } else {
             $class_alias .= sprintf("\nclass %s extends %s\n{\n\n}\n", $className, self::getNamespaceAlias($className));
         }
     }
     file_put_contents(OUTPUT_DIR . '/classes.php', $class_alias);
 }
开发者ID:google2013,项目名称:swoole-src,代码行数:36,代码来源:dump.php


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