phpDocumentor phpDocumentor
[ class tree: phpDocumentor ] [ index: phpDocumentor ] [ all elements ]
phpDocumentor
Packages:
phpDocumentor
Converters

Tutorials/Manuals:
Package-level: Files:
actions.php
bug-560532.php
bug-772441.php
builder.php
Classes.inc
clone.inc.php
clone5.inc.php
common.inc.php
config.php
EventStack.inc
file_dialog.php
HighlightParserTests.php
IntermediateParser.inc
IntermediateParserTests.php
Io.inc
new_phpdoc.php
ParserClassTests.php
ParserDescCleanup.inc
ParserPageTests.php
phpdoc.inc
phpdoc.php
phpDocumentorSetupTests.php
phpDocumentorTParserTests.php
ProceduralPages.inc
Publisher.inc
Setup.inc.php
top.php
utilities.php
DescHTML
DescHTML.inc
DocBlockTags
DocBlockTags.inc
Errors
Errors.inc
InlineTags
InlineTags.inc
Links
LinkClasses.inc
ParserData
ParserData.inc
ParserDocBlock
ParserDocBlock.inc
ParserElements
ParserElements.inc
Parsers
Beautifier.php
HighlightParser.inc
Parser.inc
phpDocumentorTParser.inc
Tokenizer.php
TutorialHighlightParser.inc
XMLpackagePageParser.inc
setup
find_phpdoc.php
Tutorial
PackagePageElements.inc
WordParsers
phpDocumentorTWordParser.inc
WordParser.inc

Classes:
Parsers
Parser
parserDescParser
phpDocumentorTParser
phpDocumentor_HighlightParser
phpDocumentor_HighlightWordParser
phpDocumentor_peardoc2_XML_Beautifier
phpDocumentor_TutorialHighlightParser
phpDocumentor_XML_Beautifier_Tokenizer
ppageParser
XMLPackagePageParser
bug_772441
Classes
EventStack
Io
phpDocumentor_IntermediateParser
phpDocumentor_setup
ProceduralPages
Publisher
tests_HighlightParserTests
tests_IntermediateParserTests
tests_ParserClassTests
tests_ParserPageTests
tests_phpDocumentorSetupTests
tests_phpDocumentorTParserTests
DescHTML
parserB
parserBr
parserCode
parserDescVar
parserI
parserKbd
parserList
parserPre
parserSamp
DocBlockTags
parserAccessTag
parserExampleTag
parserFileSourceTag
parserLicenseTag
parserLinkTag
parserMethodTag
parserNameTag
parserParamTag
parserPropertyReadTag
parserPropertyTag
parserPropertyWriteTag
parserReturnTag
parserSeeTag
parserStaticvarTag
parserTag
parserTutorialTag
parserUsedByTag
parserUsesTag
parserVarTag
Errors
ErrorTracker
RecordError
RecordWarning
InlineTags
parserExampleInlineTag
parserIdInlineTag
parserInheritdocInlineTag
parserInlineTag
parserLinkInlineTag
parserSourceInlineTag
parserTocInlineTag
parserTutorialInlineTag
Links
abstractLink
classLink
constLink
defineLink
functionLink
globalLink
methodLink
pageLink
tutorialLink
varLink
Tutorial
parserCData
parserEntity
parserXMLDocBookTag
ParserData
parserBase
parserData
parserPage
parserStringWithInlineTags
WordParsers
ObjectWordParser
phpDocumentorTWordParser
WordParser
ParserDocBlock
parserDesc
parserDocBlock
ParserElements
parserClass
parserConst
parserDefine
parserElement
parserFunction
parserGlobal
parserInclude
parserMethod
parserPackagePage
parserTutorial
parserVar

Documentable PHP Elements

Elements of PHP source that phpDocumentor can automatically document

Authors

by Joshua Eichorn by Gregory Beaver by Chuck Burgess

Table of Contents

Introduction to Documentable Elements

phpDocumentor is capable of automatically documenting include statements, define statements, functions, procedural pages, classes, class variables, and class methods.

Procedural Elements

From phpDocumentor's perspective, the basic container for procedural elements (as in real life) is the file that contains them. To reflect this, it is possible to document information about the entire contents of a file. This is accomplished through the use of a page-level DocBlock (see DocBlocks for basic information on what a DocBlock is). A page-level DocBlock is the only DocBlock that cannot precede the element that it is documenting, as there is no way to precede a file. To solve this issue, the way phpDocumentor finds a page-level DocBlock is to parse the first DocBlock in a file as the page-level DocBlock, with certain conditions.

  1. <?php
  2. /**
  3. * Page-level DocBlock
  4. */
  5. define ('oops','Page-level DocBlock it is not!');
  6. ?>

This last example has one DocBlock, and it is the first DocBlock in a file, but it is not a Page-level DocBlock. How can phpDocumentor tell the difference between a Page-level DocBlock and any other DocBlock? Simple:

  1. <?php
  2. /**
  3. * Pretend this is a file
  4. *
  5. * Page-level DocBlock is here because it is the first DocBlock
  6. * in the file, and contains a @package tag
  7. * @package pagepackage
  8. */
  9. define ("almost","Now the Page-level DocBlock is for the page, and the Define has no docblock");?>

In phpDocumentor version 1.2.2, a Page-level DocBlock is the first DocBlock in a file if it contains a @package tag. However, this example will raise a warning like WARNING in test.php on line 8: Page-level DocBlock precedes "define almost", use another DocBlock to document the source element. You can eliminate the warning by adding documentation to the define as follows:

  1. <?php
  2. /**
  3. * Page-level DocBlock
  4. * @package pagepackage
  5. */
  6. /**
  7. * Define DocBlock
  8. */
  9. define ("ahhhh","Now the Page-level DocBlock is for the page, and the Define DocBlock for the define");
  10. ?>

Now, the page has its documentation, and the define has its own documentation.

So, a DocBlock is a page-level DocBlock IF AND ONLY IF it is both:

  1. The first DocBlock in a file

  2. One of:

  3. Contains a @package tag

  4. Immediately followed by another DocBlock for any documentable PHP element this is deprecated, always use a @package tag

A Page-level DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tags:

phpDocumentor will not document a file like the first example, there must be at least one documentable PHP element in the file.

include/require/include_once/require_once statements

phpDocumentor extracts the filename and attempts to link to documentation for that filename if possible. Include statements may only have any of the Standard phpDocumentor Tags

phpDocumentor will attempt to locate the included file in the list of files parsed, and if found will make a link to that file's documentation.


define statements

A define statement's DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tag:


function declarations

A function's DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tags:


global variables

A global variable's DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tag:

In addition, the global variable's DocBlock must contain the @global tag.


Class Elements

A class's DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tags:

DocBlock inheritance

New in version 1.2.0, DocBlock's are inherited by child classes, variables, and methods. There are a few simple rules for inheritance:

  • tags @author, @version, and @copyright are automatically inherited unless explicitly specified in the DocBlock

  • As in previous versions, @package and @subpackage are inherited unless explicitly specified in the DocBlock. We recommend that you explicitly use @package and @subpackage for every class to avoid problems with name conflicts that may arise

  • If there is no short description, the short description will be inherited.

  • If there is no long description, the long description will be inherited.

  • If there is a long description, and you still want to inherit the parent's description, use inline {@inheritdoc}

Be aware that this kind of docblock inheritance expects children to be in the same package as the parent. Otherwise, the docblock inheritance will not apply.

  1. /**
  2. * short desc
  3. *
  4. * long desc
  5. * @package test
  6. * @author me
  7. * @version 1.0
  8. * @abstract
  9. * @copyright never
  10. */
  11. class parclass
  12. {
  13. }
  14. // inherits entire DocBlock minus @abstract
  15. class child1 extends parclass
  16. {
  17. }
  18. // inherits DocBlock minus @abtract, short desc
  19. /**
  20. * overriding short desc
  21. */
  22. class child2 extends parclass
  23. {
  24. }
  25. // inherits @author, @version, @copyright, @package
  26. /**
  27. * overriding short desc
  28. *
  29. * overriding long desc
  30. */
  31. class child3 extends parclass
  32. {
  33. }
  34. // inherits @version, @copyright, @package
  35. /**
  36. * overriding short desc
  37. *
  38. * overriding long desc
  39. * @author you
  40. */
  41. class child4 extends parclass
  42. {
  43. }


class variables

A class variable's DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tag:


class methods

A method's DocBlock may have any of the standard phpDocumentor Tags (see Standard phpDocumentor Tags) plus the following tags:


phpDocumentor Tutorial phpDocumentor Tutorial phpDocumentor Tutorials

Documentation generated on 2011年12月06日 07:15:43 -0600 by phpDocumentor 1.4.4

AltStyle によって変換されたページ (->オリジナル) /