PHPのクラス定義を取り出す方法

PHP, PECL

08:55:25, by admin Email , 291 words, 2619 views   Japanese (JP) del.icio.us

あったのね・・・。

(ノ・・)ン。。。。。。(((●コロコロッ

PHPはもちろん5以上。
<?php
Reflection::export(new ReflectionClass('SimpleXMLElement'));


_〆(。。)ヘェ…

[More:]


PHPのマニュアル、
異常に使いにくくて有名なのだが。

例えば、PECLのimagick2を使おうとして、
定数、プロパティ、メソッドにどう言ったモノが存在するのか知りたい時、
みなさんどうなさっているだろうか?


マニュアルを熟読することにしているのだが、
あのマニュアル、関数名とメソッド名が微妙に異なっていて、
探しにくいと思ったことはないだろうか?
なので、get_class_methods, get_class_varsで調べた方が手っ取り早い時がある。
(動作はメソッド名から想像出来る。)

ただ、それも限度があるので、
一度にどっと取得出来るに越したことはない。
そんな方法はない。かというとそうでも無いらしい。
PHPにも一応リフレクションクラスが存在するらしい。
http://www.php.net/language.oop5.reflection

必要なものを使えばいいと思うが、
とりあえず全部知りたいので、
Reflection::exportで全部取得する。

下記はmecabクラス
http://page2.xrea.jp/
のダンプ結果。
Class [ <internal:mecab> class MeCab ] {
- Constants [4] {
Constant [ string VERSION ] { 0.96 }
Constant [ integer SYS_DIC ] { 0 }
Constant [ integer USR_DIC ] { 1 }
Constant [ integer UNK_DIC ] { 2 }
}
- Static properties [0] {
}
- Static methods [2] {
Method [ <internal:mecab> static public method version ] {
}
Method [ <internal:mecab> static public method split ] {

- Parameters [4] {
Parameter #0 [ <required> $str ]
Parameter #1 [ <optional> $dicdir ]
Parameter #2 [ <optional> $userdic ]
Parameter #3 [ <optional> $filter ]
}
}
}
- Properties [0] {
}
- Methods [10] {
Method [ <internal:mecab, ctor> public method __construct ] {

- Parameters [1] {
Parameter #0 [ <optional> array $arg ]
}
}
Method [ <internal:mecab> public method parse ] {

- Parameters [3] {
Parameter #0 [ <required> $str ]
Parameter #1 [ <optional> $len ]
Parameter #2 [ <optional> $olen ]
}
}
Method [ <internal:mecab> public method parseToString ] {

- Parameters [3] {
Parameter #0 [ <required> $str ]
Parameter #1 [ <optional> $len ]
Parameter #2 [ <optional> $olen ]
}
}
Method [ <internal:mecab> public method parseToNode ] {

- Parameters [2] {
Parameter #0 [ <required> $str ]
Parameter #1 [ <optional> $len ]
}
}
Method [ <internal:mecab> public method parseNBest ] {

- Parameters [4] {
Parameter #0 [ <required> $n ]
Parameter #1 [ <required> $str ]
Parameter #2 [ <optional> $len ]
Parameter #3 [ <optional> $olen ]
}
}
Method [ <internal:mecab> public method parseNBestInit ] {

- Parameters [2] {
Parameter #0 [ <required> $str ]
Parameter #1 [ <optional> $len ]
}
}
Method [ <internal:mecab> public method next ] {

- Parameters [1] {
Parameter #0 [ <optional> $olen ]
}
}
Method [ <internal:mecab> public method nextNode ] {
}
Method [ <internal:mecab> public method formatNode ] {

- Parameters [1] {
Parameter #0 [ <required> MeCab_Node $node ]
}
}
Method [ <internal:mecab> public method dictionaryInfo ] {
}
}
}



マニュアルが全く見つからないモジュールも存在するので、
重宝するやも。




Trackback address for this post:

http://hain.jp/htsrv/trackback.php/180

Comments, Trackbacks:

No Comments/Trackbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
This is a captcha-picture. It is used to prevent mass-access by robots.

Please enter the characters from the image above. (case insensitive)

powered by b2evolution

shinobi

Neighbors
Relative
Favorites
PR

極論istの技術屋を始めて早幾年。 流れの速い業界の波にもまれながらも精一杯生きている様をとくとごらんあれ。

Archives
スポンサー

Latest bookmark
Search

Categories

Who's Online?
Misc
Syndicate this blog XML

Valid XHTML 1.0! Valid CSS! Valid RSS 2.0! Valid Atom 1.0!