【PhpDoc】コメントの書き方のまとめ

関数/メソッドの場合

例文
/**
* aaaの説明
*
* @param string $arg 第一引数
* @param integer $arg2 第二引数
* @return array 戻り値の説明
*/
function aaa($arg,$arg2){}

string
integer
object(オブジェクト)
array
mixed(いろんな型が返る場合),
resource(リソース型)

変数/define定数

/**
* 説明
* @see 関連関数
*/
のように書きます。

クラスの場合

/**
* クラスの説明
*
* @package パッケージ名:ここは、自分でうまく分類作れれば見やすくなる
* @author 作った人
* @since PHP 5.3 PHPのバージョンとかいれときます?
* @version 1.0.1
*/

DocBlockとは?

DocBlockとは、↓の部分のことを言い、
/**
* 関数aaaの説明文
*/
function aaa()
{

phpDocumentorの書き方:記述基本ルール

DocBlockの記述ルールに従う

DocBlockは、/** から始める
全てのコメント行の初めに”*”を入れているもののみ解析する:*で始まらないコメント行は無視。
コメントしたい定義のすぐ上に記載したものが解析される

Short DescriptionLong Description

Short Description

DocBlockの最初のラインから始まり、空白行またはピリオドで終わります。
ピリオドが含まれる単語(example.com や 0.1%のような)の後ろは無視されます。
3行以上になる場合は、最初の1行だけが有効になります。
HTML タグを含ませる事もできます。(記述可能なタグ)

Long Description

「長い説明文」は複数の行を書くことが出来ます。
HTML タグを含ませる事もできます

タグの中で使用頻度が高いタグ

@access

アクセス権限(private protected public)
private:phpDocに載らない
public:phpDocに載る
protected:不明
省略時はpublic

/**
* function funcA, access
* @access private ←phpDocには非表示
*/
function funcA(){ … }

@deprecated

古いもので、互換性のために残しているということを示す

@final

オーバーライドできない

@link

ハイパーリンク(URL)
/**
* 参考サイト http://blog.flavacube.com
* @link http://blog.flavacube.com
*/
define(“flavacube”,1);

@param

関数の引数
パラメータ: データ型、パラメータ名、説明
/**
* テスト関数
* @param bool $aaa 〇〇な値
* @return bool trueかfalseを返す
*/
function function1($aaa)
{
if($aaa)
{
return $aaa;
}
}

@return

関数の戻値
戻り値: データ型、説明

@see

別要素へのリンク

@todo

TODO,開発予定などを記載

@uses

参照している要素への相互リンク

@var

変数: データ型、説明

@author

作者を記述するタグ。
使用可能な関数
global variable, include, constant, function, define, class, variable, method ,page
< >で括られた場所はメールアドレスとして解釈されます。
/**
* @author Joe Shmoe <foo@bar.org>
*/

@copyright

copyrightの定義を行う
使用可能な関数
global variable, include, constant, function, define, class, variable, method, page

/**
* @copyright Copyright © 2010, flavacube.com
*/

@example

サンプルファイル
リンクしたいファイルを指定しておく。ハイライトで表示される。
/**
* @example ./sample.php 関数使用例
*/

@see

参照先を生成できる。
参照先が存在する場合はリンクが生成!
/**
* @see sample
*/
function sample2{ }
/**
* smple2の参考メソッド
*/
function sample{ }

@since

PHP5.0などバージョンを記載しておきますかね。

@version

自分たちで自由にバージョン定義しよう

カテゴリー: PC環境, php タグ: , , ,
【PhpDoc】コメントの書き方のまとめ” への1件のコメント
  1. power bank より:

    Türkiye’nin power bank tedarik deposuna hosgeldiniz! Tasinabilir mobil sarj cihazlari günümüzün popüler ürünlerindendir! Artik teknolojiden ayri yasayamiyoruz ve hepimizin sikça yasadigimiz sorunlardan biri sarj bitmesi! Aldiginiz iyi bir power bank mobil sarj bu konudaki eksiginizi tamamlayacaktir! Sirketimiz dünya ticaretinin önemli merkezlerinden olan ISTOÇ’tan tüm Türkiye’ye ürün göndermektedir?.

  2. editores libros より:

    Transmitir cultura es uno de las apuestas que Signo Editores se puso como meta cuando se fundó la empresa. A lo largo de los años, y con varias décadas vendiendo libros de máxima calidad, la compañía se ha convertido en un referente nacional, con delegaciones repartidas por toda España

  3. powerbank より:

    Türkiye’nin power bank tedarik deposuna hosgeldiniz! Tasinabilir mobil sarj cihazlari günümüzün popüler ürünlerindendir! Artik teknolojiden ayri yasayamiyoruz ve hepimizin sikça yasadigimiz sorunlardan biri sarj bitmesi! Aldiginiz iyi bir power bank mobil sarj bu konudaki eksiginizi tamamlayacaktir! Sirketimiz dünya ticaretinin önemli merkezlerinden olan ISTOÇ’tan tüm Türkiye’ye ürün göndermektedir?.

  4. Transmitir cultura es uno de las apuestas que Signo Editores se puso como meta cuando se fundó la empresa. A lo largo de los años, y con varias décadas vendiendo libros de máxima calidad, la compañía se ha convertido en un referente nacional, con delegaciones repartidas por toda España

  5. Hello, i think that i saw you visited my weblog so i came to “return the favor”.I am attempting to find things to enhance my site!I suppose its ok to use some of your ideas!!

  6. deutsch より:

    An impressive share! I’ve just forwarded this onto a coworker who had been doing a little homework on this. And he actually ordered me lunch because I found it for him… lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanx for spending the time to discuss this topic here on your site.

  7. rent dumpsters より:

    Hurrah, that’s what I was seeking for, what a data! existing here at this website, thanks admin of this website.|

  8. dumpster rental より:

    Wow! At last I got a website from where I can actually obtain helpful information concerning my study and knowledge.|

  9. Rm479@yahoo.com より:

    Hi there, just become alert to your blog via Google, and located that it is really informative. I am going to watch out for brussels. I will appreciate when you continue this in future. Lots of other folks will likely be benefited out of your writing

  10. Okno より:

    Your style is unique compared to other people I have read stuff from.

  11. Cena okna より:

    Your style is unique compared to other people I have read stuff from.

  12. It is really a great and useful piece of info. I’m satisfied that you shared this useful information with us. Please keep us informed like this. Thanks for sharing.

  13. Wow! Thank you! I constantly wanted to write on my site something like that. Can I take a portion of your post to my website?

  14. I do accept as true with all of the ideas you have offered for your post. They are very convincing and can certainly work. Still, the posts are too brief for novices. Could you please prolong them a little from next time? Thank you for the post.

  15. I am no longer sure the place you’re getting your info, but good topic. I must spend a while studying much more or understanding more. Thank you for magnificent information I was on the lookout for this info for my mission.|

  16. I am really enjoying the theme/design of your weblog. Do you ever run into any internet browser compatibility issues? A handful of my blog readers have complained about my blog not working correctly in Explorer but looks great in Chrome. Do you have any recommendations to help fix this problem?|

  17. Hi there, just changed into alert to your blog through Google, and located that it is really informative. I am gonna watch out for brussels. I’ll appreciate in case you continue this in future. Numerous other folks will be benefited from your writing

  18. Karimunjawa より:

    I simply needed to thank you so much again. I’m not certain what I could possibly have made to happen without the type of secrets documented by you about that concern. It had been a real difficult concern in my view, nevertheless understanding your well-written manner you managed that forced me to jump over contentment. I am just happy for this advice and in addition expect you comprehend what a powerful job your are undertaking instructing other individuals through your webblog. I know that you haven’t come across any of us.

  19. I haven’t checked in here for a while since I thought it was getting boring, but the last few posts are good quality so I guess I’ll add you back to my daily bloglist. You deserve it my friend 🙂

  20. Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it

  21. We can provide clear, simple guidance to ensure you select the best river cruise to meet your personal desires. Watch the video opposite then pick up your free travel report below.

  22. post (Blog 4 of 6) Bay of Bengal Expedition – OUR TRASHY TRAWLS Where’s it from and where’s it goin… appeared first on 5 Gyres Understanding Plastic Pollution Through Exploration, Education,

  23. Andy Yusuf より:

    As a Newbie, I am continuously browsing online for articles that can help me. Thank you

  24. I blog quite often and I seriously thank you for your content. This article has really peaked my interest. I’m going to book mark your website and keep checking for new information about once a week. I opted in for your Feed as well.

  25. I¡¦m not positive where you are getting your information, however good topic. I needs to spend some time learning much more or working out more. Thanks for excellent info I used to be searching for this information for my mission.

  26. Belgia より:

    Pretty! This was an incredibly wonderful post. Thanks for supplying this info.

  27. Find Out More より:

    I truly wanted to post a brief comment to be able to thank you for some of the lovely pointers you are sharing at this site. My incredibly long internet search has at the end of the day been honored with excellent facts and techniques to share with my good friends. I ‘d express that most of us site visitors are really lucky to exist in a wonderful site with so many special people with insightful tips and hints. I feel rather blessed to have come across your site and look forward to so many more entertaining moments reading here. Thanks a lot once more for all the details.

  28. wax warmers より:

    If you’re still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you’ll know which is right for you.

  29. Great goods from you, man. I have understand your stuff previous to and you are just too fantastic. I really like what you have acquired here, certainly like what you’re saying and the way in which you say it. You make it enjoyable and you still take care of to keep it smart. I can’t wait to read far more from you. This is actually a great web site.|

  30. Great site you have here.. It’s difficult to find quality writing like yours these days. I really appreciate people like you! Take care!!

  31. I have read so many articles about the blogger lovers except this article is genuinely a good post, keep it up.|

  32. Firma より:

    Some truly howling function on behalf with the owner of this internet site , dead wonderful topic matter.

  33. 匿名 より:

    Your style is unique compared to other people I have read stuff from.

  34. Hello, Neat post. There is a problem with your site in internet explorer, might check this

  35. Virgilio より:

    Nice post. I was checking continuously this weblog and I’m inspired!

    Extremely useful info specifically the closing phase 🙂 I take caare of uch info much.

    I was seeking this particular information for a long
    time. Thanks and good luck.

  36. I have seen a lot of blogs in blogspot. What purpose do they serve? Is it possible to make money through blogs. If yes how?.

  37. Someone necessarily help to make severely posts I’d state.
    This is the very first time I frequented your website page and so far?

    I amazed with the research you made to create this actual put up incredible.
    Great job!

  38. genital herpes より:

    Many. Institute. I’m very enthusiastic. Surprise.

9 Ping/トラックバック のために "【PhpDoc】コメントの書き方のまとめ"
  1. Dreary Day

    It was a dreary day here today, so I just took to messing around on the internet and realized

  2. Looking around

    I like to look in various places on the internet, often I will go to Stumble Upon and follow thru

  3. Digg

    While checking out DIGG yesterday I noticed this

  4. Buy WOW gold より:

    Digg

    While checking out DIGG today I found this

  5. Binary Trading より:

    Its hard to find good help

    I am forever proclaiming that its difficult to get good help, but here is

  6. wooden watches より:

    Dreary Day

    It was a dreary day here today, so I just took to piddeling around online and found

  7. Digg

    While checking out DIGG today I noticed this

  8. Hollywood より:

    Tumblr article

    I saw someone writing about this on Tumblr and it linked to

  9. white wall より:

    Healing’s Dragon

    to find issues to improve my site!I suppose its alright for making utilization of a few of your ideas!!