X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FgenerateJsonI18n.php;h=e9f4ecada32622c0dfc5bf0916c4111e1bcf2d6f;hb=7afced64454ad30d688540f7626448ac2faefebb;hp=a84f2ae52c789e4c98873d05d0450290728da21b;hpb=6ead43f2123fec255acccce6bf68f31b51196a55;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/generateJsonI18n.php b/maintenance/generateJsonI18n.php index a84f2ae52c..e9f4ecada3 100644 --- a/maintenance/generateJsonI18n.php +++ b/maintenance/generateJsonI18n.php @@ -55,7 +55,7 @@ class GenerateJsonI18n extends Maintenance { if ( $extension ) { if ( $phpfile ) { - $this->error( "The phpfile is already specified, conflicts with --extension.", 1 ); + $this->fatalError( "The phpfile is already specified, conflicts with --extension." ); } $phpfile = "$IP/extensions/$extension/$extension.i18n.php"; } @@ -79,6 +79,7 @@ class GenerateJsonI18n extends Maintenance { $dir_iterator = new RecursiveDirectoryIterator( dirname( $phpfile ) ); $iterator = new RecursiveIteratorIterator( $dir_iterator, RecursiveIteratorIterator::LEAVES_ONLY ); + /** @var SplFileInfo $fileObject */ foreach ( $iterator as $path => $fileObject ) { if ( fnmatch( "*.i18n.php", $fileObject->getFilename() ) ) { $this->output( "Converting $path.\n" ); @@ -101,28 +102,28 @@ class GenerateJsonI18n extends Maintenance { $this->output( "Creating directory $jsondir.\n" ); $success = mkdir( $jsondir ); if ( !$success ) { - $this->error( "Could not create directory $jsondir", 1 ); + $this->fatalError( "Could not create directory $jsondir" ); } } if ( !is_readable( $phpfile ) ) { - $this->error( "Error reading $phpfile", 1 ); + $this->fatalError( "Error reading $phpfile" ); } $messages = null; include $phpfile; $phpfileContents = file_get_contents( $phpfile ); if ( !isset( $messages ) ) { - $this->error( "PHP file $phpfile does not define \$messages array", 1 ); + $this->fatalError( "PHP file $phpfile does not define \$messages array" ); } if ( !$messages ) { - $this->error( "PHP file $phpfile contains an empty \$messages array. " . - "Maybe it was already converted?", 1 ); + $this->fatalError( "PHP file $phpfile contains an empty \$messages array. " . + "Maybe it was already converted?" ); } if ( !isset( $messages['en'] ) || !is_array( $messages['en'] ) ) { - $this->error( "PHP file $phpfile does not set language codes", 1 ); + $this->fatalError( "PHP file $phpfile does not set language codes" ); } foreach ( $messages as $langcode => $langmsgs ) { @@ -142,7 +143,7 @@ class GenerateJsonI18n extends Maintenance { FormatJson::encode( $langmsgs, "\t", FormatJson::ALL_OK ) . "\n" ); if ( $success === false ) { - $this->error( "FAILED to write $jsonfile", 1 ); + $this->fatalError( "FAILED to write $jsonfile" ); } $this->output( "$jsonfile\n" ); } @@ -182,7 +183,7 @@ class GenerateJsonI18n extends Maintenance { /** * Get an array of author names from a documentation comment containing @author declarations. * @param string $comment Documentation comment - * @return array Array of author names (strings) + * @return string[] Array of author names */ protected function getAuthorsFromComment( $comment ) { $matches = null; @@ -192,5 +193,5 @@ class GenerateJsonI18n extends Maintenance { } } -$maintClass = "GenerateJsonI18n"; +$maintClass = GenerateJsonI18n::class; require_once RUN_MAINTENANCE_IF_MAIN;