Вы также можете проверить наличие определенного метода, даже не создавая экземпляр класса
echo method_exists( bob, 'yippie' ) ? 'yes' : 'no';
Если вы хотите пойти еще дальше и убедиться, что «yippie» действительно статичен, используйте Reflection API (только PHP5)
try {
$method = new ReflectionMethod( 'bob::yippie' );
if ( $method->isStatic() )
{
// verified that bob::yippie is defined AND static, proceed
}
}
catch ( ReflectionException $e )
{
// method does not exist
echo $e->getMessage();
}
или вы можете объединить два подхода
if ( method_exists( bob, 'yippie' ) )
{
$method = new ReflectionMethod( 'bob::yippie' );
if ( $method->isStatic() )
{
// verified that bob::yippie is defined AND static, proceed
}
}