Debian Codegraph @

maintenance/validateRegistrationFile.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Registration\ExtensionJsonValidationError;
4 use MediaWiki\Registration\ExtensionJsonValidator;
5
6 // @codeCoverageIgnoreStart
7 require_once __DIR__ . '/Maintenance.php';
8 // @codeCoverageIgnoreEnd
9
10 class ValidateRegistrationFile extends Maintenance {
11 public function __construct() {
12 parent::__construct();
13 $this->addArg(
14 'path',
15 'Path or glob pattern to extension.json/skin.json file.',
16 true
17 );
18 }
19
20 public function execute() {
21 $validator = new ExtensionJsonValidator( function ( $msg ) {
22 $this->fatalError( $msg );
23 } );
24 $validator->checkDependencies();
25 $paths = glob( $this->getArg( 0 ) );
26 foreach ( $paths as $path ) {
27 try {
28 $validator->validate( $path );
29 $this->output( "$path validates against the schema!\n" );
30 } catch ( ExtensionJsonValidationError $e ) {
31 $this->fatalError( $e->getMessage() );
32 }
33 }
34 }
35 }
36
37 // @codeCoverageIgnoreStart
38 $maintClass = ValidateRegistrationFile::class;
39 require_once RUN_MAINTENANCE_IF_MAIN;
40 // @codeCoverageIgnoreEnd