3

クラスの概要を効果的に示すことができる関数またはクラスを探しています。

class MyClass{

  /*
  * Perhaps include the function comments
  * in the function.
  */
  function mainFunction(){
    //Does Something
  } 

  function functionWithArgs($arg1,$arg2=false){
    //Does Something
    //The function I want will give e the arguments w/default values
  }

}

このクラスに関する情報、さらにはファイルへの何らかのアクセスを可能にする関数またはライブラリが存在しますか。

元。

get_file_outline('fileWithAboveClass.php');

また

get_class_outline('MyClass');

誰かがどちらかを知っているか、これを簡単に書く方法を知っていますか?

4

2 に答える 2

6

PHPリフレクションAPIを見てください

//use the ReflectionClass to find out about MyClass
$classInfo = new ReflectionClass('MyClass'); 

//then you can find out pretty much anything you want to know...
$methods = $classInfo->getMethods(); 
var_dump($methods);

//you can even extract your comments, e.g.
$comment=$classInfo->getMethod('mainFunction')->getDocComment();

コメント抽出を機能させるには、PHPDoc / Doxygenコメントのようにフォーマットし、先頭から始める必要があることに注意してください。/**

于 2011-01-22T19:31:22.407 に答える
0

関数とクラスを検査するために使用できるコマンドラインオプションもあります。

$ php --rc DateTime

DateTimeクラスに関するすべての詳細を提供しますが、

$ php --rf in_array

「in_array」関数の引数を提供します。

コーディング時にターミナルを使用している場合は、PHPマニュアルで常に検索するのではなく、非常に便利です;)

于 2011-01-22T21:30:19.853 に答える