2
0

Zend_CodeGenerator-Reference.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 15341 -->
  4. <sect1 id="zend.codegenerator.reference">
  5. <title>Zend_CodeGeneratorリファレンス</title>
  6. <sect2 id="zend.codegenerator.reference.abstracts">
  7. <title>抽象クラスとインターフェース</title>
  8. <sect3 id="zend.codegenerator.reference.abstracts.abstract">
  9. <title>Zend_CodeGenerator_Abstract</title>
  10. <para>
  11. すべてのCodeGeneratorクラスが継承する基底のクラスは、
  12. 必要な最小限の機能性を提供します。
  13. そのAPIは下記の通りです。:
  14. </para>
  15. <programlisting role="php"><![CDATA[
  16. abstract class Zend_CodeGenerator_Abstract
  17. {
  18. final public function __construct(Array $options = array())
  19. public function setOptions(Array $options)
  20. public function setSourceContent($sourceContent)
  21. public function getSourceContent()
  22. protected function _init()
  23. protected function _prepare()
  24. abstract public function generate();
  25. final public function __toString()
  26. }
  27. ]]></programlisting>
  28. <para>
  29. コンストラクタは最初に<code>_init()</code>を呼び出します。
  30. (それは、具体的に拡張するクラスを実装するために空のままにされます)
  31. それから<code>setOptions()</code>に<code>$options</code>パラメータを渡し、
  32. 最後に<code>_prepare()</code>を呼び出します。
  33. (<!-- TODO -->again,
  34. クラスの拡張によって実装されます。)
  35. </para>
  36. <para>
  37. Zend Frameworkのほとんどのクラスのように、
  38. <code>setOptions()</code>ではクラスの既存のセッターへのオプション・キーを比較して、
  39. 見つかったら、メソッドに値を渡します。
  40. </para>
  41. <para>
  42. <code>__toString()</code>は最後に指定され、
  43. <code>generate()</code>の代わりをします。
  44. </para>
  45. <para>
  46. <code>setSourceContent()</code>及び<code>getSourceContent()</code>は
  47. デフォルト・コンテンツを生成されたコードに設定するか、
  48. 一旦すべての生成作業が完了した前述のコンテンツと入れ替えることを目的とします。
  49. </para>
  50. </sect3>
  51. <sect3 id="zend.codegenerator.reference.abstracts.php-abstract">
  52. <title>Zend_CodeGenerator_Php_Abstract</title>
  53. <para>
  54. <classname>Zend_CodeGenerator_Php_Abstract</classname>は
  55. <classname>Zend_CodeGenerator_Abstract</classname>を拡張し、
  56. 生成されたコンテンツの前に現れなければならないインデントの量だけでなく、
  57. コンテンツが変わったかどうか追跡するための若干のプロパティも加えます。
  58. そのAPIは下記の通りです。:
  59. </para>
  60. <programlisting role="php"><![CDATA[
  61. abstract class Zend_CodeGenerator_Php_Abstract
  62. extends Zend_CodeGenerator_Abstract
  63. {
  64. public function setSourceDirty($isSourceDirty = true)
  65. public function isSourceDirty()
  66. public function setIndentation($indentation)
  67. public function getIndentation()
  68. }
  69. ]]></programlisting>
  70. </sect3>
  71. <sect3 id="zend.codegenerator.reference.abstracts.php-member-abstract">
  72. <title>Zend_CodeGenerator_Php_Member_Abstract</title>
  73. <para>
  74. <classname>Zend_CodeGenerator_Php_Member_Abstract</classname>は
  75. クラスのメンバー - プロパティとメソッド - を生成するための基底クラスで、
  76. 可視性を確立するためのアクセッサとミューテータを提供します;
  77. メンバーやメンバー名がabstract、staticまたはfinalのいずれにせよ。
  78. そのAPIは下記の通りです。:
  79. </para>
  80. <programlisting role="php"><![CDATA[
  81. abstract class Zend_CodeGenerator_Php_Member_Abstract
  82. extends Zend_CodeGenerator_Php_Abstract
  83. {
  84. public function setAbstract($isAbstract)
  85. public function isAbstract()
  86. public function setStatic($isStatic)
  87. public function isStatic()
  88. public function setVisibility($visibility)
  89. public function getVisibility()
  90. public function setName($name)
  91. public function getName()
  92. }
  93. ]]></programlisting>
  94. </sect3>
  95. </sect2>
  96. <sect2 id="zend.codegenerator.reference.concrete">
  97. <title>Concrete CodeGenerator Classes</title>
  98. <sect3 id="zend.codegenerator.reference.concrete.php-body">
  99. <title>Zend_CodeGenerator_Php_Body</title>
  100. <para>
  101. <classname>Zend_CodeGenerator_Php_Body</classname>は、
  102. ファイルの中に含む任意の手続き的なコードを生成することを目的とします。
  103. そのように、単にコンテンツをオブジェクトに設定し、
  104. <code>generate()</code>を実施すると、それはそのコンテンツを返します。
  105. </para>
  106. <para>
  107. そのクラスのAPIは下記の通りです。:
  108. </para>
  109. <programlisting role="php"><![CDATA[
  110. class Zend_CodeGenerator_Php_Body extends Zend_CodeGenerator_Php_Abstract
  111. {
  112. public function setContent($content)
  113. public function getContent()
  114. public function generate()
  115. }
  116. ]]></programlisting>
  117. </sect3>
  118. <sect3 id="zend.codegenerator.reference.concrete.php-class">
  119. <title>Zend_CodeGenerator_Php_Class</title>
  120. <para>
  121. <classname>Zend_CodeGenerator_Php_Class</classname>は、
  122. PHPクラスを生成することを目的とします。
  123. 基本的機能ではPHPクラスそのものを生成し、
  124. また、任意で関連したPHP DocBlockも生成します。
  125. クラスは他のクラスを実装するかもしれませんし、継承するかもしれません。
  126. またはabstractと指定されるかもしれません。
  127. 他のコード・ジェネレーター・クラスを利用して、
  128. クラスの定数やプロパティ、メソッドを付与することもできます。
  129. </para>
  130. <para>
  131. そのAPIは下記の通りです。:
  132. </para>
  133. <programlisting role="php"><![CDATA[
  134. class Zend_CodeGenerator_Php_Class extends Zend_CodeGenerator_Php_Abstract
  135. {
  136. public static function fromReflection(
  137. Zend_Reflection_Class $reflectionClass
  138. )
  139. public function setDocblock(Zend_CodeGenerator_Php_Docblock $docblock)
  140. public function getDocblock()
  141. public function setName($name)
  142. public function getName()
  143. public function setAbstract($isAbstract)
  144. public function isAbstract()
  145. public function setExtendedClass($extendedClass)
  146. public function getExtendedClass()
  147. public function setImplementedInterfaces(Array $implementedInterfaces)
  148. public function getImplementedInterfaces()
  149. public function setProperties(Array $properties)
  150. public function setProperty($property)
  151. public function getProperties()
  152. public function getProperty($propertyName)
  153. public function setMethods(Array $methods)
  154. public function setMethod($method)
  155. public function getMethods()
  156. public function getMethod($methodName)
  157. public function hasMethod($methodName)
  158. public function isSourceDirty()
  159. public function generate()
  160. }
  161. ]]></programlisting>
  162. <para>
  163. <code>setProperty()</code>メソッドは、
  164. <classname>Zend_CodeGenerator_Php_Property</classname>インスタンスを生成するために
  165. 用いられるかもしれない情報の配列、
  166. またはただ単に<classname>Zend_CodeGenerator_Php_Property</classname>インスタンス、
  167. を受け入れます。
  168. 同様に<code>setMethod()</code>は、
  169. <classname>Zend_CodeGenerator_Php_Method</classname>インスタンスを生成するための、
  170. 情報の配列またはそのクラスの具体化したインスタンスを受け入れます。
  171. </para>
  172. <para>
  173. <code>setDocBlock()</code>が<classname>Zend_CodeGenerator_Php_DocBlock</classname>の
  174. インスタンスを期待することも注意してください。
  175. </para>
  176. </sect3>
  177. <sect3 id="zend.codegenerator.reference.concrete.php-docblock">
  178. <title>Zend_CodeGenerator_Php_Docblock</title>
  179. <para>
  180. <classname>Zend_CodeGenerator_Php_Docblock</classname> can be used to
  181. generate arbitrary PHP docblocks, including all the standard
  182. docblock features: short and long descriptions and annotation
  183. tags.
  184. </para>
  185. <para>
  186. Annotation tags may be set using the <code>setTag()</code> and
  187. <code>setTags()</code> methods; these each take either an array
  188. describing the tag that may be passed to the
  189. <classname>Zend_CodeGenerator_Php_Docblock_Tag</classname> constructor, or
  190. an instance of that class.
  191. </para>
  192. <para>
  193. そのAPIは下記の通りです。:
  194. </para>
  195. <programlisting role="php"><![CDATA[
  196. class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
  197. {
  198. public static function fromReflection(
  199. Zend_Reflection_Docblock $reflectionDocblock
  200. )
  201. public function setShortDescription($shortDescription)
  202. public function getShortDescription()
  203. public function setLongDescription($longDescription)
  204. public function getLongDescription()
  205. public function setTags(Array $tags)
  206. public function setTag($tag)
  207. public function getTags()
  208. public function generate()
  209. }
  210. ]]></programlisting>
  211. </sect3>
  212. <sect3 id="zend.codegenerator.reference.concrete.php-docblock-tag">
  213. <title>Zend_CodeGenerator_Php_Docblock_Tag</title>
  214. <para>
  215. <classname>Zend_CodeGenerator_Php_Docblock_Tag</classname> is intended for
  216. creating arbitrary annotation tags for inclusion in PHP
  217. docblocks. Tags are expected to contain a name (the portion
  218. immediately following the '@' symbol) and a description
  219. (everything following the tag name).
  220. </para>
  221. <para>
  222. そのクラスのAPIは下記の通りです。:
  223. </para>
  224. <programlisting role="php"><![CDATA[
  225. class Zend_CodeGenerator_Php_Docblock_Tag
  226. extends Zend_CodeGenerator_Php_Abstract
  227. {
  228. public static function fromReflection(
  229. Zend_Reflection_Docblock_Tag $reflectionTag
  230. )
  231. public function setName($name)
  232. public function getName()
  233. public function setDescription($description)
  234. public function getDescription()
  235. public function generate()
  236. }
  237. ]]></programlisting>
  238. </sect3>
  239. <sect3 id="zend.codegenerator.reference.concrete.php-docblock-tag-param">
  240. <title>Zend_CodeGenerator_Php_DocBlock_Tag_Param</title>
  241. <para>
  242. <classname>Zend_CodeGenerator_Php_DocBlock_Tag_Param</classname> is a
  243. specialized version of
  244. <classname>Zend_CodeGenerator_Php_DocBlock_Tag</classname>, and represents
  245. a method parameter. The tag name is therefor known ("param"),
  246. but due to the format of this annotation tag, additional
  247. information is required in order to generate it: the parameter
  248. name and data type it represents.
  249. </para>
  250. <para>
  251. そのクラスのAPIは下記の通りです。:
  252. </para>
  253. <programlisting role="php"><![CDATA[
  254. class Zend_CodeGenerator_Php_Docblock_Tag_Param
  255. extends Zend_CodeGenerator_Php_Docblock_Tag
  256. {
  257. public static function fromReflection(
  258. Zend_Reflection_Docblock_Tag $reflectionTagParam
  259. )
  260. public function setDatatype($datatype)
  261. public function getDatatype()
  262. public function setParamName($paramName)
  263. public function getParamName()
  264. public function generate()
  265. }
  266. ]]></programlisting>
  267. </sect3>
  268. <sect3 id="zend.codegenerator.reference.concrete.php-docblock-tag-return">
  269. <title>Zend_CodeGenerator_Php_DocBlock_Tag_Return</title>
  270. <para>
  271. Like the param docblock tag variant,
  272. <classname>Zend_CodeGenerator_Php_Docblock_Tab_Return</classname> is an
  273. annotation tag variant for representing a method return value.
  274. In this case, the annotation tag name is known ("return"), but
  275. requires a return type.
  276. </para>
  277. <para>
  278. そのクラスのAPIは下記の通りです。:
  279. </para>
  280. <programlisting role="php"><![CDATA[
  281. class Zend_CodeGenerator_Php_Docblock_Tag_Param
  282. extends Zend_CodeGenerator_Php_Docblock_Tag
  283. {
  284. public static function fromReflection(
  285. Zend_Reflection_Docblock_Tag $reflectionTagReturn
  286. )
  287. public function setDatatype($datatype)
  288. public function getDatatype()
  289. public function generate()
  290. }
  291. ]]></programlisting>
  292. </sect3>
  293. <sect3 id="zend.codegenerator.reference.concrete.php-file">
  294. <title>Zend_CodeGenerator_Php_File</title>
  295. <para>
  296. <classname>Zend_CodeGenerator_Php_File</classname> is used to generate
  297. the full contents of a file that will contain PHP code. The file
  298. may contain classes or arbitrary PHP code, as well as a
  299. file-level docblock if desired.
  300. </para>
  301. <para>
  302. When adding classes to the file, you will need to pass either an
  303. array of information to pass to the
  304. <classname>Zend_CodeGenerator_Php_Class</classname> constructor, or an
  305. instance of that class. Similarly, with docblocks, you will need
  306. to pass information for the
  307. <classname>Zend_CodeGenerator_Php_Docblock</classname> constructor to
  308. consume or an instance of the class.
  309. </para>
  310. <para>
  311. そのクラスのAPIは下記の通りです。:
  312. </para>
  313. <programlisting role="php"><![CDATA[
  314. class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract
  315. {
  316. public static function fromReflectedFilePath(
  317. $filePath,
  318. $usePreviousCodeGeneratorIfItExists = true,
  319. $includeIfNotAlreadyIncluded = true)
  320. public static function fromReflection(Zend_Reflection_File $reflectionFile)
  321. public function setDocblock(Zend_CodeGenerator_Php_Docblock $docblock)
  322. public function getDocblock()
  323. public function setRequiredFiles($requiredFiles)
  324. public function getRequiredFiles()
  325. public function setClasses(Array $classes)
  326. public function getClass($name = null)
  327. public function setClass($class)
  328. public function setFilename($filename)
  329. public function getFilename()
  330. public function getClasses()
  331. public function setBody($body)
  332. public function getBody()
  333. public function isSourceDirty()
  334. public function generate()
  335. }
  336. ]]></programlisting>
  337. </sect3>
  338. <sect3 id="zend.codegenerator.reference.concrete.php-member-container">
  339. <title>Zend_CodeGenerator_Php_Member_Container</title>
  340. <para>
  341. <classname>Zend_CodeGenerator_Php_Member_Container</classname> is used
  342. internally by <classname>Zend_CodeGenerator_Php_Class</classname> to keep
  343. track of class members -- properties and methods alike. These
  344. are indexed by name, using the concrete instances of the members
  345. as values.
  346. </para>
  347. <para>
  348. そのクラスのAPIは下記の通りです。:
  349. </para>
  350. <programlisting role="php"><![CDATA[
  351. class Zend_CodeGenerator_Php_Member_Container extends ArrayObject
  352. {
  353. public function __construct($type = self::TYPE_PROPERTY)
  354. }
  355. ]]></programlisting>
  356. </sect3>
  357. <sect3 id="zend.codegenerator.reference.concrete.php-method">
  358. <title>Zend_CodeGenerator_Php_Method</title>
  359. <para>
  360. <classname>Zend_CodeGenerator_Php_Method</classname> describes a class
  361. method, and can generate both the code and the docblock for the
  362. method. The visibility and status as static,
  363. abstract, or final may be indicated, per its parent class,
  364. <classname>Zend_CodeGenerator_Php_Member_Abstract</classname>. Finally,
  365. the parameters and return value for the method may be specified.
  366. </para>
  367. <para>
  368. Parameters may be set using <code>setParameter()</code> or
  369. <code>setParameters()</code>. In each case, a parameter should
  370. either be an array of information to pass to the
  371. <classname>Zend_CodeGenerator_Php_Parameter</classname> constructor or an
  372. instance of that class.
  373. </para>
  374. <para>
  375. そのクラスのAPIは下記の通りです。:
  376. </para>
  377. <programlisting role="php"><![CDATA[
  378. class Zend_CodeGenerator_Php_Method
  379. extends Zend_CodeGenerator_Php_Member_Abstract
  380. {
  381. public static function fromReflection(
  382. Zend_Reflection_Method $reflectionMethod
  383. )
  384. public function setDocblock(Zend_CodeGenerator_Php_Docblock $docblock)
  385. public function getDocblock()
  386. public function setFinal($isFinal)
  387. public function setParameters(Array $parameters)
  388. public function setParameter($parameter)
  389. public function getParameters()
  390. public function setBody($body)
  391. public function getBody()
  392. public function generate()
  393. }
  394. ]]></programlisting>
  395. </sect3>
  396. <sect3 id="zend.codegenerator.reference.concrete.php-parameter">
  397. <title>Zend_CodeGenerator_Php_Parameter</title>
  398. <para>
  399. <classname>Zend_CodeGenerator_Php_Parameter</classname> may be used to
  400. specify method parameters. Each parameter may have a position
  401. (if unspecified, the order in which they are registered with the
  402. method will be used), a default value, and a data type; a
  403. parameter name is required.
  404. </para>
  405. <para>
  406. そのクラスのAPIは下記の通りです。:
  407. </para>
  408. <programlisting role="php"><![CDATA[
  409. class Zend_CodeGenerator_Php_Parameter extends Zend_CodeGenerator_Php_Abstract
  410. {
  411. public static function fromReflection(
  412. Zend_Reflection_Parameter $reflectionParameter
  413. )
  414. public function setType($type)
  415. public function getType()
  416. public function setName($name)
  417. public function getName()
  418. public function setDefaultValue($defaultValue)
  419. public function getDefaultValue()
  420. public function setPosition($position)
  421. public function getPosition()
  422. public function generate()
  423. }
  424. ]]></programlisting>
  425. </sect3>
  426. <sect3 id="zend.codegenerator.reference.concrete.php-property">
  427. <title>Zend_CodeGenerator_Php_Property</title>
  428. <para>
  429. <classname>Zend_CodeGenerator_Php_Property</classname> describes a class
  430. property, which may be either a constant or a variable. In each
  431. case, the property may have an optional default value associated
  432. with it. Additionally, the visibility of variable properties may
  433. be set, per the parent class,
  434. <classname>Zend_CodeGenerator_Php_Member_Abstract</classname>.
  435. </para>
  436. <para>
  437. そのクラスのAPIは下記の通りです。:
  438. </para>
  439. <programlisting role="php"><![CDATA[
  440. class Zend_CodeGenerator_Php_Property
  441. extends Zend_CodeGenerator_Php_Member_Abstract
  442. {
  443. public static function fromReflection(
  444. Zend_Reflection_Property $reflectionProperty
  445. )
  446. public function setConst($const)
  447. public function isConst()
  448. public function setDefaultValue($defaultValue)
  449. public function getDefaultValue()
  450. public function generate()
  451. }
  452. ]]></programlisting>
  453. </sect3>
  454. </sect2>
  455. </sect1>