PHP 클래스 BetterReflection\Reflection\ReflectionFunctionAbstract

상속: implements Reflector
파일 보기 프로젝트 열기: roave/better-reflection 1 사용 예제들

공개 메소드들

메소드 설명
__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.

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