CakeFest 2024: The Official CakePHP Conference

ReflectionMethod::getModifiers

(PHP 5, PHP 7, PHP 8)

ReflectionMethod::getModifiersメソッドの修飾子を取得する

説明

public ReflectionMethod::getModifiers(): int

このメソッドのアクセス修飾子のビットフィールドを返します。

パラメータ

この関数にはパラメータはありません。

戻り値

修飾子をあらわす数値を返します。修飾子の一覧は以下のとおりです。 これらの修飾子の実際の意味については 定義済みの定数 に説明があります。

例1 ReflectionMethod::getModifiers() の例

<?php
class Testing
{
final public static function
foo()
{
return;
}
public function
bar()
{
return;
}
}

$foo = new ReflectionMethod('Testing', 'foo');

echo
"Modifiers for method foo():\n";
echo
$foo->getModifiers() . "\n";
echo
implode(' ', Reflection::getModifierNames($foo->getModifiers())) . "\n";

$bar = new ReflectionMethod('Testing', 'bar');

echo
"Modifiers for method bar():\n";
echo
$bar->getModifiers() . "\n";
echo
implode(' ', Reflection::getModifierNames($bar->getModifiers()));
?>

上の例の出力は、 たとえば以下のようになります。

Modifiers for method foo():
49
final public static
Modifiers for method bar():
1
public

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top