Merge "docs: Fix typo"
[mediawiki.git] / maintenance / validateRegistrationFile.php
blobf3e5fbfed500696a5c0df1f0d13de763e286fa68
1 <?php
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();
14 $this->addArg(
15 'path',
16 'Path or glob pattern to extension.json/skin.json file.',
17 true
21 public function execute() {
22 $validator = new ExtensionJsonValidator( function ( $msg ) {
23 $this->fatalError( $msg );
24 } );
25 $validator->checkDependencies();
26 $paths = glob( $this->getArg( 0 ) );
27 foreach ( $paths as $path ) {
28 try {
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