Sync up with Parsoid parserTests.txt
[mediawiki.git] / includes / MediaWikiVersionFetcher.php
blobeb5ec78c826a3463da2d71dd38e4ddb197c2f6f8
1 <?php
3 /**
4 * Provides access to MediaWiki's version without requiring MediaWiki (or anything else)
5 * being loaded first.
7 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
8 */
9 class MediaWikiVersionFetcher {
11 /**
12 * Get the MediaWiki version, extracted from the PHP source file where it is defined.
14 * @return string
15 * @throws RuntimeException
17 public function fetchVersion() {
18 $code = file_get_contents( __DIR__ . '/Defines.php' );
20 if ( !preg_match( "/define\( 'MW_VERSION', '([^']+)'/", $code, $matches ) ) {
21 throw new RuntimeException( 'Could not extract the MediaWiki version from Defines.php' );
24 return $matches[1];