confluence /maintenance/checkAutoLoader.php

Language PHP Lines 30
MD5 Hash 2ed87d8f676eb6527296a2be6803b2d2
Repository https://github.com/tav/confluence.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
if ( php_sapi_name() != 'cli' ) exit;

$IP = dirname(__FILE__) .'/..';
require( "$IP/includes/AutoLoader.php" );
$files = array_unique( $wgAutoloadLocalClasses );

foreach ( $files as $file ) {
	if( function_exists( 'parsekit_compile_file' ) ){
		$parseInfo = parsekit_compile_file( "$IP/$file" );
		$classes = array_keys( $parseInfo['class_table'] );
	} else {
		$contents = file_get_contents( "$IP/$file" );
		$m = array();
		preg_match_all( '/\n\s*class\s+([a-zA-Z0-9_]+)/', $contents, $m, PREG_PATTERN_ORDER );
		$classes = $m[1];
	}
	foreach ( $classes as $class ) {
		if ( !isset( $wgAutoloadLocalClasses[$class] ) ) {
			//printf( "%-50s Unlisted, in %s\n", $class, $file );
			echo "		'$class' => '$file',\n";
		} elseif ( $wgAutoloadLocalClasses[$class] !== $file ) {
			echo "$class: Wrong file: found in $file, listed in " . $wgAutoloadLocalClasses[$class] . "\n";
		}
	}

}
Back to Top