3 use MediaWiki\Maintenance\Maintenance
;
4 use MediaWiki\Registration\ExtensionJsonValidationError
;
5 use MediaWiki\Registration\ExtensionJsonValidator
;
7 // @codeCoverageIgnoreStart
8 require_once __DIR__
. '/Maintenance.php';
9 // @codeCoverageIgnoreEnd
11 class ValidateRegistrationFile
extends Maintenance
{
12 public function __construct() {
13 parent
::__construct();
16 'Path or glob pattern to extension.json/skin.json file.',
21 public function execute() {
22 $validator = new ExtensionJsonValidator( function ( $msg ) {
23 $this->fatalError( $msg );
25 $validator->checkDependencies();
26 $paths = glob( $this->getArg( 0 ) );
27 foreach ( $paths as $path ) {
29 $validator->validate( $path );
30 $this->output( "$path validates against the schema!\n" );
31 } catch ( ExtensionJsonValidationError
$e ) {
32 $this->fatalError( $e->getMessage() );
38 // @codeCoverageIgnoreStart
39 $maintClass = ValidateRegistrationFile
::class;
40 require_once RUN_MAINTENANCE_IF_MAIN
;
41 // @codeCoverageIgnoreEnd