本文整理汇总了PHP中ReflectionClass::getDeclaringClass方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::getDeclaringClass方法的具体用法?PHP ReflectionClass::getDeclaringClass怎么用?PHP ReflectionClass::getDeclaringClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionClass
的用法示例。
在下文中一共展示了ReflectionClass::getDeclaringClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: asInstance
/**
* @param object|NULL
* @return AccessBase $this
*/
public function asInstance($object)
{
if (is_object($object)) {
if ($this->reflection instanceof ReflectionClass) {
$class = $this->reflection->getName();
} else {
$class = $this->reflection->getDeclaringClass()->getName();
}
if (!$object instanceof $class) {
throw new Exception('Must be instance of accessible class.');
}
} else {
if ($object !== NULL) {
throw new Exception('Instance must be object or NULL.');
}
}
$this->instance = $object;
return $this;
}
示例2: extractTagsFromComment
/**
* @param string $comment
* @param string $current_tag
* @param \ReflectionMethod|\ReflectionClass $reflection
* @return array
*/
private function extractTagsFromComment($comment, $current_tag = 'description', $reflection)
{
$ns = $reflection instanceof \ReflectionClass ? $reflection->getNamespaceName() : $reflection->getDeclaringClass()->getNamespaceName();
$tags = array($current_tag => '');
foreach (explode(PHP_EOL, $comment) as $line) {
if ($current_tag != 'example') {
$line = trim($line);
}
$words = explode(' ', trim($line));
if (strpos($words[0], '@') === false) {
// Append to tag
$joinWith = $current_tag == 'example' ? PHP_EOL : ' ';
$tags[$current_tag] .= $joinWith . $line;
} elseif ($words[0] == '@param') {
// Get parameter declaration
if ($paramData = $this->figureOutParamDeclaration($words, $ns)) {
list($name, $data) = $paramData;
$tags['params'][$name] = $data;
}
} else {
// Start new tag
$current_tag = substr($words[0], 1);
array_splice($words, 0, 1);
if (empty($tags[$current_tag])) {
$tags[$current_tag] = '';
}
$tags[$current_tag] .= trim(join(' ', $words));
}
}
foreach ($tags as $name => $val) {
if (is_array($val)) {
foreach ($val as $subName => $subVal) {
if (is_string($subVal)) {
$tags[$name][$subName] = trim($subVal);
}
}
} else {
$tags[$name] = trim($val);
}
}
return $tags;
}
示例3: getNameSpace
/**
* @param \ReflectionClass|\ReflectionMethod $reflection
* @return string
*/
private function getNameSpace($reflection)
{
if ($reflection instanceof \ReflectionClass) {
return $reflection->getNamespaceName();
} else {
return $reflection->getDeclaringClass()->getNamespaceName();
}
}