downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ReflectionMethod::__construct> <ReflectionFunctionAbstract::__toString
[edit] Last updated: Fri, 10 Feb 2012

view this page in

La classe ReflectionMethod

(PHP 5)

Introduction

La classe ReflectionMethod rapporte des informations sur une méthode.

Synopsis de la classe

ReflectionMethod extends ReflectionFunctionAbstract implements Reflector {
/* Constantes */
const integer IS_STATIC = 1 ;
const integer IS_PUBLIC = 256 ;
const integer IS_PROTECTED = 512 ;
const integer IS_PRIVATE = 1024 ;
const integer IS_ABSTRACT = 2 ;
const integer IS_FINAL = 4 ;
/* Propriétés */
public $class ;
/* Méthodes */
public ReflectionMethod::__construct ( mixed $class , string $name )
public static string ReflectionMethod::export ( string $class , string $name [, bool $return = false ] )
public Closure ReflectionMethod::getClosure ( string $object )
public ReflectionClass ReflectionMethod::getDeclaringClass ( void )
public int ReflectionMethod::getModifiers ( void )
public ReflectionMethod ReflectionMethod::getPrototype ( void )
public mixed ReflectionMethod::invoke ( object $object [, mixed $parameter [, mixed $... ]] )
public mixed ReflectionMethod::invokeArgs ( object $object , array $args )
public bool ReflectionMethod::isAbstract ( void )
public bool ReflectionMethod::isConstructor ( void )
public bool ReflectionMethod::isDestructor ( void )
public bool ReflectionMethod::isFinal ( void )
public bool ReflectionMethod::isPrivate ( void )
public bool ReflectionMethod::isProtected ( void )
public bool ReflectionMethod::isPublic ( void )
public bool ReflectionMethod::isStatic ( void )
public void ReflectionMethod::setAccessible ( bool $accessible )
public string ReflectionMethod::__toString ( void )
/* Méthodes héritées */
final private void ReflectionFunctionAbstract::__clone ( void )
public ReflectionExtension ReflectionFunctionAbstract::getExtension ( void )
public string ReflectionFunctionAbstract::getName ( void )
abstract public void ReflectionFunctionAbstract::__toString ( void )
}

Propriétés

name

Nom de la méthode

class

Nom de la classe

Constantes pré-définies

Modificateurs de ReflectionMethod

ReflectionMethod::IS_STATIC

Indique que la méthode est statique

ReflectionMethod::IS_PUBLIC

Indique que la méthode est publique

ReflectionMethod::IS_PROTECTED

Indique que la méthode est protégée

ReflectionMethod::IS_PRIVATE

Indique que la méthode est privée

ReflectionMethod::IS_ABSTRACT

Indique que la méthode est abstraite

ReflectionMethod::IS_FINAL

Indique que la méthode est finale

Sommaire



add a note add a note User Contributed Notes ReflectionMethod
webseiten dot designer at googlemail dot com 02-Apr-2011 01:53
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'
?>
no dot prob at gmx dot net 02-Jun-2006 03:09
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.

 
show source | credits | sitemap | contact | advertising | mirror sites