allow localization of elements via data-msg-text and data-msg-html
[lhc/web/wiklou.git] / maintenance / checkAutoLoader.php
1 <?php
2 /**
3 * Check the autoloader
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Maintenance
22 */
23
24 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
25
26 /**
27 * Maintenance script to check classes definitions in the autoloader.
28 *
29 * @ingroup Maintenance
30 */
31 class CheckAutoLoader extends Maintenance {
32 public function __construct() {
33 parent::__construct();
34 $this->mDescription = "AutoLoader sanity checks";
35 }
36 public function execute() {
37 global $wgAutoloadLocalClasses, $IP;
38 $files = array_unique( $wgAutoloadLocalClasses );
39
40 foreach ( $files as $file ) {
41 if ( function_exists( 'parsekit_compile_file' ) ) {
42 $parseInfo = parsekit_compile_file( "$IP/$file" );
43 $classes = array_keys( $parseInfo['class_table'] );
44 } else {
45 $contents = file_get_contents( "$IP/$file" );
46 $m = array();
47 preg_match_all( '/\n\s*class\s+([a-zA-Z0-9_]+)/', $contents, $m, PREG_PATTERN_ORDER );
48 $classes = $m[1];
49 }
50 foreach ( $classes as $class ) {
51 if ( !isset( $wgAutoloadLocalClasses[$class] ) ) {
52 // printf( "%-50s Unlisted, in %s\n", $class, $file );
53 $this->output( "\t'$class' => '$file',\n" );
54 } elseif ( $wgAutoloadLocalClasses[$class] !== $file ) {
55 $this->output( "$class: Wrong file: found in $file, listed in " . $wgAutoloadLocalClasses[$class] . "\n" );
56 }
57 }
58 }
59 }
60 }
61
62 $maintClass = "CheckAutoLoader";
63 require_once( RUN_MAINTENANCE_IF_MAIN );