2010-06-28 3 views
21

저는 PHP 개발을 처음 접했고 커뮤니티에 주석을 사용하여 코드의 인라인 문서화에 대한 지침이 있는지 궁금합니다. Python의 PEP 257과 같은 것을 좋아하지만 인기있는 문서 추출 도구 또는 인기있는 제품의 문서 표준에 사용되는 형식으로 정했습니다. (javadoc는 매우 유사)PHP 문서화를위한 표준 스타일이 있습니까?

답변

10

PHP에 대한 API 문서의 가장 널리 사용되는 형태 phpDocumentor 별칭으로하는 PHPDoc입니다. 꽤 많은 IDE가 phpDocumentor 스타일 API 문서를 사용하여 자동 완성 힌트를 개선하기위한 정보를 추출 할 수도 있습니다.

2

phpdoc (phpDocumentor) 스타일이 일반적입니다. DocBlocks을 포함하는 DocComments을 사용합니다.

<?php 
/** 
* This is a DocBlock for a function. 
*/ 
function associatedFunction() 
{ 
} 

<?php 
/** 
* I belong to a file 
*/ 

/** 
* I belong to a class 
*/ 
class Def 
{ 
} 

태그와 주석 :

<?php 
/** 
    * A summary informing the user what the associated element does. 
    * 
    * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element 
    * and to provide some background information or textual references. 
    * 
    * @param string $myArgument With a *description* of this argument, these may also 
    * span multiple lines. 
    * 
    * @return void 
    */ 
    function myFunction($myArgument) 
    { 
    } 

Source

관련 문제