Zend_CodeGeneratorリファレンス 抽象クラスとインターフェース Zend_CodeGenerator_Abstract すべてのCodeGeneratorクラスが継承する基底のクラスは、 必要な最小限の機能性を提供します。 そのAPIは下記の通りです。: コンストラクタは最初に_init()を呼び出します。 (それは、具体的に拡張するクラスを実装するために空のままにされます) それからsetOptions()$optionsパラメータを渡し、 最後に_prepare()を呼び出します。 (again, クラスの拡張によって実装されます。) Zend Frameworkのほとんどのクラスのように、 setOptions()ではクラスの既存のセッターへのオプション・キーを比較して、 見つかったら、メソッドに値を渡します。 __toString()は最後に指定され、 generate()の代わりをします。 setSourceContent()及びgetSourceContent()は デフォルト・コンテンツを生成されたコードに設定するか、 一旦すべての生成作業が完了した前述のコンテンツと入れ替えることを目的とします。 Zend_CodeGenerator_Php_Abstract Zend_CodeGenerator_Php_AbstractZend_CodeGenerator_Abstractを拡張し、 生成されたコンテンツの前に現れなければならないインデントの量だけでなく、 コンテンツが変わったかどうか追跡するための若干のプロパティも加えます。 そのAPIは下記の通りです。: Zend_CodeGenerator_Php_Member_Abstract Zend_CodeGenerator_Php_Member_Abstractは クラスのメンバー - プロパティとメソッド - を生成するための基底クラスで、 可視性を確立するためのアクセッサとミューテータを提供します; メンバーやメンバー名がabstract、staticまたはfinalのいずれにせよ。 そのAPIは下記の通りです。: Concrete CodeGenerator Classes Zend_CodeGenerator_Php_Body Zend_CodeGenerator_Php_Bodyは、 ファイルの中に含む任意の手続き的なコードを生成することを目的とします。 そのように、単にコンテンツをオブジェクトに設定し、 generate()を実施すると、それはそのコンテンツを返します。 そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_Class Zend_CodeGenerator_Php_Classは、 PHPクラスを生成することを目的とします。 基本的機能ではPHPクラスそのものを生成し、 また、任意で関連したPHP DocBlockも生成します。 クラスは他のクラスを実装するかもしれませんし、継承するかもしれません。 またはabstractと指定されるかもしれません。 他のコード・ジェネレーター・クラスを利用して、 クラスの定数やプロパティ、メソッドを付与することもできます。 そのAPIは下記の通りです。: setProperty()メソッドは、 Zend_CodeGenerator_Php_Propertyインスタンスを生成するために 用いられるかもしれない情報の配列、 またはただ単にZend_CodeGenerator_Php_Propertyインスタンス、 を受け入れます。 同様にsetMethod()は、 Zend_CodeGenerator_Php_Methodインスタンスを生成するための、 情報の配列またはそのクラスの具体化したインスタンスを受け入れます。 setDocBlock()Zend_CodeGenerator_Php_DocBlockの インスタンスを期待することも注意してください。 Zend_CodeGenerator_Php_Docblock Zend_CodeGenerator_Php_Docblock can be used to generate arbitrary PHP docblocks, including all the standard docblock features: short and long descriptions and annotation tags. Annotation tags may be set using the setTag() and setTags() methods; these each take either an array describing the tag that may be passed to the Zend_CodeGenerator_Php_Docblock_Tag constructor, or an instance of that class. そのAPIは下記の通りです。: Zend_CodeGenerator_Php_Docblock_Tag Zend_CodeGenerator_Php_Docblock_Tag is intended for creating arbitrary annotation tags for inclusion in PHP docblocks. Tags are expected to contain a name (the portion immediately following the '@' symbol) and a description (everything following the tag name). そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_DocBlock_Tag_Param Zend_CodeGenerator_Php_DocBlock_Tag_Param is a specialized version of Zend_CodeGenerator_Php_DocBlock_Tag, and represents a method parameter. The tag name is therefor known ("param"), but due to the format of this annotation tag, additional information is required in order to generate it: the parameter name and data type it represents. そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_DocBlock_Tag_Return Like the param docblock tag variant, Zend_CodeGenerator_Php_Docblock_Tab_Return is an annotation tag variant for representing a method return value. In this case, the annotation tag name is known ("return"), but requires a return type. そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_File Zend_CodeGenerator_Php_File is used to generate the full contents of a file that will contain PHP code. The file may contain classes or arbitrary PHP code, as well as a file-level docblock if desired. When adding classes to the file, you will need to pass either an array of information to pass to the Zend_CodeGenerator_Php_Class constructor, or an instance of that class. Similarly, with docblocks, you will need to pass information for the Zend_CodeGenerator_Php_Docblock constructor to consume or an instance of the class. そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_Member_Container Zend_CodeGenerator_Php_Member_Container is used internally by Zend_CodeGenerator_Php_Class to keep track of class members -- properties and methods alike. These are indexed by name, using the concrete instances of the members as values. そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_Method Zend_CodeGenerator_Php_Method describes a class method, and can generate both the code and the docblock for the method. The visibility and status as static, abstract, or final may be indicated, per its parent class, Zend_CodeGenerator_Php_Member_Abstract. Finally, the parameters and return value for the method may be specified. Parameters may be set using setParameter() or setParameters(). In each case, a parameter should either be an array of information to pass to the Zend_CodeGenerator_Php_Parameter constructor or an instance of that class. そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_Parameter Zend_CodeGenerator_Php_Parameter may be used to specify method parameters. Each parameter may have a position (if unspecified, the order in which they are registered with the method will be used), a default value, and a data type; a parameter name is required. そのクラスのAPIは下記の通りです。: Zend_CodeGenerator_Php_Property Zend_CodeGenerator_Php_Property describes a class property, which may be either a constant or a variable. In each case, the property may have an optional default value associated with it. Additionally, the visibility of variable properties may be set, per the parent class, Zend_CodeGenerator_Php_Member_Abstract. そのクラスのAPIは下記の通りです。: