PHP Australia Conference 2015

The ReflectionFunction class

Introduction

کلاس ReflectionFunction اطلاعات درباره تابع می‌دهد.

کلاس والد ReflectionFunctionAbstract همان متدها را دارد invoke()، invokeArgs()، export() و isDisabled().

Class synopsis

ReflectionFunction extends ReflectionFunctionAbstract implements Reflector {
/* Constants */
const integer ReflectionFunction::IS_DEPRECATED = 262144 ;
/* Properties */
public $name ;
/* Methods */
__construct ( string $name )
public static string export ( string $name [, string $return ] )
public mixed invoke ([ string $args ] )
public mixed invokeArgs ( array $args )
public bool isDisabled ( void )
public string __toString ( void )
/* Inherited methods */
final private void ReflectionFunctionAbstract::__clone ( void )
public ReflectionExtension ReflectionFunctionAbstract::getExtension ( void )
public string ReflectionFunctionAbstract::getName ( void )
abstract public void ReflectionFunctionAbstract::__toString ( void )
}

Properties

name

Prop description

Predefined Constants

ReflectionFunction Node Types

ReflectionFunction::IS_DEPRECATED

Description here...

Table of Contents

add a note add a note

User Contributed Notes 1 note

up
0
Lorenz R.S.
3 years ago
Here is a concise example of ReflectionFunction usage for Parameter Reflection / introspection (e.g. to automatically generate API descriptions)

<?php
$properties
= $reflector->getProperties();
$refFunc = new ReflectionFunction('preg_replace');
foreach(
$refFunc->getParameters() as $param ){
   
//invokes ■ReflectionParameter::__toString
   
print $param;
}
?>

prints:

Parameter #0 [ <required> $regex ]
Parameter #1 [ <required> $replace ]
Parameter #2 [ <required> $subject ]
Parameter #3 [ <optional> $limit ]
Parameter #4 [ <optional> &$count ]
To Top