本文整理汇总了PHP中ReflectionClass::getExtensionName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::getExtensionName方法的具体用法?PHP ReflectionClass::getExtensionName怎么用?PHP ReflectionClass::getExtensionName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionClass
的用法示例。
在下文中一共展示了ReflectionClass::getExtensionName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getExtension
public function getExtension()
{
$extName = parent::getExtensionName();
if ($extName) {
return new MyReflectionExtension($extName);
} else {
return NULL;
}
}
示例2: generateClass
/**
* Called for every reflected class, interface or trait
*
* @param \ReflectionClass $class
* @param string $generated
* @param $generated
*/
public function generateClass(\ReflectionClass $class, $generated)
{
$this->addToExtension($class->getExtensionName(), $generated);
}
示例3: _getClass
/**
* Get all info about class (object)
* @param string|object $data Object or class name
* @return JBDump
*/
protected static function _getClass($data)
{
// check arg
if (is_object($data)) {
$className = get_class($data);
} elseif (is_string($data)) {
$className = $data;
} else {
return false;
}
if (!class_exists($className) && !interface_exists($className)) {
return false;
}
// create ReflectionClass object
$class = new ReflectionClass($data);
// get basic class info
$result['name'] = $class->name;
$result['type'] = $class->isInterface() ? 'interface' : 'class';
if ($classComment = $class->getDocComment()) {
$result['comment'] = $classComment;
}
if ($classPath = $class->getFileName()) {
$result['path'] = $classPath . ' ' . $class->getStartLine() . '/' . $class->getEndLine();
}
if ($classExtName = $class->getExtensionName()) {
$result['extension'] = $classExtName;
}
if ($class->isAbstract()) {
$result['abstract'] = true;
}
if ($class->isFinal()) {
$result['final'] = true;
}
// get all parents of class
$class_tmp = $class;
$result['parents'] = array();
while ($parent = $class_tmp->getParentClass()) {
if (isset($parent->name)) {
$result['parents'][] = $parent->name;
$class_tmp = $parent;
}
}
if (count($result['parents']) == 0) {
unset($result['parents']);
}
// reflecting class interfaces
$interfaces = $class->getInterfaces();
if (is_array($interfaces)) {
foreach ($interfaces as $property) {
$result['interfaces'][] = $property->name;
}
}
// reflection class constants
$constants = $class->getConstants();
if (is_array($constants)) {
foreach ($constants as $key => $property) {
$result['constants'][$key] = $property;
}
}
// reflecting class properties
$properties = $class->getProperties();
if (is_array($properties)) {
foreach ($properties as $key => $property) {
if ($property->isPublic()) {
$visible = "public";
} elseif ($property->isProtected()) {
$visible = "protected";
} elseif ($property->isPrivate()) {
$visible = "private";
} else {
$visible = "public";
}
$propertyName = $property->getName();
$result['properties'][$visible][$propertyName]['comment'] = $property->getDocComment();
$result['properties'][$visible][$propertyName]['static'] = $property->isStatic();
$result['properties'][$visible][$propertyName]['default'] = $property->isDefault();
$result['properties'][$visible][$propertyName]['class'] = $property->class;
}
}
// get source
$source = null;
if (isset($result['path']) && $result['path']) {
$source = @file($class->getFileName());
if (!empty($source)) {
$result['source::source'] = implode('', $source);
}
}
// reflecting class methods
foreach ($class->getMethods() as $key => $method) {
if ($method->isPublic()) {
$visible = "public";
} elseif ($method->isProtected()) {
$visible = "protected";
} elseif ($method->isPrivate()) {
$visible = "protected";
//.........这里部分代码省略.........
示例4: initVersionCompatibility
/**
* There was an api change between PHP 5.3.0alpha3 and 5.3.0beta1, the new
* extension name "Core" was introduced and interfaces like "Iterator" are
* now part of "Core" instead of "Standard".
*
* @return void
*/
private static function initVersionCompatibility()
{
$reflection = new ReflectionClass('Iterator');
$extension = strtolower($reflection->getExtensionName());
$extension = $extension === '' ? 'standard' : $extension;
if (defined('CORE_PACKAGE') === false) {
define('CORE_PACKAGE', '+' . $extension);
}
}
示例5: _resolveDepend
/**
* Resolve depend from class
* @param \ReflectionClass $class
* @return EntityClass
*/
private function _resolveDepend(\ReflectionClass $class)
{
if ($class->isInternal()) {
$this->addDepends($class->getExtensionName());
return new EntityClass($class->getName());
} elseif (isset($this->classes[$class->getName()])) {
return $this->classes[$class->getName()];
} else {
// todo: log the problem
$file = $this->files[$class->getFileName()] = new EntityFile($class->getFileName(), $this);
$file->scan();
$this->_addEntities($file);
}
}
示例6: gen_docs
function gen_docs($name, $type)
{
/* {{{ */
global $OPTION, $INFO;
if ($type & DOC_EXTENSION) {
try {
$extension = new ReflectionExtension($name);
$INFO['actual_extension'] = $name;
write_doc($extension, DOC_EXTENSION);
foreach ($extension->getClasses() as $class) {
gen_docs($class->name, DOC_CLASS);
}
foreach ($extension->getFunctions() as $function) {
gen_docs($function->name, DOC_FUNCTION);
}
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
} else {
if ($type & DOC_FUNCTION) {
try {
$function = new ReflectionFunction($name);
if (!$INFO['actual_extension']) {
if ($extname = $function->getExtensionName()) {
$INFO['actual_extension'] = $extname;
} else {
add_warning("The function {$name} lacks Reflection information");
}
}
write_doc($function, DOC_FUNCTION);
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
} else {
if ($type & DOC_METHOD) {
try {
$class = new ReflectionClass($OPTION['class']);
if (!$INFO['actual_extension']) {
if ($extname = $class->getExtensionName()) {
$INFO['actual_extension'] = $extname;
} else {
add_warning("The method {$name} lacks Reflection information");
}
}
foreach ($class->getMethods() as $method) {
/* Don't get the inherited methods */
if ($method->getDeclaringClass()->name == $class->name && (is_array($OPTION['method']) && in_array(strtolower($method->getName()), $OPTION['method']) || $OPTION['method'] == strtolower($method->getName()))) {
write_doc($method, $method->isConstructor() ? DOC_CONSTRUCTOR : DOC_METHOD);
}
}
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
} else {
if ($type & DOC_CLASS) {
try {
$class = new ReflectionClass($name);
if (!$INFO['actual_extension']) {
if ($extname = $class->getExtensionName()) {
$INFO['actual_extension'] = $extname;
} else {
add_warning("The class {$name} lacks Reflection information");
}
}
write_doc($class, DOC_CLASS);
foreach ($class->getMethods() as $method) {
/* Don't get the inherited methods */
if ($method->getDeclaringClass()->name == $class->name) {
write_doc($method, $method->isConstructor() ? DOC_CONSTRUCTOR : DOC_METHOD);
}
}
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
}
}
}
}
}
示例7: array
$err = 0;
$classes = array_merge(get_declared_classes(), get_declared_interfaces());
$extensions = array();
foreach (get_loaded_extensions() as $ext) {
$cnt_modules++;
if (strpos($ext, "_") !== false) {
$err++;
$extensions[$ext] = array();
}
}
$cnt_classes = count($classes);
foreach ($classes as $c) {
if (strpos($c, "_") !== false) {
$err++;
$ref = new ReflectionClass($c);
if (!($ext = $ref->getExtensionName())) {
$ext = $ref->isInternal() ? "<internal>" : "<user>";
}
if (!array_key_exists($ext, $extensions)) {
$extensions[$ext] = array();
}
$extensions[$ext][$c] = array();
foreach (get_class_methods($c) as $method) {
$cnt_methods++;
if (strpos(substr($method, substr($method, 0, 2) != "__" ? 0 : 2), "_") !== false) {
$err++;
$extensions[$ext][$c][] = $method;
}
}
} else {
$cnt_methods += count(get_class_methods($c));
示例8: ReflectionClass
<?php
$ref = new ReflectionClass('ReflectionClass');
var_dump($ref->getExtension() instanceof ReflectionExtension);
var_dump(is_string($ref->getExtensionName()));