summaryrefslogtreecommitdiff
blob: d6be1612e26ef4134d02923fef1dd0608bd17f7e (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

// Keep in sync with same script in Flow.

require_once getenv( 'MW_INSTALL_PATH' ) !== false
	? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
	: __DIR__ . '/../../../maintenance/Maintenance.php';

/**
 * Generates Echo autoload info
 */

class GenerateEchoAutoload extends Maintenance {
	public function __construct() {
		parent::__construct();
		$this->mDescription = 'Generates Echo autoload data';
	}

	public function execute() {
		$base = dirname( __DIR__ );
		$generator = new AutoloadGenerator( $base );
		$dirs = [
			'includes',
			'tests',
			'maintenance',
		];
		foreach ( $dirs as $dir ) {
			$generator->readDir( $base . '/' . $dir );
		}
		foreach ( glob( $base . '/*.php' ) as $file ) {
			$generator->readFile( $file );
		}

		$target = $generator->getTargetFileInfo();

		file_put_contents(
			$target['filename'],
			$generator->getAutoload( basename( __DIR__ ) . '/' . basename( __FILE__ ) )
		);

		echo "Done.\n\n";
	}
}

$maintClass = "GenerateEchoAutoload";
require_once RUN_MAINTENANCE_IF_MAIN;