wiki.techinc.nl/tests/phpunit/includes/api/generateRandomImages.php
Bartosz Dziewoński 485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00

45 lines
983 B
PHP

<?php
/**
* Bootstrapping for test image file generation
*
* @file
*/
// Start up MediaWiki in command-line mode
require_once __DIR__ . "/../../../../maintenance/Maintenance.php";
require __DIR__ . "/RandomImageGenerator.php";
class GenerateRandomImages extends Maintenance {
public function getDbType() {
return Maintenance::DB_NONE;
}
public function execute() {
$getOptSpec = [
'dictionaryFile::',
'minWidth::',
'maxWidth::',
'minHeight::',
'maxHeight::',
'shapesToDraw::',
'shape::',
'number::',
'format::'
];
$options = getopt( null, $getOptSpec );
$format = $options['format'] ?? 'jpg';
unset( $options['format'] );
$number = isset( $options['number'] ) ? intval( $options['number'] ) : 10;
unset( $options['number'] );
$randomImageGenerator = new RandomImageGenerator( $options );
$randomImageGenerator->writeImages( $number, $format );
}
}
$maintClass = 'GenerateRandomImages';
require RUN_MAINTENANCE_IF_MAIN;