'ComposerJson' => __DIR__ . '/includes/libs/composer/ComposerJson.php',
'ComposerLock' => __DIR__ . '/includes/libs/composer/ComposerLock.php',
'ComposerPackageModifier' => __DIR__ . '/includes/composer/ComposerPackageModifier.php',
+ 'ComposerPhpunitXmlCoverageEdit' => __DIR__ . '/includes/composer/ComposerPhpunitXmlCoverageEdit.php',
'ComposerVendorHtaccessCreator' => __DIR__ . '/includes/composer/ComposerVendorHtaccessCreator.php',
'ComposerVersionNormalizer' => __DIR__ . '/includes/composer/ComposerVersionNormalizer.php',
'CompressOld' => __DIR__ . '/maintenance/storage/compressOld.php',
"autoload": {
"psr-0": {
"ComposerHookHandler": "includes/composer",
- "ComposerVendorHtaccessCreator": "includes/composer"
+ "ComposerVendorHtaccessCreator": "includes/composer",
+ "ComposerPhpunitXmlCoverageEdit":"includes/composer"
}
},
"autoload-dev": {
"phpunit": "phpunit",
"phpunit:unit": "phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit",
"phpunit:integration": "phpunit --colors=always --testsuite=core:integration,extensions:integration,skins:integration",
- "phpunit:coverage": "phpunit --testsuite=core:unit --exclude-group Dump,Broken"
+ "phpunit:coverage": "phpunit --testsuite=core:unit --exclude-group Dump,Broken",
+ "phpunit:coverage-edit": "ComposerPhpunitXmlCoverageEdit::onEvent"
},
"config": {
"optimize-autoloader": true,
*
* @note This class uses setter methods instead of a constructor so that
* it can be compatible with PHP 4, PHP 5 and PHP 7 (without warnings).
- *
- * @class
*/
class PHPVersionCheck {
/* @var string The number of the MediaWiki version used. */
}
/**
+ * Select a request by class name.
+ *
* @codingStandardsIgnoreStart
- * @template T
+ * @phan-template T
* @codingStandardsIgnoreEnd
- * Select a request by class name.
* @param AuthenticationRequest[] $reqs
* @param string $class Class name
* @phan-param class-string<T> $class
--- /dev/null
+<?php
+
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+/**
+ * Edit phpunit.xml to speed up code coverage generation.
+ *
+ * Usage: composer phpunit:coverage-edit -- extensions/ExtensionName
+ *
+ * This class runs *outside* of the normal MediaWiki
+ * environment and cannot depend upon any MediaWiki
+ * code.
+ */
+class ComposerPhpunitXmlCoverageEdit {
+
+ public static function onEvent( $event ) {
+ $IP = dirname( dirname( __DIR__ ) );
+ // TODO: Support passing arbitrary directories for core (or extensions/skins).
+ $args = $event->getArguments();
+ if ( count( $args ) !== 1 ) {
+ throw new InvalidArgumentException( 'Pass extensions/$extensionName as an argument, ' .
+ 'e.g. "composer phpunit:coverage-edit -- extensions/BoilerPlate"' );
+ }
+ $project = current( $args );
+ $phpunitXml = \PHPUnit\Util\Xml::loadFile( $IP . '/phpunit.xml.dist' );
+ $whitelist = iterator_to_array( $phpunitXml->getElementsByTagName( 'whitelist' ) );
+ /** @var DOMNode $childNode */
+ foreach ( $whitelist as $childNode ) {
+ $childNode->parentNode->removeChild( $childNode );
+ }
+ $whitelistElement = $phpunitXml->createElement( 'whitelist' );
+ $whitelistElement->setAttribute( 'addUncoveredFilesFromWhitelist', 'false' );
+ // TODO: Use AutoloadClasses from extension.json to load the relevant directories
+ foreach ( [ 'includes', 'src', 'maintenance' ] as $dir ) {
+ $dirElement = $phpunitXml->createElement( 'directory', $project . '/' . $dir );
+ $dirElement->setAttribute( 'suffix', '.php' );
+ $whitelistElement->appendChild( $dirElement );
+
+ }
+ $phpunitXml->getElementsByTagName( 'filter' )->item( 0 )
+ ->appendChild( $whitelistElement );
+ $phpunitXml->formatOutput = true;
+ $phpunitXml->save( $IP . '/phpunit.xml' );
+ }
+}
if ( $samePage && $this->mNewPage && $permissionManager->quickUserCan(
'edit', $user, $this->mNewPage
) ) {
- if ( $this->mNewRev->isCurrent() && $permissionManager->userCan(
+ if ( $this->mNewRev->isCurrent() && $permissionManager->quickUserCan(
'rollback', $user, $this->mNewPage
) ) {
$rollbackLink = Linker::generateRollback( $this->mNewRev, $this->getContext(),
$filterSelection = Html::rawElement( 'div', [], '' );
}
- $labelUsername = Xml::radioLabel(
+ $labelUsername = Xml::label(
$this->msg( 'sp-contributions-username' )->text(),
- 'contribs',
- 'user',
- 'user',
- true,
- [ 'class' => 'mw-input' ]
+ 'mw-target-user-or-ip'
);
$input = Html::input(
'target',
* The web server should generally be configured to make this accessible via a canonical URL/URI,
* such as <http://my.domain.org/data/main/Foo>.
*
- * @class
* @ingroup SpecialPage
*/
class SpecialPageData extends SpecialPage {
'callback' => 'processRow',
];
+ /** @var LocalRepo|null */
+ private $repo;
+
public function __construct() {
parent::__construct();
$this->addDescription( 'Script to clean up broken, unparseable upload filenames' );
* @return string
*/
private function filePath( $name ) {
- if ( !isset( $this->repo ) ) {
+ if ( $this->repo === null ) {
$this->repo = RepoGroup::singleton()->getLocalRepo();
}
class CompareParsers extends DumpIterator {
private $count = 0;
+ /** @var bool */
+ private $saveFailed;
+ /** @var bool */
+ private $stripParametersEnabled;
+ /** @var bool */
+ private $showParsedOutput;
+ /** @var bool */
+ private $showDiff;
+ /** @var ParserOptions */
+ private $options;
+ /** @var int */
+ private $failed;
public function __construct() {
parent::__construct();
* @ingroup Maintenance
*/
abstract class DumpIterator extends Maintenance {
-
private $count = 0;
private $startTime;
+ /** @var string|bool|null */
+ private $from;
public function __construct() {
parent::__construct();
$revision->setTitle( Title::newFromText(
rawurldecode( basename( $this->getOption( 'file' ), '.txt' ) )
) );
+ $this->from = false;
$this->handleRevision( $revision );
return;
}
$this->count++;
- if ( isset( $this->from ) ) {
+ if ( $this->from !== false ) {
if ( $this->from != $title ) {
return;
}
public $imageBasePath = false;
/** @var array|false */
public $nsFilter = false;
+ /** @var bool|resource */
+ public $stderr;
+ /** @var callable|null */
+ protected $importCallback;
+ /** @var callable|null */
+ protected $logItemCallback;
+ /** @var callable|null */
+ protected $uploadCallback;
+ /** @var int */
+ protected $startTime;
function __construct() {
parent::__construct();
public $dumpUploadFileContents = false;
public $orderRevs = false;
public $limitNamespaces = [];
+ /** @var bool|resource */
+ public $stderr;
protected $reportingInterval = 100;
protected $pageCount = 0;
protected $ID = 0;
+ /** @var int */
+ protected $startTime;
+ /** @var int */
+ protected $pageCountPart;
+ /** @var int */
+ protected $revCountPart;
+ /** @var int */
+ protected $maxCount;
+ /** @var int */
+ protected $timeOfCheckpoint;
+ /** @var ExportProgressFilter */
+ protected $egress;
+ /** @var string */
+ protected $buffer;
+ /** @var array|false */
+ protected $openElement;
+ /** @var bool */
+ protected $atStart;
+ /** @var string|null */
+ protected $thisRevModel;
+ /** @var string|null */
+ protected $thisRevFormat;
+ /** @var string */
+ protected $lastName;
+ /** @var string */
+ protected $state;
+
/**
* The dependency-injected database to use.
*
* @ingroup Maintenance
*/
class MWDocGen extends Maintenance {
+ /** @var string */
+ private $doxygen;
+ /** @var string */
+ private $mwVersion;
+ /** @var string */
+ private $output;
+ /** @var string */
+ private $input;
+ /** @var string */
+ private $inputFilter;
+ /** @var string */
+ private $template;
+ /** @var string[] */
+ private $excludes;
+ /** @var string[] */
+ private $excludePatterns;
+ /** @var bool */
+ private $doDot;
+ /** @var bool */
+ private $doMan;
/**
* Prepare Maintenance class
/* Variables for dressing up as a parser */
public $mTitle = 'PreprocessDump';
public $mPPNodeCount = 0;
+ /** @var Preprocessor */
+ public $mPreprocessor;
public function getStripList() {
$parser = MediaWikiServices::getInstance()->getParser();
class PPFuzzTest {
public $templates, $mainText, $title, $entryPoint, $output;
+ /** @var PPFuzzTester */
+ private $parent;
+ /** @var string */
+ public $nickname;
+ /** @var bool */
+ public $fancySig;
+
/**
* @param PPFuzzTester $tester
*/
* @ingroup Maintenance
*/
class ImageBuilder extends Maintenance {
-
/**
* @var IMaintainableDatabase
*/
protected $dbw;
+ /** @var bool */
+ private $dryrun;
+
+ /** @var LocalRepo|null */
+ private $repo;
+
+ /** @var int */
+ private $updated;
+
+ /** @var int */
+ private $processed;
+
+ /** @var int */
+ private $count;
+
+ /** @var int */
+ private $startTime;
+
+ /** @var string */
+ private $table;
+
function __construct() {
parent::__construct();
* @return LocalRepo
*/
function getRepo() {
- if ( !isset( $this->repo ) ) {
+ if ( $this->repo === null ) {
$this->repo = RepoGroup::singleton()->getLocalRepo();
}
* @ingroup Maintenance
*/
class RecountCategories extends Maintenance {
+ /** @var string */
+ private $mode;
+
+ /** @var int */
+ private $minimumId;
+
public function __construct() {
parent::__construct();
$this->addDescription( <<<'TEXT'
private $count = 0;
private $outputDirectory, $startTime;
+ /** @var string */
+ private $prefix;
public function __construct() {
parent::__construct();
/** @var ConcatenatedGzipHistoryBlob|false */
public $cgz;
public $referrers;
+ /** @var array */
+ private $texts;
/**
* Create a transaction from a RecompressTracked object