0
$this->categories = tx_dagoupost_lib::getCategories();

上記のコードの場合: getCategories()static または not として宣言されているかどうかを確認するにはどうすればよいですか? 通常の関数を次のように呼び出すこともできるためtx_dagoupost_lib::getCategories();、適切ではありませんが。これを使用できるようです: ReflectionMethod::isStatic、しかし、使用方法がわかりません。ここには例がありません: http://php.net/manual/en/reflectionmethod.isstatic.phpgetCategories()静的関数かどうかを確認します。

4

3 に答える 3

1

ドキュメントの残りの部分に目を通すと、次のようにしてオブジェクトReflectionを取得することがわかります。ReflectionMethod

$class = new ReflectionClass('tx_dagoupost_lib');
$method = $class->getMethod('getCategories');
if ($method->isStatic()) {
    ...
}
于 2013-08-16T07:28:02.360 に答える
1

あなたができる:

$check_static = new ReflectionMethod('tx_dagoupost_lib', 'getCategories');

if( $check_static->isStatic() ) {
   echo "Its static method";
}
于 2013-08-16T07:28:08.493 に答える
0

次のようなものを使用できます。

$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_FINAL);
var_dump($methods);

詳細を表示する

于 2013-08-16T07:30:51.473 に答える