From 1e43667a8552f0916f0935d8bd9893afc8e4c528 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Mon, 9 Jan 2012 13:45:34 +0000 Subject: [PATCH] Add a new methodExists method to MWInit. --- includes/Init.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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. -- 2.20.1