"PhanUndeclaredConstant",
// approximate error count: 60
"PhanTypeMismatchArgument",
- // approximate error count: 219
- "PhanUndeclaredMethod",
// approximate error count: 752
"PhanUndeclaredProperty",
] );
--- /dev/null
+<?php
+// These stubs were generated by the phan stub generator.
+// @phan-stub-for-extension dom@20031129
+
+namespace {
+class DOMAttr extends \DOMNode {
+
+ // properties
+ public $name;
+ public $ownerElement;
+ public $schemaTypeInfo;
+ public $specified;
+ public $value;
+
+ // methods
+ public function isId() {}
+ public function __construct($name, $value = null) {}
+}
+
+class DOMCdataSection extends \DOMText {
+
+ // methods
+ public function __construct($value) {}
+}
+
+class DOMCharacterData extends \DOMNode {
+
+ // properties
+ public $data;
+ public $length;
+
+ // methods
+ public function substringData($offset, $count) {}
+ public function appendData($arg) {}
+ public function insertData($offset, $arg) {}
+ public function deleteData($offset, $count) {}
+ public function replaceData($offset, $count, $arg) {}
+}
+
+class DOMComment extends \DOMCharacterData {
+
+ // methods
+ public function __construct($value = null) {}
+}
+
+class DOMConfiguration {
+
+ // methods
+ public function setParameter($name, $value) {}
+ public function getParameter($name = null) {}
+ public function canSetParameter($name = null, $value = null) {}
+}
+
+class DOMDocument extends \DOMNode {
+
+ // properties
+ public $actualEncoding;
+ public $config;
+ public $doctype;
+ public $documentElement;
+ public $documentURI;
+ public $encoding;
+ public $formatOutput;
+ public $implementation;
+ public $preserveWhiteSpace;
+ public $recover;
+ public $resolveExternals;
+ public $standalone;
+ public $strictErrorChecking;
+ public $substituteEntities;
+ public $validateOnParse;
+ public $version;
+ public $xmlEncoding;
+ public $xmlStandalone;
+ public $xmlVersion;
+
+ // methods
+ public function createElement($tagName, $value = null) {}
+ public function createDocumentFragment() {}
+ public function createTextNode($data) {}
+ public function createComment($data) {}
+ public function createCDATASection($data) {}
+ public function createProcessingInstruction($target, $data) {}
+ public function createAttribute($name) {}
+ public function createEntityReference($name) {}
+ public function getElementsByTagName($tagName) {}
+ public function importNode(\DOMNode $importedNode, $deep) {}
+ public function createElementNS($namespaceURI, $qualifiedName, $value = null) {}
+ public function createAttributeNS($namespaceURI, $qualifiedName) {}
+ public function getElementsByTagNameNS($namespaceURI, $localName) {}
+ public function getElementById($elementId) {}
+ public function adoptNode(\DOMNode $source) {}
+ public function normalizeDocument() {}
+ public function renameNode(\DOMNode $node, $namespaceURI, $qualifiedName) {}
+ public function load($source, $options = null) {}
+ public function save($file) {}
+ public function loadXML($source, $options = null) {}
+ public function saveXML(\DOMNode $node = null, $options = null) {}
+ public function __construct($version = null, $encoding = null) {}
+ public function validate() {}
+ public function xinclude($options = null) {}
+ public function loadHTML($source, $options = null) {}
+ public function loadHTMLFile($source, $options = null) {}
+ public function saveHTML() {}
+ public function saveHTMLFile($file) {}
+ public function schemaValidate($filename) {}
+ public function schemaValidateSource($source) {}
+ public function relaxNGValidate($filename) {}
+ public function relaxNGValidateSource($source) {}
+ public function registerNodeClass($baseClass, $extendedClass) {}
+}
+
+class DOMDocumentFragment extends \DOMNode {
+
+ // properties
+ public $name;
+
+ // methods
+ public function __construct() {}
+ public function appendXML($data) {}
+}
+
+class DOMDocumentType extends \DOMNode {
+
+ // properties
+ public $entities;
+ public $internalSubset;
+ public $name;
+ public $notations;
+ public $publicId;
+ public $systemId;
+}
+
+class DOMDomError {
+}
+
+class DOMElement extends \DOMNode {
+
+ // properties
+ public $schemaTypeInfo;
+ public $tagName;
+
+ // methods
+ public function getAttribute($name) {}
+ public function setAttribute($name, $value) {}
+ public function removeAttribute($name) {}
+ public function getAttributeNode($name) {}
+ public function setAttributeNode(\DOMAttr $newAttr) {}
+ public function removeAttributeNode(\DOMAttr $oldAttr) {}
+ public function getElementsByTagName($name) {}
+ public function getAttributeNS($namespaceURI, $localName) {}
+ public function setAttributeNS($namespaceURI, $qualifiedName, $value) {}
+ public function removeAttributeNS($namespaceURI, $localName) {}
+ public function getAttributeNodeNS($namespaceURI, $localName) {}
+ public function setAttributeNodeNS(\DOMAttr $newAttr) {}
+ public function getElementsByTagNameNS($namespaceURI, $localName) {}
+ public function hasAttribute($name) {}
+ public function hasAttributeNS($namespaceURI, $localName) {}
+ public function setIdAttribute($name, $isId) {}
+ public function setIdAttributeNS($namespaceURI, $localName, $isId) {}
+ public function setIdAttributeNode(\DOMAttr $attr, $isId) {}
+ public function __construct($name, $value = null, $uri = null) {}
+}
+
+class DOMEntity extends \DOMNode {
+
+ // properties
+ public $actualEncoding;
+ public $encoding;
+ public $notationName;
+ public $publicId;
+ public $systemId;
+ public $version;
+}
+
+class DOMEntityReference extends \DOMNode {
+
+ // properties
+ public $name;
+
+ // methods
+ public function __construct($name) {}
+}
+
+class DOMErrorHandler {
+
+ // methods
+ public function handleError(\DOMDomError $error) {}
+}
+
+final class DOMException extends \Exception {
+
+ // properties
+ public $code;
+ protected $message;
+ protected $file;
+ protected $line;
+}
+
+class DOMImplementation {
+
+ // properties
+ public $name;
+
+ // methods
+ public function getFeature($feature, $version) {}
+ public function hasFeature() {}
+ public function createDocumentType($qualifiedName, $publicId, $systemId) {}
+ public function createDocument($namespaceURI, $qualifiedName, \DOMDocumentType $docType) {}
+}
+
+class DOMImplementationList {
+
+ // methods
+ public function item($index) {}
+}
+
+class DOMImplementationSource {
+
+ // methods
+ public function getDomimplementation($features) {}
+ public function getDomimplementations($features) {}
+}
+
+class DOMLocator {
+}
+
+class DOMNameList {
+
+ // methods
+ public function getName($index) {}
+ public function getNamespaceURI($index) {}
+}
+
+class DOMNameSpaceNode {
+}
+
+class DOMNamedNodeMap implements \Traversable, \Countable {
+
+ // properties
+ public $length;
+
+ // methods
+ public function getNamedItem($name) {}
+ public function setNamedItem(\DOMNode $arg) {}
+ public function removeNamedItem($name = null) {}
+ public function item($index = null) {}
+ public function getNamedItemNS($namespaceURI = null, $localName = null) {}
+ public function setNamedItemNS(\DOMNode $arg = null) {}
+ public function removeNamedItemNS($namespaceURI = null, $localName = null) {}
+ public function count() {}
+}
+
+class DOMNode {
+
+ // properties
+ public $attributes;
+ public $baseURI;
+ public $childNodes;
+ public $firstChild;
+ public $lastChild;
+ public $localName;
+ public $namespaceURI;
+ public $nextSibling;
+ public $nodeName;
+ public $nodeType;
+ public $nodeValue;
+ public $ownerDocument;
+ public $parentNode;
+ public $prefix;
+ public $previousSibling;
+ public $textContent;
+
+ // methods
+ public function insertBefore(\DOMNode $newChild, \DOMNode $refChild = null) {}
+ public function replaceChild(\DOMNode $newChild, \DOMNode $oldChild) {}
+ public function removeChild(\DOMNode $oldChild) {}
+ public function appendChild(\DOMNode $newChild) {}
+ public function hasChildNodes() {}
+ public function cloneNode($deep = null) {}
+ public function normalize() {}
+ public function isSupported($feature, $version) {}
+ public function hasAttributes() {}
+ public function compareDocumentPosition(\DOMNode $other) {}
+ public function isSameNode(\DOMNode $other) {}
+ public function lookupPrefix($namespaceURI) {}
+ public function isDefaultNamespace($namespaceURI) {}
+ public function lookupNamespaceUri($prefix) {}
+ public function isEqualNode(\DOMNode $arg) {}
+ public function getFeature($feature, $version) {}
+ public function setUserData($key, $data, $handler) {}
+ public function getUserData($key) {}
+ public function getNodePath() {}
+ public function getLineNo() {}
+ public function C14N($exclusive = null, $with_comments = null, array $xpath = null, array $ns_prefixes = null) {}
+ public function C14NFile($uri, $exclusive = null, $with_comments = null, array $xpath = null, array $ns_prefixes = null) {}
+}
+
+class DOMNodeList implements \Traversable, \Countable {
+
+ // properties
+ public $length;
+
+ // methods
+ public function item($index) {}
+ public function count() {}
+}
+
+class DOMNotation extends \DOMNode {
+
+ // properties
+ public $publicId;
+ public $systemId;
+}
+
+class DOMProcessingInstruction extends \DOMNode {
+
+ // properties
+ public $data;
+ public $target;
+
+ // methods
+ public function __construct($name, $value = null) {}
+}
+
+class DOMStringExtend {
+
+ // methods
+ public function findOffset16($offset32) {}
+ public function findOffset32($offset16) {}
+}
+
+class DOMStringList {
+
+ // methods
+ public function item($index) {}
+}
+
+class DOMText extends \DOMCharacterData {
+
+ // properties
+ public $wholeText;
+
+ // methods
+ public function splitText($offset) {}
+ public function isWhitespaceInElementContent() {}
+ public function isElementContentWhitespace() {}
+ public function replaceWholeText($content) {}
+ public function __construct($value = null) {}
+}
+
+class DOMTypeinfo {
+}
+
+class DOMUserDataHandler {
+
+ // methods
+ public function handle() {}
+}
+
+class DOMXPath {
+
+ // properties
+ public $document;
+
+ // methods
+ public function __construct(\DOMDocument $doc) {}
+ public function registerNamespace($prefix, $uri) {}
+ public function query($expr, \DOMNode $context = null, $registerNodeNS = null) {}
+ public function evaluate($expr, \DOMNode $context = null, $registerNodeNS = null) {}
+ public function registerPhpFunctions() {}
+}
+
+function dom_import_simplexml($node) {}
+const DOMSTRING_SIZE_ERR = 2;
+const DOM_HIERARCHY_REQUEST_ERR = 3;
+const DOM_INDEX_SIZE_ERR = 1;
+const DOM_INUSE_ATTRIBUTE_ERR = 10;
+const DOM_INVALID_ACCESS_ERR = 15;
+const DOM_INVALID_CHARACTER_ERR = 5;
+const DOM_INVALID_MODIFICATION_ERR = 13;
+const DOM_INVALID_STATE_ERR = 11;
+const DOM_NAMESPACE_ERR = 14;
+const DOM_NOT_FOUND_ERR = 8;
+const DOM_NOT_SUPPORTED_ERR = 9;
+const DOM_NO_DATA_ALLOWED_ERR = 6;
+const DOM_NO_MODIFICATION_ALLOWED_ERR = 7;
+const DOM_PHP_ERR = 0;
+const DOM_SYNTAX_ERR = 12;
+const DOM_VALIDATION_ERR = 16;
+const DOM_WRONG_DOCUMENT_ERR = 4;
+const XML_ATTRIBUTE_CDATA = 1;
+const XML_ATTRIBUTE_DECL_NODE = 16;
+const XML_ATTRIBUTE_ENTITY = 6;
+const XML_ATTRIBUTE_ENUMERATION = 9;
+const XML_ATTRIBUTE_ID = 2;
+const XML_ATTRIBUTE_IDREF = 3;
+const XML_ATTRIBUTE_IDREFS = 4;
+const XML_ATTRIBUTE_NMTOKEN = 7;
+const XML_ATTRIBUTE_NMTOKENS = 8;
+const XML_ATTRIBUTE_NODE = 2;
+const XML_ATTRIBUTE_NOTATION = 10;
+const XML_CDATA_SECTION_NODE = 4;
+const XML_COMMENT_NODE = 8;
+const XML_DOCUMENT_FRAG_NODE = 11;
+const XML_DOCUMENT_NODE = 9;
+const XML_DOCUMENT_TYPE_NODE = 10;
+const XML_DTD_NODE = 14;
+const XML_ELEMENT_DECL_NODE = 15;
+const XML_ELEMENT_NODE = 1;
+const XML_ENTITY_DECL_NODE = 17;
+const XML_ENTITY_NODE = 6;
+const XML_ENTITY_REF_NODE = 5;
+const XML_HTML_DOCUMENT_NODE = 13;
+const XML_LOCAL_NAMESPACE = 18;
+const XML_NAMESPACE_DECL_NODE = 18;
+const XML_NOTATION_NODE = 12;
+const XML_PI_NODE = 7;
+const XML_TEXT_NODE = 3;
+}
*/
public function send( $recipients, array $headers, $body ) {
}
+ /**
+ * @return string
+ */
+ public function getMessage() {
+ }
}
class Mail_smtp extends Mail {
* Really delete the file
*
* @param Title &$title
- * @param File &$file
+ * @param LocalFile &$file
* @param string &$oldimage Archive name
* @param string $reason Reason of the deletion
* @param bool $suppress Whether to mark all deleted versions as restricted
if ( $oldimage ) {
$page = null;
$status = $file->deleteOld( $oldimage, $reason, $suppress, $user );
- if ( $status->ok ) {
+ if ( $status->isOK() ) {
// Need to do a log item
$logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text();
if ( trim( $reason ) != '' ) {
namespace MediaWiki\Navigation;
-use MediaWiki\Linker\LinkTarget;
-use MessageLocalizer;
use Html;
+use MessageLocalizer;
+use Title;
/**
* Helper class for generating prev/next links for paging.
+ * @todo Use LinkTarget instead of Title
*
* @since 1.34
*/
*/
private $messageLocalizer;
+ /**
+ * @param MessageLocalizer $messageLocalizer
+ */
public function __construct( MessageLocalizer $messageLocalizer ) {
$this->messageLocalizer = $messageLocalizer;
}
/**
* Generate (prev x| next x) (20|50|100...) type links for paging
*
- * @param LinkTarget $title LinkTarget object to link
+ * @param Title $title Title object to link
* @param int $offset
* @param int $limit
* @param array $query Optional URL query parameter string
* @param bool $atend Optional param for specified if this is the last page
* @return string
*/
- public function buildPrevNextNavigation( LinkTarget $title, $offset, $limit,
- array $query = [], $atend = false
+ public function buildPrevNextNavigation(
+ Title $title,
+ $offset,
+ $limit,
+ array $query = [],
+ $atend = false
) {
# Make 'previous' link
$prev = $this->messageLocalizer->msg( 'prevn' )->title( $title )
# Make links to set number of items per page
$numLinks = [];
+ // @phan-suppress-next-next-line PhanUndeclaredMethod
+ // @fixme MessageLocalizer doesn't have a getLanguage() method!
$lang = $this->messageLocalizer->getLanguage();
foreach ( [ 20, 50, 100, 250, 500 ] as $num ) {
$numLinks[] = $this->numLink( $title, $offset, $num, $query,
/**
* Helper function for buildPrevNextNavigation() that generates links
*
- * @param LinkTarget $title LinkTarget object to link
+ * @param Title $title Title object to link
* @param int $offset
* @param int $limit
* @param array $query Extra query parameters
* @param string $class Value of the "class" attribute of the link
* @return string HTML fragment
*/
- private function numLink( LinkTarget $title, $offset, $limit, array $query, $link,
+ private function numLink( Title $title, $offset, $limit, array $query, $link,
$tooltipMsg, $class
) {
$query = [ 'limit' => $limit, 'offset' => $offset ] + $query;
* @param Title $t
*/
public function setTitle( Title $t ) {
+ // @phan-suppress-next-next-line PhanUndeclaredMethod
+ // @fixme Not all implementations of IContextSource have this method!
$this->getContext()->setTitle( $t );
}
*
* run() must be declared in the subclass. It cannot be declared as abstract
* here because it has a variable parameter list.
+ * @todo Declare it as abstract after dropping HHVM
*
* @package MediaWiki\Rest
*/
class SimpleHandler extends Handler {
public function execute() {
$params = array_values( $this->getRequest()->getPathParams() );
+ // @phan-suppress-next-line PhanUndeclaredMethod
return $this->run( ...$params );
}
}
*
* @since 1.31
* @since 1.32 Renamed from MediaWiki\Storage\MutableRevisionRecord
+ * @property MutableRevisionSlots $mSlots
*/
class MutableRevisionRecord extends RevisionRecord {
$slots = new MutableRevisionSlots();
parent::__construct( $title, $slots, $dbDomain );
-
- $this->mSlots = $slots; // redundant, but nice for static analysis
}
/**
// TODO: introduce something like an UnsavedRevisionFactory service instead!
/** @var MutableRevisionRecord $rev */
$rev = $this->derivedDataUpdater->getRevision();
+ '@phan-var MutableRevisionRecord $rev';
$rev->setPageId( $title->getArticleID() );
// splitTitleString method, but the only implementation (MediaWikiTitleCodec) does
/** @var MediaWikiTitleCodec $titleCodec */
$titleCodec = MediaWikiServices::getInstance()->getTitleParser();
+ '@phan-var MediaWikiTitleCodec $titleCodec';
// MalformedTitleException can be thrown here
$parts = $titleCodec->splitTitleString( $this->mDbkeyform, $this->mDefaultNamespace );
/**
* The TitleArray class only exists to provide the newFromResult method at pre-
* sent.
+ *
+ * @method int count()
*/
abstract class TitleArray implements Iterator {
/**
$this->useTransactionalTimeLimit();
$old = $this->getRequest()->getText( 'oldimage' );
+ /** @var LocalFile $localFile */
$localFile = $this->page->getFile();
+ '@phan-var LocalFile $localFile';
$oldFile = OldLocalFile::newFromArchiveName( $this->getTitle(), $localFile->getRepo(), $old );
$source = $localFile->getArchiveVirtualUrl( $old );
$pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
$titleObj = $pageObj->getTitle();
if ( !$pageObj->exists() &&
+ // @phan-suppress-next-line PhanUndeclaredMethod
!( $titleObj->getNamespace() == NS_FILE && self::canDeleteFile( $pageObj->getFile() ) )
) {
$this->dieWithError( 'apierror-missingtitle' );
) {
$title = $page->getTitle();
+ // @phan-suppress-next-line PhanUndeclaredMethod There's no right typehint for it
$file = $page->getFile();
if ( !self::canDeleteFile( $file ) ) {
return self::delete( $page, $user, $reason, $tags );
* ApiResult.
* @since 1.25
* @ingroup API
+ * @phan-file-suppress PhanUndeclaredMethod Undeclared methods in IApiMessage
*/
class ApiErrorFormatter {
/** @var Title Dummy title to silence warnings from MessageCache::parse() */
$parser->startExternalParse( $titleObj, $options, Parser::OT_PREPROCESS );
$dom = $parser->preprocessToDom( $params['text'] );
if ( is_callable( [ $dom, 'saveXML' ] ) ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->saveXML();
} else {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->__toString();
}
if ( isset( $prop['parsetree'] ) ) {
if ( $e instanceof ApiUsageException ) {
foreach ( $e->getStatusValue()->getErrors() as $error ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$msg = ApiMessage::create( $error )
->inLanguage( $this->getLanguage() );
$errorTitle = $this->msg( 'api-feed-error-title', $msg->getApiCode() );
$tmpFile = MediaWikiServices::getInstance()->getTempFSFileFactory()
->newTempFSFile( 'rotate_', $ext );
$dstPath = $tmpFile->getPath();
+ // @phan-suppress-next-line PhanUndeclaredMethod
$err = $handler->rotate( $file, [
'srcPath' => $srcPath,
'dstPath' => $dstPath,
$comment = wfMessage(
'rotate-comment'
)->numParams( $rotation )->inContentLanguage()->text();
+ // @phan-suppress-next-line PhanUndeclaredMethod
$status = $file->upload(
$dstPath,
$comment,
* @param IContextSource|WebRequest|null $context If this is an instance of
* FauxRequest, errors are thrown and no printing occurs
* @param bool $enableWrite Should be set to true if the api may modify data
+ * @suppress PhanUndeclaredMethod
*/
public function __construct( $context = null, $enableWrite = false ) {
if ( $context === null ) {
* @since 1.27
* @ingroup API
* @phan-file-suppress PhanTraitParentReference
+ * @phan-file-suppress PhanUndeclaredMethod
*/
trait ApiMessageTrait {
case 'xml':
$printer = $this->getMain()->createPrinterByName( 'xml' . $this->fm );
+ '@phan-var ApiFormatXML $printer';
$printer->setRootElement( 'SearchSuggestion' );
return $printer;
* @param string $search the search query
* @param array $params api request params
* @return array search results. Keys are integers.
- * @phan-return array<array{title:Title,extract:false,image:false,url:string}>
+ * @phan-return array<array{title:Title,redirect_from:?Title,extract:false,extract_trimmed:false,image:false,url:string}>
* Note that phan annotations don't support keys containing a space.
*/
private function search( $search, array $params ) {
$parser = MediaWikiServices::getInstance()->getParser();
$parser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $parser->preprocessToDom( $this->content->getText() )->__toString();
$result_array['parsetree'] = $xml;
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
// Filter modules based on continue parameter
$continuationManager = new ApiContinuationManager( $this, $allModules, $propModules );
$this->setContinuationManager( $continuationManager );
+ /** @var ApiQueryBase[] $modules */
$modules = $continuationManager->getRunModules();
+ '@phan-var ApiQueryBase[] $modules';
if ( !$continuationManager->isGeneratorDone() ) {
// Query modules may optimize data requests through the $this->getPageSet()
$cacheMode = $this->mPageSet->getCacheMode();
// Execute all unfinished modules
- /** @var ApiQueryBase $module */
foreach ( $modules as $module ) {
$params = $module->extractRequestParams();
$cacheMode = $this->mergeCacheMode(
$id = $restriction->getBlockId();
switch ( $restriction->getType() ) {
case 'page':
+ /** @var \MediaWiki\Block\Restriction\PageRestriction $restriction */
+ '@phan-var \MediaWiki\Block\Restriction\PageRestriction $restriction';
$value = [ 'id' => $restriction->getValue() ];
if ( $restriction->getTitle() ) {
self::addTitleInfo( $value, $restriction->getTitle() );
$vals['thumbmime'] = $mime;
}
} elseif ( $mto && $mto->isError() ) {
+ /** @var MediaTransformError $mto */
+ '@phan-var MediaTransformError $mto';
$vals['thumberror'] = $mto->toText();
}
}
// Thus there should be no issue with format=xml.
$format = new FormatMetadata;
$format->setSingleLanguage( !$opts['multilang'] );
+ // @phan-suppress-next-line PhanUndeclaredMethod
$format->getContext()->setLanguage( $opts['language'] );
$extmetaArray = $format->fetchExtendedMetadata( $file );
if ( $opts['extmetadatafilter'] ) {
}
if ( $archive && $file->isOld() ) {
+ /** @var OldLocalFile $file */
+ '@phan-var OldLocalFile $file';
$vals['archivename'] = $file->getArchiveName();
}
if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
+ /** @var WikitextContent $content */
+ '@phan-var WikitextContent $content';
$t = $content->getText(); # note: don't set $text
$parser = MediaWikiServices::getInstance()->getParser();
);
$dom = $parser->preprocessToDom( $t );
if ( is_callable( [ $dom, 'saveXML' ] ) ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->saveXML();
} else {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->__toString();
}
$vals['parsetree'] = $xml;
if ( $this->expandTemplates && !$this->parseContent ) {
if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
+ /** @var WikitextContent $content */
+ '@phan-var WikitextContent $content';
$text = $content->getText();
$text = MediaWikiServices::getInstance()->getParser()->preprocess(
public function __construct() {
/** @var SessionProvider $provider */
$provider = SessionManager::getGlobalSession()->getProvider();
+ '@phan-var SessionProvider $provider';
$this->expiration = $provider->getRememberUserDuration();
}
if ( $block instanceof SystemBlock ) {
$systemBlocks[] = $block;
} elseif ( $block->getType() === DatabaseBlock::TYPE_AUTO ) {
+ /** @var DatabaseBlock $block */
+ '@phan-var DatabaseBlock $block';
if ( !isset( $databaseBlocks[$block->getParentBlockId()] ) ) {
$databaseBlocks[$block->getParentBlockId()] = $block;
}
* @inheritDoc
*/
public static function newFromRow( \stdClass $row ) {
+ /** @var self $restriction */
$restriction = parent::newFromRow( $row );
+ '@phan-var self $restriction';
// If the page_namespace and the page_title were provided, add the title to
// the restriction.
*
* @since 1.33
* @param \stdClass $row
- * @return self
+ * @return static
*/
public static function newFromRow( \stdClass $row );
* but 'Bot' is unchecked, hidebots=1 will be sent.
*
* @since 1.29
+ * @method ChangesListBooleanFilter[] getFilters()
*/
class ChangesListBooleanFilterGroup extends ChangesListFilterGroup {
/**
* Registers a filter in this group
*
* @param ChangesListBooleanFilter $filter
+ * @suppress PhanParamSignaturePHPDocMismatchHasParamType,PhanParamSignatureMismatch
*/
public function registerFilter( ChangesListBooleanFilter $filter ) {
$this->filters[$filter->getName()] = $filter;
* Represents a filter group (used on ChangesListSpecialPage and descendants)
*
* @since 1.29
+ * @method registerFilter($filter)
*/
abstract class ChangesListFilterGroup {
/**
* Registers a filter in this group
*
* @param ChangesListStringOptionsFilter $filter
+ * @suppress PhanParamSignaturePHPDocMismatchHasParamType,PhanParamSignatureMismatch
*/
public function registerFilter( ChangesListStringOptionsFilter $filter ) {
$this->filters[$filter->getName()] = $filter;
/**
* Generic list for change tagging.
+ *
+ * @property ChangeTagsLogItem $current
+ * @method ChangeTagsLogItem next()
+ * @method ChangeTagsLogItem reset()
+ * @method ChangeTagsLogItem current()
+ * @phan-file-suppress PhanParamSignatureMismatch
*/
abstract class ChangeTagsList extends RevisionListBase {
function __construct( IContextSource $context, Title $title, array $ids ) {
* @return string|bool The raw text, or false if the conversion failed.
*/
public function getWikitextForTransclusion() {
+ /** @var WikitextContent $wikitext */
$wikitext = $this->convert( CONTENT_MODEL_WIKITEXT, 'lossy' );
+ '@phan-var WikitextContent $wikitext';
if ( $wikitext ) {
return $wikitext->getText();
*/
public function diff( Content $that, Language $lang = null ) {
$this->checkModelID( $that->getModel() );
-
+ /** @var self $that */
+ '@phan-var self $that';
// @todo could implement this in DifferenceEngine and just delegate here?
if ( !$lang ) {
public function serializeContent( Content $content, $format = null ) {
$this->checkFormat( $format );
+ // @phan-suppress-next-line PhanUndeclaredMethod
return $content->getText();
}
*/
public function serializeContent( Content $content, $format = null ) {
/** @var UnknownContent $content */
+ '@phan-var UnknownContent $content';
return $content->getData();
}
"document uses $myModelId but " .
"section uses $sectionModelId." );
}
+ /** @var self $with $oldtext */
+ '@phan-var self $with';
$oldtext = $this->getText();
$text = $with->getText();
if ( isset( $queue[$class] ) ) {
/** @var MergeableUpdate $existingUpdate */
$existingUpdate = $queue[$class];
+ '@phan-var MergeableUpdate $existingUpdate';
$existingUpdate->merge( $update );
// Move the update to the end to handle things like mergeable purge
// updates that might depend on the prior updates in the queue running
/** @var TextSlotDiffRenderer $slotDiffRenderer */
$slotDiffRenderer = ContentHandler::getForModelID( CONTENT_MODEL_TEXT )
->getSlotDiffRenderer( RequestContext::getMain() );
+ '@phan-var TextSlotDiffRenderer $slotDiffRenderer';
return $slotDiffRenderer->getTextDiff( $oldText, $newText );
}
use MediaWiki\MediaWikiServices as MediaWikiServicesAlias;
use MediaWiki\Storage\RevisionRecord;
use Wikimedia\Rdbms\IResultWrapper;
-use Wikimedia\Rdbms\IDatabase;
/**
* @ingroup SpecialPage Dump
/** @var XmlDumpWriter */
private $writer;
- /** @var IDatabase */
+ /** @var Database */
protected $db;
/** @var array|int */
}
/**
- * @param IDatabase $db
+ * @param Database $db
* @param int|array $history One of WikiExporter::FULL, WikiExporter::CURRENT,
* WikiExporter::RANGE or WikiExporter::STABLE, or an associative array:
* - offset: non-inclusive offset at which to start the query
*/
function writeUpload( $file, $dumpContents = false ) {
if ( $file->isOld() ) {
+ /** @var OldLocalFile $file */
+ '@phan-var OldLocalFile $file';
$archiveName = " " .
Xml::element( 'archivename', null, $file->getArchiveName() ) . "\n";
} else {
$thumb = false;
} elseif ( $thumb->isError() ) { // transform error
/** @var MediaTransformError $thumb */
+ '@phan-var MediaTransformError $thumb';
$this->lastError = $thumb->toText();
// Ignore errors if requested
if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
: FSFile::getSha1Base36FromPath( $srcPath );
/** @var FileBackendDBRepoWrapper $wrapperBackend */
$wrapperBackend = $repo->getBackend();
+ '@phan-var FileBackendDBRepoWrapper $wrapperBackend';
$dst = $wrapperBackend->getPathForSHA1( $sha1 );
$status = $repo->quickImport( $src, $dst );
if ( $flags & File::DELETE_SOURCE ) {
$oldTitleFile->purgeEverything();
foreach ( $archiveNames as $archiveName ) {
/** @var OldLocalFile $oldTitleFile */
+ '@phan-var OldLocalFile $oldTitleFile';
$oldTitleFile->purgeOldThumbnails( $archiveName );
}
$newTitleFile->purgeEverything();
public function execute() {
$repo = $this->file->repo;
$status = $repo->newGood();
+ /** @var LocalFile $destFile */
$destFile = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
->newFile( $this->target );
+ '@phan-var LocalFile $destFile';
$this->file->lock();
$destFile->lock(); // quickly fail if destination is not available
* (defined in htmlform.Element.js) picks up the extra config when constructed using OO.ui.infuse().
*
* Currently only supports passing 'hide-if' data.
+ * @phan-file-suppress PhanUndeclaredMethod
*/
trait HTMLFormElement {
/**
* Take care of whatever is necessary to perform the URI request.
*
- * @return StatusValue
+ * @return Status
* @note currently returns Status for B/C
*/
public function execute() {
$user
);
} else {
+ '@phan-var LocalFile $file';
$flags = 0;
$status = $file->upload(
$source,
* This will return a cached connection if one is available.
*
* @return Status
+ * @suppress PhanUndeclaredMethod
*/
public function getConnection() {
if ( $this->db ) {
public function setupSchemaVars() {
$status = $this->getConnection();
if ( $status->isOK() ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$status->value->setSchemaVars( $this->getSchemaVars() );
} else {
$msg = __METHOD__ . ': unexpected error while establishing'
$cl = $this->maintenance->runChild(
RebuildLocalisationCache::class, 'rebuildLocalisationCache.php'
);
+ '@phan-var RebuildLocalisationCache $cl';
$this->output( "Rebuilding localisation cache...\n" );
$cl->setForce();
$cl->execute();
$task = $this->maintenance->runChild(
MigrateImageCommentTemp::class, 'migrateImageCommentTemp.php'
);
+ // @phan-suppress-next-line PhanUndeclaredMethod
$task->setForce();
$ok = $task->execute();
$this->output( $ok ? "done.\n" : "errors were encountered.\n" );
if ( $this->db->fieldExists( 'archive', 'ar_text', __METHOD__ ) ) {
$this->output( "Migrating archive ar_text to modern storage.\n" );
$task = $this->maintenance->runChild( MigrateArchiveText::class, 'migrateArchiveText.php' );
+ // @phan-suppress-next-line PhanUndeclaredMethod
$task->setForce();
if ( $task->execute() ) {
$this->applyPatch( 'patch-drop-ar_text.sql', false,
if ( !$status->isOK() ) {
return $status;
}
+ // @phan-suppress-next-line PhanUndeclaredMethod
$status->value->insert(
'site_stats',
[
* @var Database $conn
*/
$conn = $status->value;
+ '@phan-var Database $conn';
// Check version
return static::meetsMinimumRequirement( $conn->getServerVersion() );
*
* @ingroup Deployment
* @since 1.17
+ * @property DatabaseMysqlBase $db
*/
class MysqlUpdater extends DatabaseUpdater {
protected function getCoreUpdateList() {
if ( !$status->isOK() ) {
return $status;
}
+ // @phan-suppress-next-line PhanUndeclaredMethod
$exists = $status->value->roleExists( $this->getVar( 'wgDBuser' ) );
}
}
/** @var DatabasePostgres $conn */
$conn = $status->value;
+ '@phan-var DatabasePostgres $conn';
// Create the schema if necessary
$schema = $this->getVar( 'wgDBmwschema' );
if ( !$status->isOK() ) {
return $status;
}
+ /** @var DatabasePostgres $conn */
$conn = $status->value;
+ '@phan-var DatabasePostgres $conn';
$safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) );
$safepass = $conn->addQuotes( $this->getVar( 'wgDBpassword' ) );
/** @var DatabasePostgres $conn */
$conn = $status->value;
+ '@phan-var DatabasePostgres $conn';
if ( $conn->tableExists( 'archive' ) ) {
$status->warning( 'config-install-tables-exist' );
# Special case for Creative Commons partner chooser box.
if ( $this->request->getVal( 'SubmitCC' ) ) {
+ /** @var WebInstallerOptions $page */
$page = $this->getPageByName( 'Options' );
+ '@phan-var WebInstallerOptions $page';
$this->output->useShortHeader();
$this->output->allowFrames();
$page->submitCC();
}
if ( $this->request->getVal( 'ShowCC' ) ) {
+ /** @var WebInstallerOptions $page */
$page = $this->getPageByName( 'Options' );
+ '@phan-var WebInstallerOptions $page';
$this->output->useShortHeader();
$this->output->allowFrames();
$this->output->addHTML( $page->getCCDoneBox() );
foreach ( $moduleNames as $moduleName ) {
/** @var ResourceLoaderFileModule $module */
$module = $resourceLoader->getModule( $moduleName );
+ '@phan-var ResourceLoaderFileModule $module';
if ( !$module ) {
// T98043: Don't fatal, but it won't look as pretty.
continue;
$lang = $this->getLanguage();
$pm = MediaWikiServices::getInstance()->getPermissionManager();
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
+ // @phan-suppress-next-line PhanUndeclaredMethod
$img = $iscur ? $file->getName() : $file->getArchiveName();
$userId = $file->getUser( 'id' );
$userText = $file->getUser( 'text' );
* @ingroup Media
*
* @property WikiFilePage $mPage Set by overwritten newPage() in this class
+ * @method WikiFilePage getPage()
*/
class ImagePage extends Article {
/** @var File|false */
/**
* Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
+ *
+ * @method array getActionOverrides()
+ * @method string getUserText($audience=1,User $user=null)
+ * @method string getTimestamp()
+ * @method Title getTitle()
*/
interface Page {
}
/**
* @ingroup Parser
+ * @property string[] $out
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPDPart_Hash extends PPDPart {
* @ingroup Parser
*/
class PPDStack {
- public $stack, $rootAccum;
+ /** @var PPDStackElement[] */
+ public $stack;
+ public $rootAccum;
/**
- * @var PPDStack|false
+ * @var PPDStackElement|false
*/
public $top;
public $out;
/**
* @ingroup Parser
+ * @property PPDPart_Hash[] $parts
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPDStackElement_Hash extends PPDStackElement {
*/
public function breakSyntax( $openingCount = false ) {
if ( $this->open == "\n" ) {
- // @phan-suppress-next-line PhanTypeMismatchArgumentInternal
$accum = array_merge( [ $this->savedPrefix ], $this->parts[0]->out );
} else {
if ( $openingCount === false ) {
} else {
$accum[++$lastIndex] = '|';
}
- // @phan-suppress-next-line PhanTypeMismatchForeach
+
foreach ( $part->out as $node ) {
if ( is_string( $node ) && is_string( $accum[$lastIndex] ) ) {
$accum[$lastIndex] .= $node;
* An expansion frame, used as a context to expand the result of preprocessToObj()
* @deprecated since 1.34, use PPFrame_Hash
* @ingroup Parser
+ * @phan-file-suppress PhanUndeclaredMethod
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPFrame_DOM implements PPFrame {
/**
* @deprecated since 1.34, use PPNode_Hash_{Tree,Text,Array,Attr}
* @ingroup Parser
+ * @phan-file-suppress PhanUndeclaredMethod
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class PPNode_DOM implements PPNode {
*/
private static function normalizeSectionName( $text ) {
# T90902: ensure the same normalization is applied for IDs as to links
+ /** @var MediaWikiTitleCodec $titleParser */
$titleParser = MediaWikiServices::getInstance()->getTitleParser();
+ '@phan-var MediaWikiTitleCodec $titleParser';
try {
$parts = $titleParser->splitTitleString( "#$text" );
}
$i += $count;
} elseif ( $found == 'close' ) {
+ /** @var PPDStackElement_Hash $piece */
$piece = $stack->top;
+ '@phan-var PPDStackElement_Hash $piece';
# lets check if there are enough characters for closing brace
$maxCount = $piece->count;
if ( $piece->close === '}-' && $curChar === '}' ) {
// Construct pseudo-hash based on params and arguments
/** @var ParameterizedPassword $passObj */
$passObj = $this->factory->newFromType( $type );
+ '@phan-var ParameterizedPassword $passObj';
$params = '';
$args = '';
// Hash the last hash with the next type in the layer
$passObj = $this->factory->newFromCiphertext( $existingHash );
+ '@phan-var ParameterizedPassword $passObj';
$passObj->crypt( $lastHash );
// Move over the params and args
// Construct pseudo-hash based on params and arguments
/** @var ParameterizedPassword $passObj */
$passObj = $this->factory->newFromType( $type );
+ '@phan-var ParameterizedPassword $passObj';
$params = '';
$args = '';
// Hash the last hash with the next type in the layer
$passObj = $this->factory->newFromCiphertext( $existingHash );
+ '@phan-var ParameterizedPassword $passObj';
$passObj->crypt( $lastHash );
// Move over the params and args
if ( !$status->isOK() ) {
return $status;
}
+ /** @var RedisConnRef $conn */
$conn = $status->value;
+ '@phan-var RedisConnRef $conn';
// phpcs:disable Generic.Files.LineLength
static $script =
if ( !$status->isOK() ) {
return $status;
}
+ /** @var RedisConnRef $conn */
$conn = $status->value;
+ '@phan-var RedisConnRef $conn';
$now = microtime( true );
try {
* Save the form data and reload the page
*
* @param array $formData
- * @param HTMLForm $form
+ * @param PreferencesFormOOUI $form
* @param array $formDescriptor
* @return Status
*/
- protected function submitForm( array $formData, HTMLForm $form, array $formDescriptor ) {
+ protected function submitForm(
+ array $formData,
+ PreferencesFormOOUI $form,
+ array $formDescriptor
+ ) {
$res = $this->saveFormData( $formData, $form, $formDescriptor );
if ( $res === true ) {
* @ingroup Profiler
*
* @since 1.25
+ * @property ProfilerXhprof $collector
*/
class ProfilerOutputDump extends ProfilerOutput {
/**
* Item class for a filearchive table row
+ *
+ * @property ArchivedFile $file
+ * @property RevDelArchivedFileList $list
*/
class RevDelArchivedFileItem extends RevDelFileItem {
- /** @var RevDelArchivedFileList $list */
- /** @var ArchivedFile $file */
/** @var LocalFile */
protected $lockFile;
}
public function doPostCommitUpdates( array $visibilityChangeMap ) {
+ /** @var LocalFile $file */
$file = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()
->newFile( $this->title );
+ '@phan-var LocalFile $file';
$file->purgeCache();
$file->purgeDescription();
* needs to be able to make a query from a set of identifiers to pull
* relevant rows, to return RevDelItem subclasses wrapping them, and
* to wrap bulk update operations.
+ *
+ * @property RevDelItem $current
+ * @method RevDelItem next()
+ * @method RevDelItem reset()
+ * @method RevDelItem current()
+ * @phan-file-suppress PhanParamSignatureMismatch
*/
abstract class RevDelList extends RevisionListBase {
function __construct( IContextSource $context, Title $title, array $ids ) {
/**
* Item class for a live revision table row
+ *
+ * @property RevDelRevisionList $list
*/
class RevDelRevisionItem extends RevDelItem {
/** @var Revision */
* This trait can be used directly by extensions providing a SearchEngine.
*
* @ingroup Search
+ * @phan-file-suppress PhanUndeclaredMethod
*/
trait SearchResultSetTrait {
/**
/** @var array Track original session fields for later modification check */
protected $sessionFieldCache = [];
- protected function __construct( SessionManagerInterface $manager ) {
+ protected function __construct( SessionManager $manager ) {
$this->setEnableFlags(
\RequestContext::getMain()->getConfig()->get( 'PHPSessionHandling' )
);
/**
* Install a session handler for the current web request
- * @param SessionManagerInterface $manager
+ * @param SessionManager $manager
*/
- public static function install( SessionManagerInterface $manager ) {
+ public static function install( SessionManager $manager ) {
if ( self::$instance ) {
$manager->setupPHPSessionHandler( self::$instance );
return;
$this->idIsSafe = $data['idIsSafe'];
$this->forceUse = $data['forceUse'] && $this->provider;
} else {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$this->id = $this->provider->getManager()->generateSessionId();
$this->idIsSafe = true;
$this->forceUse = false;
/**
* Get the global SessionManager
- * @return SessionManagerInterface
- * (really a SessionManager, but this is to make IDEs less confused)
+ * @return self
*/
public static function singleton() {
if ( self::$instance === null ) {
/** @var CreditsAction $action */
$action = Action::factory(
'credits', $this->getWikiPage(), $this->getContext() );
+ '@phan-var CreditsAction $action';
$tpl->set( 'credits',
$action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
} else {
$isLoggedIn = $this->getUser()->isLoggedIn();
$continuePart = $this->isContinued() ? 'continue-' : '';
$anotherPart = $isLoggedIn ? 'another-' : '';
+ // @phan-suppress-next-line PhanUndeclaredMethod
$expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
$expirationDays = ceil( $expiration / ( 3600 * 24 ) );
$secureLoginLink = '';
return $title;
}
+ // @phan-suppress-next-line PhanUndeclaredMethod
$context->setTitle( $page->getPageTitle( $par ) );
} elseif ( !$page->isIncludable() ) {
return false;
foreach ( $block->getRestrictions() as $restriction ) {
switch ( $restriction->getType() ) {
case PageRestriction::TYPE:
+ /** @var PageRestriction $restriction */
+ '@phan-var PageRestriction $restriction';
if ( $restriction->getTitle() ) {
$pageRestrictions[] = $restriction->getTitle()->getPrefixedText();
}
$dom = $parser->preprocessToDom( $input );
if ( method_exists( $dom, 'saveXML' ) ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->saveXML();
} else {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$xml = $dom->__toString();
}
}
$user = $this->getUser();
$significance = $this->getFilterGroup( 'significance' );
+ /** @var ChangesListBooleanFilter $hideMinor */
$hideMinor = $significance->getFilter( 'hideminor' );
+ '@phan-var ChangesListBooleanFilter $hideMinor';
$hideMinor->setDefault( $user->getBoolOption( 'hideminor' ) );
$automated = $this->getFilterGroup( 'automated' );
+ /** @var ChangesListBooleanFilter $hideBots */
$hideBots = $automated->getFilter( 'hidebots' );
+ '@phan-var ChangesListBooleanFilter $hideBots';
$hideBots->setDefault( true );
+ /** @var ChangesListStringOptionsFilterGroup|null $reviewStatus */
$reviewStatus = $this->getFilterGroup( 'reviewStatus' );
+ '@phan-var ChangesListStringOptionsFilterGroup|null $reviewStatus';
if ( $reviewStatus !== null ) {
// Conditional on feature being available and rights
if ( $user->getBoolOption( 'hidepatrolled' ) ) {
$reviewStatus->setDefault( 'unpatrolled' );
$legacyReviewStatus = $this->getFilterGroup( 'legacyReviewStatus' );
+ /** @var ChangesListBooleanFilter $legacyHidePatrolled */
$legacyHidePatrolled = $legacyReviewStatus->getFilter( 'hidepatrolled' );
+ '@phan-var ChangesListBooleanFilter $legacyHidePatrolled';
$legacyHidePatrolled->setDefault( true );
}
}
$changeType = $this->getFilterGroup( 'changeType' );
+ /** @var ChangesListBooleanFilter $hideCategorization */
$hideCategorization = $changeType->getFilter( 'hidecategorization' );
+ '@phan-var ChangesListBooleanFilter $hideCategorization';
if ( $hideCategorization !== null ) {
// Conditional on feature being available
$hideCategorization->setDefault( $user->getBoolOption( 'hidecategorization' ) );
$buttonFields = [];
if ( $isText ) {
+ '@phan-var TextContent $content';
// TODO: MCR: make this work for multiple slots
// source view for textual content
$sourceView = Xml::element( 'textarea', [
*
* @param string|null $par String if any subpage provided, else null
* @throws UserBlockedError|PermissionsError
+ * @suppress PhanUndeclaredMethod
*/
public function execute( $par ) {
$user = $this->getUser();
$this->getOutput()->addWikiTextAsInterface( $status->getWikiText() );
return;
- } else {
- $user = $status->value;
}
+ /** @var User $user */
+ $user = $status->value;
+ '@phan-var User $user';
+
$groups = $user->getGroups();
$groupMemberships = $user->getGroupMemberships();
$this->showEditUserGroupsForm( $user, $groups, $groupMemberships );
/**
* @inheritDoc
+ * @suppress PhanUndeclaredMethod
*/
protected function registerFilters() {
parent::registerFilters();
switch ( $restriction->getType() ) {
case PageRestriction::TYPE:
+ '@phan-var PageRestriction $restriction';
if ( $restriction->getTitle() ) {
$items[$restriction->getType()][] = Html::rawElement(
'li',
$throttle->clear( $user->getName(), $request->getIP() );
}
return self::loginHook( $user, $bp,
+ // @phan-suppress-next-line PhanUndeclaredMethod
Status::newGood( $provider->newSessionForRequest( $user, $bp, $request ) ) );
}
* @return string|string[] An error or list of errors in the
* provided $datum. When no errors exist the empty array is
* returned.
+ * @suppress PhanUndeclaredMethod
*/
public static function getErrors( AvroSchema $schema, $datum ) {
switch ( $schema->type ) {
const SUPPORTED = 'mwfile';
/**
- * @var LanguageConverter
+ * @var LanguageConverter|FakeConverter
*/
public $mConverter;
}
function __construct() {
- // @phan-suppress-next-line PhanTypeMismatchProperty
$this->mConverter = new FakeConverter( $this );
// Set the code to the name of the descendant
if ( static::class === 'Language' ) {
$revision = Revision::newFromTitle( $title );
if ( $revision ) {
if ( $revision->getContentModel() == CONTENT_MODEL_WIKITEXT ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$txt = $revision->getContent( RevisionRecord::RAW )->getText();
}
$res = $dbw->select( 'content', 'content_address', [], __METHOD__, [ 'DISTINCT' ] );
$blobStore = MediaWikiServices::getInstance()->getBlobStore();
foreach ( $res as $row ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$textId = $blobStore->getTextIdFromAddress( $row->content_address );
if ( $textId ) {
$cur[] = $textId;
*/
public function execute() {
$siteStore = MediaWikiServices::getInstance()->getSiteStore();
- $siteStore->reset();
+ if ( method_exists( $siteStore, 'reset' ) ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
+ $siteStore->reset();
+ }
$globalId = $this->getArg( 0 );
$group = $this->getArg( 1 );
$siteStore->saveSites( [ $site ] );
if ( method_exists( $siteStore, 'reset' ) ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$siteStore->reset();
}
require __DIR__ . '/../commandLine.inc';
-use Wikimedia\Rdbms\IMaintainableDatabase;
-
/**
* Maintenance script that upgrade for log_id/log_deleted fields in a
* replication-safe way.
class UpdateLogging {
/**
- * @var IMaintainableDatabase
+ * @var Database
*/
public $dbw;
public $batchSize = 1000;
public $minTs = false;
function execute() {
- $this->dbw = $this->getDB( DB_MASTER );
+ $this->dbw = wfGetDB( DB_MASTER );
$logging = $this->dbw->tableName( 'logging' );
$logging_1_10 = $this->dbw->tableName( 'logging_1_10' );
$logging_pre_1_10 = $this->dbw->tableName( 'logging_pre_1_10' );
"$IP/tests/phpunit/phpunit.php",
"$IP/tests/phpunit/suites/LessTestSuite.php"
];
+ // @phan-suppress-next-line PhanUndeclaredMethod
$textUICommand->run( $argv );
}
}
protected function doOperations( FileRepo $tempRepo, array $ops ) {
$status = $tempRepo->getBackend()->doQuickOperations( $ops );
if ( !$status->isOK() ) {
+ // @phan-suppress-next-line PhanUndeclaredMethod
$this->error( print_r( $status->getErrorsArray(), true ) );
}
}
return;
}
+ /** @var WikitextContent $content */
+ '@phan-var WikitextContent $content';
$text = strval( $content->getText() );
$output1 = $parser1->parse( $text, $title, $this->options );
}
$res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" );
+ // @phan-suppress-next-line PhanUndeclaredMethod
if ( $dbw->fieldType( $res, 0 ) == "int" ) {
$this->output( "Schema already converted\n" );
/** @var LocalFile $file */
$file = $repo->newFile( $row->fa_name );
+ '@phan-var LocalFile $file';
try {
$file->lock();
} catch ( LocalFileLockError $e ) {
$this->output( "Deleted version '$key' ($ts) of file '$name'\n" );
} else {
$this->output( "Failed to delete version '$key' ($ts) of file '$name'\n" );
+ // @phan-suppress-next-line PhanUndeclaredMethod
$this->output( print_r( $status->getErrorsArray(), true ) );
}
} else {
}
$this->uploadCount++;
// $this->report();
+ // @phan-suppress-next-line PhanUndeclaredMethod
$this->progress( "upload: " . $revision->getFilename() );
if ( !$this->dryRun ) {
if ( $this->hasOption( 'dry' ) ) {
$this->output( "done.\n" );
+ // @phan-suppress-next-line PhanUndeclaredMethod
} elseif ( $image->recordUpload2(
$archive->value,
$summary,
$dbw->query( "DELETE FROM $tbl_pag WHERE page_id = $id" );
$this->commitTransaction( $dbw, __METHOD__ );
// Delete revisions as appropriate
+ /** @var NukePage $child */
$child = $this->runChild( NukePage::class, 'nukePage.php' );
+ '@phan-var NukePage $child';
$child->deleteRevisions( $revs );
$this->purgeRedundantText( true );
$n_deleted++;
}
// Upgrade the old file versions...
foreach ( $file->getHistory() as $oldFile ) {
+ /** @var OldLocalFile $oldFile */
+ '@phan-var OldLocalFile $oldFile';
$sha1 = $oldFile->getRepo()->getFileSha1( $oldFile->getPath() );
if ( strval( $sha1 ) !== '' ) { // file on disk and hashed properly
if ( $isRegen && $oldFile->getSha1() !== $sha1 ) {
if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
return;
}
+ /** @var WikitextContent $content */
+ '@phan-var WikitextContent $content';
try {
$this->mPreprocessor->preprocessToObj( strval( $content->getText() ), 0 );
$passed = 'passed';
} catch ( Exception $e ) {
$testReport = self::$currentTest->getReport();
- $exceptionReport = $e->getText();
+ $exceptionReport = $e instanceof MWException ? $e->getText() : (string)$e;
$hash = md5( $testReport );
file_put_contents( "results/ppft-$hash.in", serialize( self::$currentTest ) );
file_put_contents( "results/ppft-$hash.fail",
}
/**
- * @return FileRepo
+ * @return LocalRepo
*/
function getRepo() {
if ( !isset( $this->repo ) ) {
$filename = $altname;
$this->output( "Estimating transcoding... $altname\n" );
} else {
- # @todo FIXME: create renameFile()
+ // @fixme create renameFile()
+ // @phan-suppress-next-line PhanUndeclaredMethod See comment above...
$filename = $this->renameFile( $filename );
}
}
[],
[ 'content' => [ 'INNER JOIN', [ 'content_id = slot_content_id' ] ] ]
);
+ /** @var \MediaWiki\Storage\SqlBlobStore $blobStore */
$blobStore = MediaWikiServices::getInstance()->getBlobStore();
+ '@phan-var \MediaWiki\Storage\SqlBlobStore $blobStore';
foreach ( $res as $row ) {
$textId = $blobStore->getTextIdFromAddress( $row->content_address );
if ( $textId ) {
require_once __DIR__ . '/Maintenance.php';
-use Wikimedia\Rdbms\IMaintainableDatabase;
use Wikimedia\Rdbms\DatabaseSqlite;
/**
$dbDomain = WikiMap::getCurrentWikiDbDomain()->getId();
$this->output( "Going to run database updates for $dbDomain\n" );
if ( $db->getType() === 'sqlite' ) {
- /** @var IMaintainableDatabase|DatabaseSqlite $db */
+ /** @var DatabaseSqlite $db */
+ '@phan-var DatabaseSqlite $db';
$this->output( "Using SQLite file: '{$db->getDbFilePath()}'\n" );
}
$this->output( "Depending on the size of your database this may take a while!\n" );
while ( $json['manifest_version'] !== ExtensionRegistry::MANIFEST_VERSION ) {
$json['manifest_version'] += 1;
$func = "updateTo{$json['manifest_version']}";
+ // @phan-suppress-next-line PhanUndeclaredMethod
$this->$func( $json );
}
*/
class UserDupes {
/**
- * @var IMaintainableDatabase
+ * @var Database
*/
private $db;
private $reassigned;
$user = User::newFromId( $row->user_id );
/** @var ParameterizedPassword $password */
$password = $passwordFactory->newFromCiphertext( $row->user_password );
+ '@phan-var ParameterizedPassword $password';
/** @var LayeredParameterizedPassword $layeredPassword */
$layeredPassword = $passwordFactory->newFromType( $layeredType );
+ '@phan-var LayeredParameterizedPassword $layeredPassword';
$layeredPassword->partialCrypt( $password );
$updateUsers[] = $user;