r108412 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108411‎ | r108412 | r108413 >
Date:13:45, 9 January 2012
Author:dantman
Status:ok
Tags:
Comment:
Add a new methodExists method to MWInit.
Modified paths:
  • /trunk/phase3/includes/Init.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Init.php
@@ -153,6 +153,27 @@
154154 }
155155
156156 /**
 157+ * Determine wether a method exists within a class, using a method which works
 158+ * under HipHop.
 159+ *
 160+ * Note that under HipHop when method_exists is given a string for it's class
 161+ * such as to test for a static method has the same issues as class_exists does.
 162+ *
 163+ * @param $class string
 164+ * @param $method string
 165+ *
 166+ * @return bool
 167+ */
 168+ static function methodExists( $class, $method ) {
 169+ try {
 170+ $r = new ReflectionMethod( $class, $method );
 171+ } catch( ReflectionException $r ) {
 172+ $r = false;
 173+ }
 174+ return $r !== false;
 175+ }
 176+
 177+ /**
157178 * Determine whether a function exists, using a method which works under
158179 * HipHop.
159180 *

Status & tagging log