本文整理汇总了PHP中ReflectionMethod::getPrototype方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::getPrototype方法的具体用法?PHP ReflectionMethod::getPrototype怎么用?PHP ReflectionMethod::getPrototype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionMethod
的用法示例。
在下文中一共展示了ReflectionMethod::getPrototype方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readMethodAnnotations
/**
* Reads all supported method annotations.
*
* @param stirng $className
* @param \ReflectionMethod $method
*
* @return array
*/
private function readMethodAnnotations($className, \ReflectionMethod $method)
{
$annotations = array();
// Read parent annotations.
try {
$prototype = $method->getPrototype();
$annotations = array_merge($annotations, $this->readMethodAnnotations($className, $prototype));
} catch (\ReflectionException $e) {
}
// Read method annotations.
if ($docBlock = $method->getDocComment()) {
$description = NULL;
foreach (explode("\n", $docBlock) as $docLine) {
$docLine = preg_replace('/^\\/\\*\\*\\s*|^\\s*\\*\\s*|\\s*\\*\\/$|\\s*$/', '', $docLine);
if (preg_match('/^\\@(' . $this->availableAnnotations . ')\\s*(.*)?$/i', $docLine, $matches)) {
$class = $this->annotationClasses[strtolower($matches[1])];
$callback = array($className, $method->getName());
if (isset($matches[2]) && !empty($matches[2])) {
$annotation = new $class($callback, $matches[2]);
} else {
$annotation = new $class($callback);
}
if (NULL !== $description) {
$annotation->setDescription($description);
}
$annotations[] = $annotation;
} elseif (NULL === $description && '' !== $docLine && FALSE === strpos($docLine, '@')) {
$description = $docLine;
}
}
}
return $annotations;
}
示例2: getPrototype
/**
* Gets the method prototype (if there is one).
*
* @return A `ReflectionMethod` instance of the method prototype.
* @throws ReflectionException if the method does not have a prototype.
*/
public function getPrototype()
{
/* @var \ReflectionMethod $prototype */
/* @var \ReflectionClass $class */
$prototype = parent::getPrototype();
$class = $prototype->getDeclaringClass();
return new self($class->getName(), $prototype->getName());
}
示例3: getPrototype
/**
* Returns the prototype.
*
* This is mostly a wrapper method, which calls the corresponding method of
* the parent class. The only difference is that it returns an instance
* ezcReflectionClass instead of a ReflectionClass instance
* @return ezcReflectionClass Prototype
* @throws ReflectionException if the method has no prototype
*/
public function getPrototype()
{
if ($this->reflectionSource instanceof parent) {
$prototype = $this->reflectionSource->getPrototype();
} else {
$prototype = parent::getPrototype();
}
return new ezcReflectionClass($prototype->getName());
}
示例4: readMethodAnnotations
/**
* Reads all supported method annotations.
*
* @param string $className
* @param \ReflectionMethod $method
*
* @return array
*/
private function readMethodAnnotations($className, \ReflectionMethod $method)
{
$annotations = array();
// read parent annotations
try {
$prototype = $method->getPrototype();
// error occurs on PHP 5.4.11+ when the same trait is used by a parent and the child class
if ($prototype->getDeclaringClass()->getName() !== $method->getDeclaringClass()->getName()) {
$annotations = array_merge($annotations, $this->readMethodAnnotations($className, $prototype));
}
} catch (\ReflectionException $e) {
}
// read method annotations
if ($docBlock = $method->getDocComment()) {
$description = null;
foreach (explode("\n", $docBlock) as $docLine) {
$docLine = preg_replace('/^\\/\\*\\*\\s*|^\\s*\\*\\s*|\\s*\\*\\/$|\\s*$/', '', $docLine);
if (preg_match('/^\\@(' . $this->availableAnnotations . ')\\s*(.*)?$/i', $docLine, $matches)) {
$class = $this->annotationClasses[strtolower($matches[1])];
$callback = array($className, $method->getName());
if (isset($matches[2]) && !empty($matches[2])) {
$annotation = new $class($callback, $matches[2]);
} else {
$annotation = new $class($callback);
}
if (null !== $description) {
$annotation->setDescription($description);
}
$annotations[] = $annotation;
} elseif (null === $description && '' !== $docLine && false === strpos($docLine, '@')) {
$description = $docLine;
}
}
}
return $annotations;
}
示例5: getPrototype
/**
* @return Method
*/
public function getPrototype()
{
$prototype = parent::getPrototype();
return new Method($prototype->getDeclaringClass()->getName(), $prototype->getName());
}
示例6: getInheritDoc
/**
* @param \ReflectionMethod $reflectionMethod
* @return DocBlock
*/
protected function getInheritDoc($reflectionMethod)
{
$parentClass = $reflectionMethod->getDeclaringClass()->getParentClass();
//Get either a parent or the interface
if ($parentClass) {
$method = $parentClass->getMethod($reflectionMethod->getName());
} else {
$method = $reflectionMethod->getPrototype();
}
if ($method) {
$namespace = $method->getDeclaringClass()->getNamespaceName();
$phpdoc = new DocBlock($method, new Context($namespace));
if (strpos($phpdoc->getText(), '{@inheritdoc}') !== false) {
//Not at the end yet, try another parent/interface..
return $this->getInheritDoc($method);
} else {
return $phpdoc;
}
}
}
示例7: getPrototype
function getPrototype()
{
$prototype = parent::getPrototype();
return new NMethodReflection($prototype->getDeclaringClass()->getName(), $prototype->getName());
}
示例8: getPrototype
/**
* Returns the method prototype.
*
* @return \TokenReflection\Php\ReflectionMethod
*/
public function getPrototype()
{
return self::create(parent::getPrototype(), $this->broker);
}
示例9: isImplementMethod
/**
* Returns whether the method is implement method.
*
* @param \ReflectionMethod $method ReflectionMethod object.
* @param \ReflectionClass &$declaringClass Output parameter for Declaring class.
* @return bool true if the method is implement method, false otherwise.
*/
protected function isImplementMethod(\ReflectionMethod $method, &$declaringClass)
{
try {
$declaringClass = $method->getPrototype()->getDeclaringClass();
if ($declaringClass->isInterface()) {
return true;
}
if ($declaringClass->getMethod($method->getName())->isAbstract()) {
return true;
}
return false;
} catch (\ReflectionException $e) {
return null;
}
}