Zend_Reflectionリファレンス
The various classes in Zend_Reflection mimic the API of
PHP's Reflection API -
with one important difference. PHP's Reflection API does not provide
introspection into docblock annotation tags, nor into parameter variable
types or return types.
Zend_Reflection analyzes method docblock annotations to
determine parameter variable types and the return type. Specifically,
the @param and @return annotations are used.
However, you can also check for any other annotation tags, as well as
the standard "short" and "long" descriptions.
Each reflection object in Zend_Reflection overrides the
getDocblock() method to return an instance of
Zend_Reflection_Docblock. This class provides introspection
into the docblocks and annotation tags.
Zend_Reflection_File is a new reflection class that allows
introspection of PHP files. With it, you can retrieve the classes,
functions, and global PHP code contained in the file.
Finally, the various methods that return other reflection objects
allow a second parameter, the name of the reflection class to use for
the returned reflection object.
Zend_Reflection_Docblock
Zend_Reflection_Docblock is the heart of
Zend_Reflection's value-add over PHP's Reflection API.
It provides the following methods:
getContents(): docblockの完全な内容を返す
getStartLine(): 定義されたファイル内での
docblock開始位置を返す
getEndLine(): 定義されたファイル内での
docblock終了行を返す
getShortDescription(): 短い、一行の説明を取得
(たいていはdocblockの最初の行)
getLongDescription(): docblockの長い説明を取得
hasTag($name): 与えられた注釈タグが
docblockにあるかどうか判断する。
getTag($name): Retrieve the given annotation tag
reflection object, or a boolean false if it's not
present.
getTags($filter): Retrieve all tags, or all tags
matching the given $filter string. The tags
returned will be an array of
Zend_Reflection_Docblock_Tag objects.
Zend_Reflection_Docblock_Tag
Zend_Reflection_Docblock_Tag provides reflection for
individual annotation tags. Most tags consist of only a name and a
description. In the case of some special tags, the class provides a
factory method for retrieving an instance of the appropriate class.
The following methods are defined for
Zend_Reflection_Docblock_Tag:
factory($tagDocblockLine): instantiate the
appropriate tag reflection class and return it.
getName(): 注釈タグの名前を返す
getDescription(): 注釈の説明を返す
Zend_Reflection_Docblock_Tag_Param
Zend_Reflection_Docblock_Tag_Param is a specialized
version of Zend_Reflection_Docblock_Tag. The
@param annotation tag description consists of the
parameter type, variable name, and variable description. It adds the
following methods to Zend_Reflection_Docblock_Tag:
getType(): パラメータ変数の型を返す
getVariableName(): パラメータ変数の名前を返す
Zend_Reflection_Docblock_Tag_Return
Like Zend_Reflection_Docblock_Tag_Param,
Zend_Reflection_Docblock_Tag_Return is a specialized
version of Zend_Reflection_Docblock_Tag. The
@return annotation tag description consists of the
return type and variable description. It adds the following method
to Zend_Reflection_Docblock_Tag:
getType(): 戻す型を返す
Zend_Reflection_File
Zend_Reflection_File provides introspection into PHP
files. With it, you can introspect the classes, functions, and bare
PHP code defined in a file. It defines the following methods:
getFileName(): reflectionを使用したファイルの名前を取得
getStartLine(): ファイルの開始行を返す(常に1)
getEndLine() 最終行、ファイル中の行数を取得
getDocComment($reflectionClass =
'Zend_Reflection_Docblock'): retrive the file-level
docblock reflection object.
getClasses($reflectionClass =
'Zend_Reflection_Class'): retrieve an array of
reflection objects, one for each class defined in the file.
getFunctions($reflectionClass =
'Zend_Reflection_Function'): retrieve an array of
reflection objects, one for each function defined in the file.
getClass($name = null, $reflectionClass =
'Zend_Reflection_Class'): retrieve the reflection
object for a single class.
getContents(): retrieve the full contents of the
file.
Zend_Reflection_Class
Zend_Reflection_Class extends
ReflectionClass, and follows its API. It adds one
additional method, getDeclaringFile(), which may be
used to retrieve the Zend_Reflection_File reflection
object for the defining file.
Additionally, the following methods add an additional argument for
specifying the reflection class to use when fetching a reflection
object:
getDeclaringFile($reflectionClass = 'Zend_Reflection_File')
getDocblock($reflectionClass = 'Zend_Reflection_Docblock')
getInterfaces($reflectionClass = 'Zend_Reflection_Class')
getMethod($reflectionClass = 'Zend_Reflection_Method')
getMethods($filter = -1, $reflectionClass = 'Zend_Reflection_Method')
getParentClass($reflectionClass = 'Zend_Reflection_Class')
getProperty($name, $reflectionClass =
'Zend_Reflection_Property')
getProperties($filter = -1, $reflectionClass =
'Zend_Reflection_Property')
Zend_Reflection_Extension
Zend_Reflection_Extension extends
ReflectionExtension, and follows its API. It overrides
the following methods to add an additional argument for specifying
the reflection class to use when fetching a reflection object:
getFunctions($reflectionClass =
'Zend_Reflection_Function'): retrieve an array of
reflection objects representing the functions defined by the
extension.
getClasses($reflectionClass =
'Zend_Reflection_Class'): retrieve an array of
reflection objects representing the classes defined by the
extension.
Zend_Reflection_Function
Zend_Reflection_Function adds a method for retrieving
the function return type, as well as overrides several methods to
allow specifying the reflection class to use for returned reflection
objects.
getDocblock($reflectionClass =
'Zend_Reflection_Docblock'): retrieve the function
docblock reflection object.
getParameters($reflectionClass =
'Zend_Reflection_Parameter'): retrieve an array of
all function parameter reflection objects.
getReturn(): retrieve the return type reflection
object.
Zend_Reflection_Method
Zend_Reflection_Method mirrors
Zend_Reflection_Function, and only overrides one
additional method:
getParentClass($reflectionClass =
'Zend_Reflection_Class'): retrieve the parent class
reflection object.
Zend_Reflection_Parameter
Zend_Reflection_Parameter adds a method for retrieving
the parameter type, as well as overrides methods to allow specifying
the reflection class to use on returned reflection objects.
getDeclaringClass($reflectionClass =
'Zend_Reflection_Class'): get the declaring class of
the parameter as a reflection object (if available).
getClass($reflectionClass =
'Zend_Reflection_Class'): get the class of
the parameter as a reflection object (if available).
getDeclaringFunction($reflectionClass =
'Zend_Reflection_Function'): get the function of
the parameter as a reflection object (if available).
getType(): パラメータの型を取得
Zend_Reflection_Property
Zend_Reflection_Property overrides a single method in
order to allow specifying the returned reflection object class:
getDeclaringClass($reflectionClass =
'Zend_Reflection_Class'): retrieve the declaring
class of the property as a reflection object.