From: Daniel Friesen Date: Mon, 9 Jan 2012 13:45:34 +0000 (+0000) Subject: Add a new methodExists method to MWInit. X-Git-Tag: 1.31.0-rc.0~25399 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=1e43667a8552f0916f0935d8bd9893afc8e4c528;p=lhc%2Fweb%2Fwiklou.git Add a new methodExists method to MWInit. --- diff --git a/includes/Init.php b/includes/Init.php index c4bdc5f7a0..72c10543af 100644 --- a/includes/Init.php +++ b/includes/Init.php @@ -152,6 +152,27 @@ class MWInit { return $r !== false; } + /** + * Determine wether a method exists within a class, using a method which works + * under HipHop. + * + * Note that under HipHop when method_exists is given a string for it's class + * such as to test for a static method has the same issues as class_exists does. + * + * @param $class string + * @param $method string + * + * @return bool + */ + static function methodExists( $class, $method ) { + try { + $r = new ReflectionMethod( $class, $method ); + } catch( ReflectionException $r ) { + $r = false; + } + return $r !== false; + } + /** * Determine whether a function exists, using a method which works under * HipHop.