Note that the public member $class contains the name of the class in which the method has been defined:
<?php
class A {public function __construct() {}}
class B extends A {}
$method = new ReflectionMethod('B', '__construct');
echo $method->class; // prints 'A'
?>
The ReflectionMethod class
Introduction
کلاس ReflectionMethod اطلاعاتی درباره متد ارائه میدهد.
Class synopsis
Properties
- name
-
Prop description
- class
-
Prop description
Predefined Constants
ReflectionMethod Node Types
- ReflectionMethod::IS_STATIC
-
Description here...
- ReflectionMethod::IS_PUBLIC
-
Description here...
- ReflectionMethod::IS_PROTECTED
-
Description here...
- ReflectionMethod::IS_PRIVATE
-
Description here...
- ReflectionMethod::IS_ABSTRACT
-
Description here...
- ReflectionMethod::IS_FINAL
-
Description here...
Table of Contents
- ReflectionMethod::__construct — ساخت ReflectionMethod
- ReflectionMethod::export — ارسال
- ReflectionMethod::getDeclaringClass — دریافت اعلام کلاس
- ReflectionMethod::getModifiers — دریافت تغییر دهندهها
- ReflectionMethod::getPrototype — دریافت prototype
- ReflectionMethod::invoke — احضار
- ReflectionMethod::invokeArgs — احضار آرگومانها
- ReflectionMethod::isAbstract — بررسی انتزاعی بودن متد
- ReflectionMethod::isConstructor — بررسی سازنده بودن متد
- ReflectionMethod::isDestructor — بررسی نابودگر بودن متد
- ReflectionMethod::isFinal — بررسی نهایی بودن متد
- ReflectionMethod::isPrivate — بررسی خصوصی بودن متد
- ReflectionMethod::isProtected — بررسی حفاظت شده بودن متد
- ReflectionMethod::isPublic — بررسی عمومی بودن متد
- ReflectionMethod::isStatic — بررسی استاتیک بودن متد
- ReflectionMethod::setAccessible — تعیین دسترسی متد
- ReflectionMethod::__toString — به رشته
webseiten dot designer at googlemail dot com ¶
2 years ago
no dot prob at gmx dot net ¶
6 years ago
I have written a function which returns the value of a given DocComment tag.
Full example:
<?php
header('Content-Type: text/plain');
class Example
{
/**
* This is my DocComment!
*
* @DocTag: prints Hello World!
*/
public function myMethod()
{
echo 'Hello World!';
}
}
function getDocComment($str, $tag = '')
{
if (empty($tag))
{
return $str;
}
$matches = array();
preg_match("/".$tag.":(.*)(\\r\\n|\\r|\\n)/U", $str, $matches);
if (isset($matches[1]))
{
return trim($matches[1]);
}
return '';
}
$method = new ReflectionMethod('Example', 'myMethod');
// will return Hello World!
echo getDocComment($method->getDocComment(), '@DocTag');
?>
Maybe you can add this functionality to the getDocComment methods of the reflection classes.
