HTMLForm: throw a warning when no callback is set
[mediawiki.git] / maintenance / checkAutoLoader.php
blobd199b6feae131437c2017406e5efc3124eaf4320
1 <?php
2 /**
3 * Check the autoloader
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.
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.
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
20 * @file
21 * @ingroup Maintenance
24 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
26 class CheckAutoLoader extends Maintenance {
27 public function __construct() {
28 parent::__construct();
29 $this->mDescription = "AutoLoader sanity checks";
31 public function execute() {
32 global $wgAutoloadLocalClasses, $IP;
33 $files = array_unique( $wgAutoloadLocalClasses );
35 foreach ( $files as $file ) {
36 if ( function_exists( 'parsekit_compile_file' ) ) {
37 $parseInfo = parsekit_compile_file( "$IP/$file" );
38 $classes = array_keys( $parseInfo['class_table'] );
39 } else {
40 $contents = file_get_contents( "$IP/$file" );
41 $m = array();
42 preg_match_all( '/\n\s*class\s+([a-zA-Z0-9_]+)/', $contents, $m, PREG_PATTERN_ORDER );
43 $classes = $m[1];
45 foreach ( $classes as $class ) {
46 if ( !isset( $wgAutoloadLocalClasses[$class] ) ) {
47 // printf( "%-50s Unlisted, in %s\n", $class, $file );
48 $this->output( "\t'$class' => '$file',\n" );
49 } elseif ( $wgAutoloadLocalClasses[$class] !== $file ) {
50 $this->output( "$class: Wrong file: found in $file, listed in " . $wgAutoloadLocalClasses[$class] . "\n" );
57 $maintClass = "CheckAutoLoader";
58 require_once( RUN_MAINTENANCE_IF_MAIN );