4 * Some functions that are useful during startup.
7 static $compilerVersion;
10 * Get the version of HipHop used to compile, or false if MediaWiki was not
11 * compiled. This works by having our build script insert a special function
12 * into the compiled code.
14 static function getCompilerVersion() {
15 if ( self
::$compilerVersion === null ) {
16 if ( self
::functionExists( 'wfHipHopCompilerVersion' ) ) {
17 self
::$compilerVersion = wfHipHopCompilerVersion();
19 self
::$compilerVersion = false;
22 return self
::$compilerVersion;
26 * Returns true if we are running under HipHop, whether in compiled or
31 static function isHipHop() {
32 return function_exists( 'hphp_thread_set_warmup_enabled' );
36 * Get a fully-qualified path for a source file relative to $IP. Including
37 * such a path under HipHop will force the file to be interpreted. This is
38 * useful for configuration files.
44 static function interpretedPath( $file ) {
50 * If we are running code compiled by HipHop, this will pass through the
51 * input path, assumed to be relative to $IP. If the code is interpreted,
52 * it will converted to a fully qualified path. It is necessary to use a
53 * path which is relative to $IP in order to make HipHop use its compiled
60 static function compiledPath( $file ) {
63 if ( defined( 'MW_COMPILED' ) ) {
71 * Determine whether a class exists, using a method which works under HipHop.
73 * Note that it's not possible to implement this with any variant of
74 * class_exists(), because class_exists() returns false for classes which
77 * Calling class_exists() on a literal string causes the class to be made
78 * "volatile", which means (as of March 2011) that the class is broken and
79 * can't be used at all. So don't do that. See
80 * https://github.com/facebook/hiphop-php/issues/314
82 * @param $class string
86 static function classExists( $class ) {
88 $r = new ReflectionClass( $class );
89 } catch( ReflectionException
$r ) {
96 * Determine whether a function exists, using a method which works under
99 * @param $function string
103 static function functionExists( $function ) {
105 $r = new ReflectionFunction( $function );
106 } catch( ReflectionException
$r ) {
113 * Call a static method of a class with variable arguments without causing
114 * it to become volatile.
116 static function callStaticMethod( $className, $methodName, $args ) {
117 $r = new ReflectionMethod( $className, $methodName );
118 return $r->invokeArgs( null, $args );