PHP Класс BetterReflection\Reflection\ReflectionFunctionAbstract

Наследование: implements Reflector
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__clone ( )
addParameter ( string $parameterName ) Add a new parameter to the method/function.
export ( )
getAst ( ) : ClassMethod | Function_ Fetch the AST for this method or function.
getBodyAst ( ) : PhpParser\Node[] Retrieves the body of this function as AST nodes
getBodyCode ( PrettyPrinterAbstract $printer = null ) : string Retrieves the body of this function as code.
getDocBlockReturnTypes ( ) : phpDocumentor\Reflection\Type[] Get the return types defined in the DocBlocks. This returns an array because the parameter may have multiple (compound) types specified (for example when you type hint pipe-separated "string|null", in which case this would return an array of Type objects, one for string, one for null.
getDocComment ( ) : string
getEndLine ( ) : integer Get the line number that this function ends on.
getFileName ( ) : string
getLocatedSource ( ) : BetterReflection\SourceLocator\Located\LocatedSource
getName ( ) : string Get the "full" name of the function (e.g. for A\B\foo, this will return "A\B\foo").
getNamespaceName ( ) : string Get the "namespace" name of the function (e.g. for A\B\foo, this will return "A\B").
getNumberOfParameters ( ) : integer Get the number of parameters for this class.
getNumberOfRequiredParameters ( ) : integer Get the number of required parameters for this method.
getParameter ( string $parameterName ) : ReflectionParameter | null Get a single parameter by name. Returns null if parameter not found for the function.
getParameters ( ) : ReflectionParameter[] Get an array list of the parameters for this method signature, as an array of ReflectionParameter instances.
getReturnStatementsAst ( ) : PhpParser\Node\Stmt\Return_[] Fetch an array of all return statements found within this function.
getReturnType ( ) : ReflectionType | null Get the return type declaration (only for PHP 7+ code)
getShortName ( ) : string Get the "short" name of the function (e.g. for A\B\foo, this will return "foo").
getStartLine ( ) : integer Get the line number that this function starts on.
hasReturnType ( ) : boolean Do we have a return type declaration (only for PHP 7+ code)
inNamespace ( ) : boolean Decide if this function is part of a namespace. Returns false if the class is in the global namespace or does not have a specified namespace.
isClosure ( ) : boolean Is this function a closure?
isDeprecated ( ) : boolean Is this function deprecated?
isGenerator ( ) : boolean Check if this function can be used as a generator (i.e. contains the "yield" keyword).
isInternal ( ) : boolean Is this an internal function?
isUserDefined ( ) : boolean Is this a user-defined function (will always return the opposite of whatever isInternal returns).
isVariadic ( ) : boolean Check if the function has a variadic parameter.
removeParameter ( string $parameterName ) : void Remove a parameter from the method/function.
removeReturnType ( ) Remove the return type declaration completely.
returnsReference ( ) : boolean Is this function declared as a reference.
setBodyFromAst ( array $nodes ) Override the method or function's body of statements with an entirely new body of statements within the reflection.
setBodyFromClosure ( Closure $newBody ) Override the method or function's body of statements with an entirely new body of statements within the reflection.
setBodyFromString ( string $newBody ) Override the method or function's body of statements with an entirely new body of statements within the reflection.
setReturnType ( phpDocumentor\Reflection\Type $newReturnType ) Set the return type declaration.

Защищенные методы

Метод Описание
__construct ( )
getNode ( ) : ClassMethod | Function_ Get the AST node from which this function was created
populateFunctionAbstract ( BetterReflection\Reflector\Reflector $reflector, PhpParser\Node $node, BetterReflection\SourceLocator\Located\LocatedSource $locatedSource, Namespace_ $declaringNamespace = null ) Populate the common elements of the function abstract.

Приватные методы

Метод Описание
nodeIsOrContainsYield ( PhpParser\Node $node ) : boolean Recursively search an array of statements (PhpParser nodes) to find if a yield expression exists anywhere (thus indicating this is a generator).
setNodeOptionalFlag ( ) We must determine if params are optional or not ahead of time, but we must do it in reverse.

Описание методов

__clone() публичный Метод

public __clone ( )

__construct() защищенный Метод

protected __construct ( )

addParameter() публичный Метод

Add a new parameter to the method/function.
public addParameter ( string $parameterName )
$parameterName string

export() публичный статический Метод

public static export ( )

getAst() публичный Метод

Fetch the AST for this method or function.
public getAst ( ) : ClassMethod | Function_
Результат PhpParser\Node\Stmt\ClassMethod | PhpParser\Node\Stmt\Function_

getBodyAst() публичный Метод

Retrieves the body of this function as AST nodes
public getBodyAst ( ) : PhpParser\Node[]
Результат PhpParser\Node[]

getBodyCode() публичный Метод

If a PrettyPrinter is provided as a paramter, it will be used, otherwise a default will be used. Note that the formatting of the code may not be the same as the original function. If specific formatting is required, you should provide your own implementation of a PrettyPrinter to unparse the AST.
public getBodyCode ( PrettyPrinterAbstract $printer = null ) : string
$printer PhpParser\PrettyPrinterAbstract
Результат string

getDocBlockReturnTypes() публичный Метод

Get the return types defined in the DocBlocks. This returns an array because the parameter may have multiple (compound) types specified (for example when you type hint pipe-separated "string|null", in which case this would return an array of Type objects, one for string, one for null.
public getDocBlockReturnTypes ( ) : phpDocumentor\Reflection\Type[]
Результат phpDocumentor\Reflection\Type[]

getDocComment() публичный Метод

public getDocComment ( ) : string
Результат string

getEndLine() публичный Метод

Get the line number that this function ends on.
public getEndLine ( ) : integer
Результат integer

getFileName() публичный Метод

public getFileName ( ) : string
Результат string

getLocatedSource() публичный Метод

public getLocatedSource ( ) : BetterReflection\SourceLocator\Located\LocatedSource
Результат BetterReflection\SourceLocator\Located\LocatedSource

getName() публичный Метод

Get the "full" name of the function (e.g. for A\B\foo, this will return "A\B\foo").
public getName ( ) : string
Результат string

getNamespaceName() публичный Метод

Get the "namespace" name of the function (e.g. for A\B\foo, this will return "A\B").
public getNamespaceName ( ) : string
Результат string

getNode() защищенный Метод

Get the AST node from which this function was created
protected getNode ( ) : ClassMethod | Function_
Результат PhpParser\Node\Stmt\ClassMethod | PhpParser\Node\Stmt\Function_

getNumberOfParameters() публичный Метод

Get the number of parameters for this class.
public getNumberOfParameters ( ) : integer
Результат integer

getNumberOfRequiredParameters() публичный Метод

Get the number of required parameters for this method.
public getNumberOfRequiredParameters ( ) : integer
Результат integer

getParameter() публичный Метод

Get a single parameter by name. Returns null if parameter not found for the function.
public getParameter ( string $parameterName ) : ReflectionParameter | null
$parameterName string
Результат ReflectionParameter | null

getParameters() публичный Метод

Get an array list of the parameters for this method signature, as an array of ReflectionParameter instances.
public getParameters ( ) : ReflectionParameter[]
Результат ReflectionParameter[]

getReturnStatementsAst() публичный Метод

Note that return statements within smaller scopes contained (e.g. anonymous classes, closures) are not returned here as they are not within the immediate scope.
public getReturnStatementsAst ( ) : PhpParser\Node\Stmt\Return_[]
Результат PhpParser\Node\Stmt\Return_[]

getReturnType() публичный Метод

Get the return type declaration (only for PHP 7+ code)
public getReturnType ( ) : ReflectionType | null
Результат ReflectionType | null

getShortName() публичный Метод

Get the "short" name of the function (e.g. for A\B\foo, this will return "foo").
public getShortName ( ) : string
Результат string

getStartLine() публичный Метод

Get the line number that this function starts on.
public getStartLine ( ) : integer
Результат integer

hasReturnType() публичный Метод

Do we have a return type declaration (only for PHP 7+ code)
public hasReturnType ( ) : boolean
Результат boolean

inNamespace() публичный Метод

Decide if this function is part of a namespace. Returns false if the class is in the global namespace or does not have a specified namespace.
public inNamespace ( ) : boolean
Результат boolean

isClosure() публичный Метод

Is this function a closure?
public isClosure ( ) : boolean
Результат boolean

isDeprecated() публичный Метод

Note - we cannot reflect on internal functions (as there is no PHP source code we can access. This means, at present, we can only EVER return false from this function.
См. также: https://github.com/Roave/BetterReflection/issues/38
public isDeprecated ( ) : boolean
Результат boolean

isGenerator() публичный Метод

Check if this function can be used as a generator (i.e. contains the "yield" keyword).
public isGenerator ( ) : boolean
Результат boolean

isInternal() публичный Метод

Note - we cannot reflect on internal functions (as there is no PHP source code we can access. This means, at present, we can only EVER return false from this function.
См. также: https://github.com/Roave/BetterReflection/issues/38
public isInternal ( ) : boolean
Результат boolean

isUserDefined() публичный Метод

Is this a user-defined function (will always return the opposite of whatever isInternal returns).
public isUserDefined ( ) : boolean
Результат boolean

isVariadic() публичный Метод

Check if the function has a variadic parameter.
public isVariadic ( ) : boolean
Результат boolean

populateFunctionAbstract() защищенный Метод

Populate the common elements of the function abstract.
protected populateFunctionAbstract ( BetterReflection\Reflector\Reflector $reflector, PhpParser\Node $node, BetterReflection\SourceLocator\Located\LocatedSource $locatedSource, Namespace_ $declaringNamespace = null )
$reflector BetterReflection\Reflector\Reflector
$node PhpParser\Node
$locatedSource BetterReflection\SourceLocator\Located\LocatedSource
$declaringNamespace PhpParser\Node\Stmt\Namespace_

removeParameter() публичный Метод

Remove a parameter from the method/function.
public removeParameter ( string $parameterName ) : void
$parameterName string
Результат void

removeReturnType() публичный Метод

Remove the return type declaration completely.
public removeReturnType ( )

returnsReference() публичный Метод

Is this function declared as a reference.
public returnsReference ( ) : boolean
Результат boolean

setBodyFromAst() публичный Метод

Override the method or function's body of statements with an entirely new body of statements within the reflection.
public setBodyFromAst ( array $nodes )
$nodes array

setBodyFromClosure() публичный Метод

Override the method or function's body of statements with an entirely new body of statements within the reflection.
public setBodyFromClosure ( Closure $newBody )
$newBody Closure

setBodyFromString() публичный Метод

Override the method or function's body of statements with an entirely new body of statements within the reflection.
public setBodyFromString ( string $newBody )
$newBody string

setReturnType() публичный Метод

You must use the phpDocumentor reflection type classes as the parameter.
public setReturnType ( phpDocumentor\Reflection\Type $newReturnType )
$newReturnType phpDocumentor\Reflection\Type