Add a new methodExists method to MWInit.
authorDaniel Friesen <dantman@users.mediawiki.org>
Mon, 9 Jan 2012 13:45:34 +0000 (13:45 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Mon, 9 Jan 2012 13:45:34 +0000 (13:45 +0000)
includes/Init.php

index c4bdc5f..72c1054 100644 (file)
@@ -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.