"jakub-onderka/php-parallel-lint": "0.9.2",
"jetbrains/phpstorm-stubs": "dev-master#1b9906084d6635456fcf3f3a01f0d7d5b99a578a",
"justinrainbow/json-schema": "~5.2",
- "mediawiki/mediawiki-codesniffer": "0.11.0",
+ "mediawiki/mediawiki-codesniffer": "0.12.0",
"monolog/monolog": "~1.22.1",
"nikic/php-parser": "2.1.0",
"nmred/kafka-php": "0.1.5",
/**
* Load up our object with user supplied data
+ * @param Config $config
*/
function __construct( Config $config ) {
$this->config = $config;
* which in turn gives User::getName().
*
* @param string|int|User|null $target
- * @return array( User|String|null, Block::TYPE_ constant|null )
+ * @return array [ User|String|null, Block::TYPE_ constant|null ]
*/
public static function parseTarget( $target ) {
# We may have been through this before
* Get the target and target type for this particular Block. Note that for autoblocks,
* this returns the unredacted name; frontend functions need to call $block->getRedactedName()
* in this situation.
- * @return array( User|String, Block::TYPE_ constant )
+ * @return array [ User|String, Block::TYPE_ constant ]
* @todo FIXME: This should be an integral part of the Block member variables
*/
public function getTargetAndType() {
/**
* @see validateBounds()
+ * @param string $name
+ * @param int $min
+ * @param int $max
*/
public function validateIntBounds( $name, $min, $max ) {
$this->validateBounds( $name, $min, $max );
}
/**
- * {@inheritDoc}
+ * @inheritDoc
*/
public function start() {
if ( $this->procsToStart > 0 ) {
}
$age = time() - wfTimestamp( TS_UNIX, $mtime );
- $adaptiveTTL = max( .9 * $age, $minTTL );
+ $adaptiveTTL = max( 0.9 * $age, $minTTL );
$adaptiveTTL = min( $adaptiveTTL, $maxTTL );
$this->lowerCdnMaxage( (int)$adaptiveTTL );
*
* The schema for the data is located at:
* <https://meta.wikimedia.org/wiki/Schema:MediaWikiPingback>
+ * @return bool
*/
public function sendPingback() {
if ( !$this->acquireLock() ) {
* @see self::getLocalURL for the arguments.
* @param array|string $query
* @param string $proto Protocol type to use in URL
- * @return String. A url suitable to use in an HTTP location header.
+ * @return string A url suitable to use in an HTTP location header.
*/
public function getFullUrlForRedirect( $query = '', $proto = PROTO_CURRENT ) {
$target = $this;
* NOTE: Unlike getInternalURL(), the canonical URL includes the fragment
*
* @see self::getLocalURL for the arguments.
+ * @param string $query
+ * @param string|bool $query2
* @return string The URL
* @since 1.18
*/
* Creates a header that can be added to the output.
*
* @param string $header The header text.
+ * @param string $canonicalId
* @return string The HTML.
*/
protected function makeHeader( $header, $canonicalId ) {
}
/**
+ * @param array $data
* @return bool|array True for success, false for didn't-try, array of errors on failure
*/
public function onSubmit( $data ) {
/**
* Mark as internal. This isn't meant to be used by normal api users
+ * @return bool
*/
public function isInternal() {
return true;
/**
* Even if you don't have read rights, we still want your report.
+ * @return bool
*/
public function isReadMode() {
return false;
* Doesn't touch db, so max lag should be rather irrelavent.
*
* Also, this makes sure that reports aren't lost during lag events.
+ * @return bool
*/
public function shouldCheckMaxLag() {
return false;
/**
* Overridden to honor $this->forceDefaultParams(), if applicable
+ * @inheritDoc
* @since 1.26
*/
protected function getParameterFromSettings( $paramName, $paramSettings, $parseLimit ) {
* This class expects the result data to be in a custom format set by self::setResult()
* $result['_feed'] - an instance of one of the $wgFeedClasses classes
* $result['_feeditems'] - an array of FeedItem instances
+ * @param bool $unused
*/
public function initPrinter( $unused = false ) {
parent::initPrinter( $unused );
];
}
- /** @see ApiBase::getExamplesMessages() */
+ /** @inheritDoc */
protected function getExamplesMessages() {
return [
'action=help'
return $this->mQueryModule;
}
- /**
- * @see ApiBase::getParent()
- */
+ /** @inheritDoc */
public function getParent() {
return $this->getQuery();
}
}
}
- /**
- * @see ApiBase::getHelpFlags()
- *
- * Corresponding messages: api-help-flag-generator
- */
+ /** @inheritDoc */
protected function getHelpFlags() {
+ // Corresponding messages: api-help-flag-generator
$flags = parent::getHelpFlags();
$flags[] = 'generator';
return $flags;
}
/**
- * @returns ApiMessage
+ * @return ApiMessage
*/
private function getApiMessage() {
$errors = $this->status->getErrorsByType( 'error' );
* structured UI.
*
* This can either be the exact filter, or a new filter that replaces it.
+ * @return bool
*/
public function isFeatureAvailableOnStructuredUi() {
return $this->displaysOnStructuredUi();
}
/**
+ * @param string $index
+ * @return string
* @since 1.16.3
*/
public function getLetterByIndex( $index ) {
}
/**
+ * @param string $index
+ * @return string
* @since 1.16.3
*/
public function getSortKeyByLetterIndex( $index ) {
}
/**
+ * @param string $index
+ * @return string
* @since 1.16.3
*/
public function getFirstLetterCount() {
/**
* Test if a code point is a CJK (Chinese, Japanese, Korean) character
+ * @param int $codepoint
+ * @return bool
* @since 1.16.3
*/
public static function isCjk( $codepoint ) {
* Escape a string for inclusion in a PHP single-quoted string literal.
*
* @param string $string string to be escaped.
- * @return String: escaped string.
+ * @return string escaped string.
* @public
* @deprecated since 1.25, use UtfNormal\Utils directly
*/
}
/**
- * @see Config::get
+ * @inheritDoc
*/
public function get( $name ) {
if ( !$this->has( $name ) ) {
}
/**
- * @see Config::has
+ * @inheritDoc
*/
public function has( $name ) {
return $this->hasWithPrefix( $this->prefix, $name );
}
/**
- * @see Config::get
+ * @inheritDoc
*/
public function get( $name ) {
if ( !$this->has( $name ) ) {
}
/**
- * @see Config::has
+ * @inheritDoc
+ * @since 1.24
*/
public function has( $name ) {
return array_key_exists( $name, $this->settings );
/**
* @see MutableConfig::set
+ * @param string $name
+ * @param mixed $value
*/
public function set( $name, $value ) {
$this->settings[$name] = $value;
}
/**
- * @see Config::get
+ * @inheritDoc
*/
public function get( $name ) {
foreach ( $this->configs as $config ) {
}
/**
- * @see Config::has
+ * @inheritDoc
*/
public function has( $name ) {
foreach ( $this->configs as $config ) {
* @since 1.21
*
* @see Content::getModel
+ * @return string
*/
public function getModel() {
return $this->model_id;
* @since 1.21
*
* @see Content::getContentHandler
+ * @return ContentHandler
*/
public function getContentHandler() {
return ContentHandler::getForContent( $this );
* @since 1.21
*
* @see Content::getDefaultFormat
+ * @return string
*/
public function getDefaultFormat() {
return $this->getContentHandler()->getDefaultFormat();
* @since 1.21
*
* @see Content::getSupportedFormats
+ * @return string[]
*/
public function getSupportedFormats() {
return $this->getContentHandler()->getSupportedFormats();
/**
* @since 1.21
*
+ * @param string|int $sectionId
* @return null
*
* @see Content::getSection
/**
* @since 1.21
*
+ * @param string|int|null|bool $sectionId
+ * @param Content $with
+ * @param string $sectionTitle
* @return null
*
* @see Content::replaceSection
/**
* @since 1.21
*
+ * @param Title $title
+ * @param User $user
+ * @param ParserOptions $popts
* @return Content $this
*
* @see Content::preSaveTransform
/**
* @since 1.21
*
+ * @param string $header
* @return Content $this
*
* @see Content::addSectionHeader
/**
* @since 1.21
*
+ * @param Title $title
+ * @param ParserOptions $popts
+ * @param array $params
* @return Content $this
*
* @see Content::preloadTransform
/**
* @since 1.21
*
+ * @param WikiPage $page
+ * @param int $flags
+ * @param int $parentRevId
+ * @param User $user
* @return Status
*
* @see Content::prepareSave
* @since 1.21
*
* @param WikiPage $page
- * @param ParserOutput $parserOutput
+ * @param ParserOutput|null $parserOutput
*
* @return LinksDeletionUpdate[]
*
protected $writer;
/**
- * @var array $schemas Map from Monolog channel to Avro schema.
+ * @param array $schemas Map from Monolog channel to Avro schema.
* Each schema can be either the JSON string or decoded into PHP
* arrays.
*/
/**
* Get the writer for the named channel
*
- * @var string $channel Name of the schema to fetch
+ * @param string $channel Name of the schema to fetch
* @return \AvroSchema|null
*/
protected function getSchema( $channel ) {
/**
* Get the writer for the named channel
*
- * @var string $channel Name of the schema
+ * @param string $channel Name of the schema
* @return int|null
*/
public function getSchemaRevisionId( $channel ) {
* @see WANObjectCacheRepear
* @param WANObjectCache $cache
* @param TitleValue $t
- * @returns string[]
+ * @return string[]
*/
public function getEventAffectedKeys( WANObjectCache $cache, TitleValue $t ) {
/** @var WikiPage[]|LocalFile[]|User[] $entities */
class ExternalStoreHttp extends ExternalStoreMedium {
/**
* @see ExternalStoreMedium::fetchFromURL()
+ * @param string $url
+ * @return string|bool
+ * @throws MWException
*/
public function fetchFromURL( $url ) {
return Http::get( $url, [], __METHOD__ );
/**
* @see ExternalStoreMedium::store()
+ * @param string $cluster
+ * @param string $data
+ * @return string|bool
+ * @throws MWException
*/
public function store( $cluster, $data ) {
throw new MWException( "ExternalStoreHttp is read-only and does not support store()." );
* The URL returned is of the form of the form mwstore://backend/container/wiki/id
*
* @see ExternalStoreMedium::fetchFromURL()
+ * @param string $url
+ * @return bool
*/
public function fetchFromURL( $url ) {
$be = FileBackendGroup::singleton()->backendFromPath( $url );
/**
* @see ExternalStoreMedium::store()
+ * @param string $backend
+ * @param string $data
+ * @return string|bool
+ * @throws MWException
*/
public function store( $backend, $data ) {
$be = FileBackendGroup::singleton()->get( $backend );
*
* @param string $function
* @param array $params
+ * @return mixed
*/
protected function translateSrcParams( $function, array $params ) {
$latest = !empty( $params['latest'] );
* @param string $name
* @param int $width
* @param int $height
- * @param array $result Out parameter that will be changed by the function.
+ * @param array &$result
* @param string $otherParams
*
* @return bool
*
* This is the case for a couple files on Wikimedia servers where
* the old version is "lost".
+ * @return bool
*/
public function exists() {
$archiveName = $this->getArchiveName();
/**
* Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
+ * @param string $inputField
+ * @param array $config
* @return OOUI\FieldLayout|OOUI\ActionFieldLayout
*/
protected function getFieldLayoutOOUI( $inputField, $config ) {
/**
* Get a configured MultiHttpClient
* @param array $options
+ * @return MultiHttpClient
*/
public static function createMultiClient( $options = [] ) {
global $wgHTTPConnectTimeout, $wgHTTPTimeout, $wgHTTPProxy;
* so normal methods of handling errors programmatically
* like get_last_error() don't work.
* @internal
+ * @param int $errno
+ * @param string $errstr
*/
public function errorHandler( $errno, $errstr ) {
$n = count( $this->fopenErrors ) + 1;
class InstallerSessionProvider extends SessionProvider {
/**
* Pretend there is a session, to avoid MWCryptRand overhead
+ * @param WebRequest $request
+ * @return SessionInfo
*/
public function provideSessionInfo( WebRequest $request ) {
return new SessionInfo( 1, [
/**
* Yes we will treat your data with great care!
+ * @return bool
*/
public function persistsSessionId() {
return true;
/**
* Sure, you can be whoever you want, as long as you have ID 0
+ * @return bool
*/
public function canChangeUser() {
return true;
* @param string $updatekey
* @param string $patch
* @param bool $fullpath
+ * @return bool
*/
protected function updateSchema( $table, $updatekey, $patch, $fullpath = false ) {
if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
/**
* @param string $s
+ * @param string $escapeChar
* @return string
*/
protected function escapeLikeInternal( $s, $escapeChar = '`' ) {
/**
* Convert a wildcard (as used in LIKE) to a regex
* Slashes are escaped, slash terminators included
+ * @param string $wildcard
+ * @return string
*/
protected function likeToRegex( $wildcard ) {
$r = preg_quote( $wildcard, '/' );
*
* @see getRadioSet
*
+ * @param mixed[] $params
* @return array
*/
public function getRadioElements( $params ) {
/**
* @see JobQueue::ack()
* @param Job $job
+ * @return Job|bool
*/
protected function doAck( Job $job ) {
return $this->mainQueue->doAck( $job );
/**
* @see JobQueue::delete()
+ * @return bool
* @throws MWException
*/
protected function doDelete() {
/**
* @see JobQueueAggregator::notifyQueueEmpty()
+ * @param string $wiki
+ * @param string $type
+ * @return bool
*/
abstract protected function doNotifyQueueEmpty( $wiki, $type );
/**
* @see JobQueueAggregator::notifyQueueNonEmpty()
+ * @param string $wiki
+ * @param string $type
+ * @return bool
*/
abstract protected function doNotifyQueueNonEmpty( $wiki, $type );
* 2001:0db8:85a3::7344 - 2001:0db8:85a3::7344 Explicit range
* 2001:0db8:85a3::7344 Single IP
* @param string $range IP range
- * @return array(string, string)
+ * @return array [ string, string ]
*/
public static function parseRange( $range ) {
// CIDR notation
*
* @param string $key
* @param bool &$success
+ * @return bool
*/
protected function fetchResult( $key, &$success ) {
$success = false;
* @param callable $callable
* @param array $args
* @param int $ttl
+ * @return mixed
*/
public static function call( $callable, array $args = [], $ttl = 3600 ) {
$instance = new self( $callable, $ttl );
/**
* Start xhprof profiler
+ * @return bool
*/
public static function isEnabled() {
return self::$enabled;
/**
* Start xhprof profiler
+ * @param int $flags
+ * @param array $options
+ * @throws Exception
*/
public static function enable( $flags = 0, $options = [] ) {
if ( self::isEnabled() ) {
* The resulting array is left padded with nulls, so a key
* with no parent (eg 'main()') will return [null, 'function'].
*
+ * @param string $key
* @return array
*/
public static function splitKey( $key ) {
return; // invalid storage path
}
$mtime = ConvertibleTimestamp::convert( TS_UNIX, $val['mtime'] );
- $ttl = $this->memCache->adaptiveTTL( $mtime, 7 * 86400, 300, .1 );
+ $ttl = $this->memCache->adaptiveTTL( $mtime, 7 * 86400, 300, 0.1 );
$key = $this->fileCacheKey( $path );
// Set the cache unless it is currently salted.
$this->memCache->set( $key, $val, $ttl );
* @param string $chunk the first 256 bytes of the file
* @param string $proposed the MIME type proposed by the server
*
- * @return Array: map of IE version to detected MIME type
+ * @return array map of IE version to detected MIME type
*/
public function getRealMimesFromData( $fileName, $chunk, $proposed ) {
$types = $this->getMimesFromData( $fileName, $chunk, $proposed );
* @param string $chunk the first 256 bytes of the file
* @param string $proposed the MIME type proposed by the server
*
- * @return Array: map of IE version to detected MIME type
+ * @return array map of IE version to detected MIME type
*/
public function getMimesFromData( $fileName, $chunk, $proposed ) {
$types = [];
$lSince = microtime( true ); // lock timestamp
return new ScopedCallback( function () use ( $key, $lSince, $expiry ) {
- $latency = .050; // latency skew (err towards keeping lock present)
+ $latency = 0.050; // latency skew (err towards keeping lock present)
$age = ( microtime( true ) - $lSince + $latency );
if ( ( $age + $latency ) >= $expiry ) {
$this->logger->warning( "Lock for $key held too long ($age sec)." );
protected function applyDefaultParams( $params ) {
return $params + [
'compress_threshold' => 1500,
- 'connect_timeout' => .5,
+ 'connect_timeout' => 0.5,
'debug' => false
];
}
* @return int Adaptive TTL
* @since 1.28
*/
- public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = .2 ) {
+ public function adaptiveTTL( $mtime, $maxTTL, $minTTL = 30, $factor = 0.2 ) {
if ( is_float( $mtime ) || ctype_digit( $mtime ) ) {
$mtime = (int)$mtime; // handle fractional seconds and string integers
}
/** @var float Seconds */
protected $dbLockThreshold = 3.0;
/** @var float Seconds */
- protected $eventThreshold = .25;
+ protected $eventThreshold = 0.25;
/** @var bool */
protected $silenced = false;
const PING_TTL = 1.0;
const PING_QUERY = 'SELECT 1 AS ping';
- const TINY_WRITE_SEC = .010;
- const SLOW_WRITE_SEC = .500;
+ const TINY_WRITE_SEC = 0.010;
+ const SLOW_WRITE_SEC = 0.500;
const SMALL_WRITE_ROWS = 100;
/** @var string SQL query */
/**
* @param string $s
+ * @param string $escapeChar
* @return string
*/
protected function escapeLikeInternal( $s, $escapeChar = '`' ) {
* we don't want to select everything into memory
*
* @see IDatabase::insertSelect()
+ * @param string $destTable
+ * @param string|array $srcTable
+ * @param array $varMap
+ * @param array $conds
+ * @param string $fname
+ * @param array $insertOptions
+ * @param array $selectOptions
+ * @param array $selectJoinConds
+ * @return bool
*/
protected function nativeInsertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = __METHOD__,
* MS SQL supports more pattern operators than other databases (ex: [,],^)
*
* @param string $s
+ * @param string $escapeChar
* @return string
*/
protected function escapeLikeInternal( $s, $escapeChar = '`' ) {
}
/**
- * @var string $table
- * @var string $field
+ * @param string $table
+ * @param string $field
* @return PostgresField|null
*/
public function fieldInfo( $table, $field ) {
$newWeight = $movAveRatio * $coefficient + ( 1 - $movAveRatio ) * $lastWeight;
// Scale from 10% to 100% of nominal weight
- $weightScales[$i] = max( $newWeight, .10 );
+ $weightScales[$i] = max( $newWeight, 0.10 );
if ( !$conn ) {
$lagTimes[$i] = false;
* and logged in users by sending the current userId of a user
* with each request with a key of "uniques" (or similar).
*
- * @param string|array $key The metric(s) to set.
- * @param float $value The value for the stats.
+ * @param string|array $key The metric(s) to set.
+ * @param float $value The value for the stats.
*
* @return array
*/
* Visual Editor "pretends" the V1 API is like. A previous version of
* ParsoidVirtualRESTService translated these to the "real" Parsoid v1
* API. We now translate these to the "real" Parsoid v3 API.
+ * @param array $req
+ * @param Closure $idGeneratorFunc
+ * @return array
+ * @throws Exception
*/
public function onParsoid1Request( array $req, Closure $idGeneratorFunc ) {
$parts = explode( '/', $req['url'] );
/**
* Remaps Parsoid v1/v3 requests to RESTBase v1 requests.
+ * @param array $reqs
+ * @param Closure $idGeneratorFunc
+ * @return array
+ * @throws Exception
*/
public function onParsoidRequests( array $reqs, Closure $idGeneratorFunc ) {
$result = [];
* NOTE: the POST APIs aren't "real" Parsoid v1 APIs, they are just what
* Visual Editor "pretends" the V1 API is like. (See
* ParsoidVirtualRESTService.)
+ * @param array $req
+ * @param Closure $idGeneratorFunc
+ * @return array
+ * @throws Exception
*/
public function onParsoid1Request( array $req, Closure $idGeneratorFunc ) {
$parts = explode( '/', $req['url'] );
* * body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body_only' => true/false )
* * $title is optional
* * $revision is optional
+ * @param array $req
+ * @param Closure $idGeneratorFunc
+ * @return array
+ * @throws Exception
*/
public function onParsoid3Request( array $req, Closure $idGeneratorFunc ) {
$parts = explode( '/', $req['url'] );
/**
* Primary job is to initialize the XMLParser
+ * @param LoggerInterface|null $logger
*/
function __construct( LoggerInterface $logger = null ) {
if ( !function_exists( 'xml_parser_create_ns' ) ) {
/**
* Check if this instance supports using this class
+ * @return bool
*/
public static function isSupported() {
return function_exists( 'xml_parser_create_ns' ) && class_exists( 'XMLReader' );
/**
* Must use "im" for XCF
*
+ * @param string $dstPath
+ * @param bool $checkDstPath
* @return string
*/
protected function getScalerType( $dstPath, $checkDstPath = true ) {
* @todo Move this UI stuff somewhere else
*
* @see ContentHandler::getActionOverrides
+ * @return array
*/
public function getActionOverrides() {
return $this->getContentHandler()->getActionOverrides();
* @param array|string &$error Array of errors to append to
* @param User $user The deleting user
* @param array $tags Tags to apply to the deletion action
+ * @param string $logsubtype
* @return Status Status object; if successful, $status->value is the log_id of the
* deletion log entry. If the page couldn't be deleted because it wasn't
* found, $status is a non-fatal 'cannotdelete' error
// finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL)
// Current values imply that m=3933.333333 and b=-333.333333
// See https://www.nngroup.com/articles/website-response-times/
- const PARSE_FAST_SEC = .100; // perceived "fast" page parse
+ const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse
const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse
const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages
const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages
* return value is suitable for writing back via setText() but is not valid
* for display to the user.
*
+ * @return string
* @since 1.27
*/
public function getRawText() {
$this->mSpeculativeRevId = $id;
}
- /** @since 1.28 */
+ /**
+ * @return int|null
+ * @since 1.28
+ */
public function getSpeculativeRevIdUsed() {
return $this->mSpeculativeRevId;
}
}
/**
+ * @return array
* @since 1.25
*/
public function getIndicators() {
return $this->mModuleStyles;
}
- /** @since 1.23 */
+ /**
+ * @return array
+ * @since 1.23
+ */
public function getJsConfigVars() {
return $this->mJsConfigVars;
}
}
/**
+ * @param string $id
+ * @param string $content
* @since 1.25
*/
public function setIndicator( $id, $content ) {
* @code
* $parser->getOutput()->my_ext_foo = '...';
* @endcode
+ * @param string $name
+ * @param mixed $value
*/
public function setProperty( $name, $value ) {
$this->mProperties[$name] = $value;
*
* @param string $text
* @param int $flags
+ * @param string $tree
*/
protected function cacheSetTree( $text, $flags, $tree ) {
$config = RequestContext::getMain()->getConfig();
/**
* Like splitArg() but for a raw child array. For internal use only.
+ * @param array $children
+ * @return array
*/
public static function splitRawArg( array $children ) {
$bits = [];
/**
* Like splitExt() but for a raw child array. For internal use only.
+ * @param array $children
+ * @return array
*/
public static function splitRawExt( array $children ) {
$bits = [];
/**
* Like splitHeading() but for a raw child array. For internal use only.
+ * @param array $children
+ * @return array
*/
public static function splitRawHeading( array $children ) {
$bits = [];
/**
* Like splitTemplate() but for a raw child array. For internal use only.
+ * @param array $children
+ * @return array
*/
public static function splitRawTemplate( array $children ) {
$parts = [];
class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
/**
* @see RCFeedFormatter::getLine
+ * @param array $feed
+ * @param RecentChange $rc
+ * @param string|null $actionComment
+ * @return string|null
*/
public function getLine( array $feed, RecentChange $rc, $actionComment ) {
global $wgUseRCPatrol, $wgUseNPPatrol, $wgLocalInterwikis,
/**
* Generates a notification that can be easily interpreted by a machine.
* @see RCFeedFormatter::getLine
+ * @param array $feed
+ * @param RecentChange $rc
+ * @param string|null $actionComment
+ * @return string|null
*/
public function getLine( array $feed, RecentChange $rc, $actionComment ) {
global $wgCanonicalServer, $wgServerName, $wgScriptPath;
/**
* @see FormattedRCFeed::send
+ * @param array $feed
+ * @param string $line
+ * @return bool
*/
public function send( array $feed, $line ) {
$parsed = wfParseUrl( $feed['uri'] );
class UDPRCFeedEngine extends RCFeedEngine {
/**
* @see RCFeedEngine::send
+ * @param array $feed
+ * @param string $line
+ * @return bool
*/
public function send( array $feed, $line ) {
$transport = UDPTransport::newFromString( $feed['uri'] );
/**
* Helper method for getDefinitionSummary.
+ * @param ResourceLoaderContext $context
+ * @return array
*/
protected function getFileHashes( ResourceLoaderContext $context ) {
$this->loadFromDefinition();
}
/**
+ * @param ResourceLoaderContext|null $context
* @return array
*/
public function getDependencies( ResourceLoaderContext $context = null ) {
}
/**
+ * @param ResourceLoaderContext $context
* @return array
*/
public function getPreloadLinks( ResourceLoaderContext $context ) {
protected $targets = [ 'desktop', 'mobile' ];
/**
+ * @param ResourceLoaderContext $context
* @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
}
/**
+ * @param ResourceLoaderContext|null $context
* @return array
*/
public function getDependencies( ResourceLoaderContext $context = null ) {
/**
* Get a list of categories, as an array with title text strings.
*
+ * @param ParserOutput $parserOutput
* @return string[]
*/
public function getCategories( ParserOutput $parserOutput ) {
/**
* Get a list of external links from ParserOutput, as an array of strings.
*
+ * @param ParserOutput $parserOutput
* @return string[]
*/
public function getExternalLinks( ParserOutput $parserOutput ) {
* Get a list of outgoing wiki links (including interwiki links), as
* an array of prefixed title strings.
*
+ * @param ParserOutput $parserOutput
* @return string[]
*/
public function getOutgoingLinks( ParserOutput $parserOutput ) {
/**
* Get a list of templates used in the ParserOutput content, as prefixed title strings
*
+ * @param ParserOutput $parserOutput
* @return string[]
*/
public function getTemplates( ParserOutput $parserOutput ) {
* might support more. The default in all implementations should be 'relevance.'
*
* @since 1.25
- * @return array(string) the valid sort directions for setSort
+ * @return string[] the valid sort directions for setSort
*/
public function getValidSorts() {
return [ 'relevance' ];
/**
* Return a result set of hits on other (multiple) wikis associated with this one
*
+ * @param int $type
* @return SearchResultSet[]
*/
function getInterwikiResults( $type = self::SECONDARY_RESULTS ) {
/**
* Check if there are results on other wikis
*
+ * @param int $type
* @return bool
*/
function hasInterwikiResults( $type = self::SECONDARY_RESULTS ) {
/**
* Move the suggestion at index $key to the first position
+ * @param string $key
*/
public function rescore( $key ) {
$removed = array_splice( $this->suggestions, $key, 1 );
/**
* @codeCoverageIgnore
+ * @inheritDoc
*/
public function preventSessionsForUser( $username ) {
BotPassword::removeAllPasswordsForUser( $username );
/**
* @note Despite the name, this seems to be intended to implement isset()
* rather than array_key_exists(). So do that.
+ * @inheritDoc
*/
public function offsetExists( $offset ) {
$data = &$this->backend->getData();
* data to detect such changes.
* @note Accessing a nonexistent key via this mechanism causes that key to
* be created with a null value, and does not raise a PHP warning.
+ * @inheritDoc
*/
public function &offsetGet( $offset ) {
$data = &$this->backend->getData();
/**
* Deletes all sites from the database. After calling clear(), getSites() will return an empty
* list and getSite() will return null until saveSite() or saveSites() is called.
+ * @return bool
*/
public function clear() {
$this->sites = [];
/**
* @todo is this even used?
+ * @param string $name
+ * @param string $urlaction
+ * @return array
*/
function makeArticleUrlDetails( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
* ChangesListFilterGroup constructors.
*
* There is light processing to simplify core maintenance.
+ * @param array $definition
*/
protected function registerFiltersFromDefinitions( array $definition ) {
$autoFillPriority = -1;
/**
* @param string|null $subpage
+ * @return Title|bool
*/
public function execute( $subpage ) {
$redirect = $this->getRedirect( $subpage );
* @note This will only be run if the page is cached (ie $wgMiserMode = true)
* unless forceExistenceCheck() is true.
* @since 1.24
+ * @param Title $title
* @return bool
*/
protected function existenceCheck( Title $title ) {
/**
* @param int $ns The namespace of the article
* @param string $text The name of the article
- * @return array( int namespace, string dbkey, string pagename ) or null on error
+ * @return array|null [ int namespace, string dbkey, string pagename ] or null on error
*/
protected function getNamespaceKeyAndText( $ns, $text ) {
if ( $text == '' ) {
* @param string $par Subpage parameter passed to setup, or data value from
* the HTMLForm
* @param WebRequest $request Optionally try and get data from a request too
- * @return array( User|string|null, Block::TYPE_ constant|null )
+ * @return array [ User|string|null, Block::TYPE_ constant|null ]
*/
public static function getTargetAndType( $par, WebRequest $request = null ) {
$i = 0;
*
* @see T130058
* @todo FIXME This special page should not use LIMIT for paging
+ * @return int
*/
protected function getMaxResults() {
return max( parent::getMaxResults(), 60000 );
}
/**
- * @param stdClass $row Result row from recent changes
+ * @param stdClass $result Result row from recent changes
* @return Revision|bool
*/
protected function revisionFromRcResult( stdClass $result ) {
/**
* Under which header this special page is listed in Special:SpecialPages.
+ * @return string
*/
protected function getGroupName() {
return 'users';
* This controls js: mw.config.get( 'wgFileCanRotate' )
*
* @todo What about non-BitmapHandler handled files?
+ * @return bool
*/
public static function rotationEnabled() {
$bitmapHandler = new BitmapHandler();
* In its own function to allow subclasses to override.
* @see SpecialWantedFilesGUOverride in GlobalUsage extension.
* @since 1.24
+ * @return bool
*/
protected function likelyToHaveFalsePositives() {
return RepoGroup::singleton()->hasForeignRepos();
* Use wfFindFile so we still think file namespace pages without
* files are missing, but valid file redirects and foreign files are ok.
*
+ * @param Title $title
* @return bool
*/
protected function existenceCheck( Title $title ) {
/**
* Get a string key for the Noah's Ark algorithm
+ * @return string
*/
public function getNoahKey() {
if ( $this->noahKey === null ) {
/**
* Insert a comment at the appropriate place for inserting a node.
* @param string $value Content of the comment.
+ * @return string
* @see https://html.spec.whatwg.org/multipage/syntax.html#insert-a-comment
*/
public function insertComment( $value ) {
* Insert text at the appropriate place for inserting a node.
* @param string $value
* @param bool $isComment
+ * @return string
* @see https://html.spec.whatwg.org/multipage/syntax.html#appropriate-place-for-inserting-a-node
*/
public function insertText( $value, $isComment = false ) {
/**
* Return the adjusted current node.
+ * @param string $fragmentContext
+ * @return string
*/
public function adjustedCurrentNode( $fragmentContext ) {
return ( $fragmentContext && count( $this->elements ) === 1 ) ?
* Find and return the last element with the specified tag between the
* end of the list and the last marker on the list.
* Used when parsing <a> "in body mode".
+ * @param string $tag
+ * @return null|Node
*/
public function findElementByTag( $tag ) {
$elt = $this->tail;
/**
* Return true if validate() can be used
+ * @return bool
*/
public function supportsValidate() {
return false;
protected $alias;
/**
- * @var string $code PHP code (including <?php) to detect class names from
+ * @param string $code PHP code (including <?php) to detect class names from
* @return array List of FQCN detected within the tokens
*/
public function getClasses( $code ) {
*
* @param string $text Text to be converted
* @param string $variant The target variant code
- * @param int $startPos
+ * @param int &$startPos
* @param int $depth Depth of recursion
*
* @throws MWException
* This function has the same parameters as wfGetDB()
*
* @param int $db DB index (DB_REPLICA/DB_MASTER)
- * @param array $groups; default: empty array
- * @param string|bool $wiki; default: current wiki
+ * @param array $groups default: empty array
+ * @param string|bool $wiki default: current wiki
* @return IMaintainableDatabase
*/
protected function getDB( $db, $groups = [], $wiki = false ) {
/**
* Imports the site described by the parameters (see self::__construct()) passed to this
* maintenance sccript into the sites table of MediaWiki.
+ * @return bool
*/
public function execute() {
$siteStore = MediaWikiServices::getInstance()->getSiteStore();
/**
* Check whether a function or method includes a call to wfDeprecated(),
* indicating that it is a hard-deprecated interface.
+ * @param PhpParser\Node $node
+ * @return bool
*/
public function isHardDeprecated( PhpParser\Node $node ) {
if ( !$node->stmts ) {
/**
* gzwrite() / fwrite() wrapper
*
- * @param resource $handle
+ * @param resource &$handle
* @param string $str
*/
function write( &$handle, $str ) {
/**
* gzclose() / fclose() wrapper
*
- * @param resource $handle
+ * @param resource &$handle
*/
function close( &$handle ) {
if ( $this->compress ) {
* comment ID field.
* Blanks the old fields while migrating.
*
- * @param string $oldTable Table to migrate
+ * @param string $table Table to migrate
* @param string $primaryKey Primary key of the table.
* @param string $oldField Old comment field name
* @param string $newPrimaryKey Primary key of the new table.
/**
* Dumb stuff to run a mode.
+ * @return bool
*/
public function run() {
if ( !$this->mReady ) {
<exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
<exclude name="MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals" />
+ <exclude name="MediaWiki.Files.ClassMatchesFilename.WrongCase" />
+ <exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
+ <exclude name="MediaWiki.Files.OneClassPerFile.MultipleFound" />
</rule>
<rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
<properties>
/**
* Asserts that the cookie jar does not have the given cookie.
- * @param string $expectedName Cookie name
+ * @param string $name Cookie name
* @param CookieJar $cookieJar
*/
protected function assertNotHasCookie( $name, CookieJar $cookieJar ) {
/**
* This should be called before the table prefix is changed
+ * @param IDatabase $db
+ * @param bool|string $filter
*/
function __construct( $db, $filter = false ) {
$this->db = $db;
/**
* Show a warning to the user
+ * @param string $message
*/
public function warning( $message ) {
echo "$message\n";
/**
* Mark a test skipped
+ * @param string $test
+ * @param string $subtest
*/
public function skipped( $test, $subtest ) {
if ( $this->showProgress ) {
/**
* Serialize the XML DOM for comparison purposes. This does not generate HTML.
+ * @return string
*/
protected function serialize() {
return strtr( $this->doc->saveXML( $this->body ),
/**
* Ensure a given setup stage has been done, throw an exception if it has
* not.
+ * @param string $funcName
+ * @param string|null $funcName2
*/
protected function checkSetupDone( $funcName, $funcName2 = null ) {
if ( !$this->setupDone[$funcName]
/**
* Determine whether the current parser has the hooks registered in it
* that are required by a file read by TestFileReader.
+ * @param array $requirements
+ * @return bool
*/
public function meetsRequirements( $requirements ) {
foreach ( $requirements as $requirement ) {
// get a reference to the mock object.
MessageCache::singleton()->getParser();
$restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] );
- $status = $page->doEditContent(
- ContentHandler::makeContent( $text, $title ),
- '',
- EDIT_NEW | EDIT_INTERNAL
- );
- $restore();
+ try {
+ $status = $page->doEditContent(
+ ContentHandler::makeContent( $text, $title ),
+ '',
+ EDIT_NEW | EDIT_INTERNAL
+ );
+ } finally {
+ $restore();
+ }
if ( !$status->isOK() ) {
throw new MWException( $status->getWikiText( false, false, 'en' ) );
/**
* Mark a test skipped
+ * @param string $test
+ * @param string $reason
*/
public function skipped( $test, $reason ) {
$this->testCase->markTestSkipped( "SKIPPED: $reason" );
/**
* Determine if there is a usable tidy.
+ * @param bool $useConfiguration
*/
public function __construct( $useConfiguration = false ) {
global $IP, $wgUseTidy, $wgTidyBin, $wgTidyInternal, $wgTidyConfig,
*
* @param Config|null $bootstrapConfig The bootstrap config to use with the new
* MediaWikiServices.
+ * @return MediaWikiServices
*/
protected static function resetGlobalServices( Config $bootstrapConfig = null ) {
$oldServices = MediaWikiServices::getInstance();
*
* @since 1.20
*
- * @param array $array
+ * @param array &$array
*/
protected function objectAssociativeSort( array &$array ) {
uasort(
*
* @since 1.20
*
- * @param mixed $r The array to remove string keys from.
+ * @param mixed &$r The array to remove string keys from.
*/
protected static function stripStringKeys( &$r ) {
if ( !is_array( $r ) ) {
/**
* Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit.
+ * @param string $buffer
* @return string
*/
public static function wfResetOutputBuffersBarrier( $buffer ) {
* - string 'modules' Pipe-separated list of module names
* - string|null 'only' "scripts" (unwrapped script), "styles" (stylesheet), or null
* (mw.loader.implement).
+ * @param ResourceLoader|null $rl
* @return ResourceLoaderContext
*/
protected function getResourceLoaderContext( $options = [], ResourceLoader $rl = null ) {
[ -30281104, TS_MW, '19690115123456', 'Negative TS_UNIX to TS_MW' ],
[ $t, TS_UNIX, 979562096, 'TS_UNIX to TS_UNIX' ],
[ $t, TS_DB, '2001-01-15 12:34:56', 'TS_UNIX to TS_DB' ],
- [ $t + .01, TS_MW, '20010115123456', 'TS_UNIX float to TS_MW' ],
+ [ $t + 0.01, TS_MW, '20010115123456', 'TS_UNIX float to TS_MW' ],
[ $t, TS_ISO_8601_BASIC, '20010115T123456Z', 'TS_ISO_8601_BASIC to TS_DB' ],
/**
* Returns SQL queries grouped by '; '
* Clear the list of queries that have been done so far.
+ * @return string
*/
public function getLastSqls() {
$lastSqls = implode( '; ', $this->lastSqls );
public static function provideAdaptiveTTL() {
return [
- [ 3600, 900, 30, .2, 720 ],
- [ 3600, 500, 30, .2, 500 ],
- [ 3600, 86400, 800, .2, 800 ],
- [ false, 86400, 800, .2, 800 ],
- [ null, 86400, 800, .2, 800 ]
+ [ 3600, 900, 30, 0.2, 720 ],
+ [ 3600, 500, 30, 0.2, 500 ],
+ [ 3600, 86400, 800, 0.2, 800 ],
+ [ false, 86400, 800, 0.2, 800 ],
+ [ null, 86400, 800, 0.2, 800 ]
];
}
$tp->setLogger( $logger );
$tp->setExpectation( 'queries', 2, __METHOD__ );
- $tp->recordQueryCompletion( "SQL 1", microtime( true ) - .01, false, 0 );
- $tp->recordQueryCompletion( "SQL 2", microtime( true ) - .01, false, 0 );
- $tp->recordQueryCompletion( "SQL 3", microtime( true ) - .01, false, 0 ); // warn
- $tp->recordQueryCompletion( "SQL 4", microtime( true ) - .01, false, 0 ); // warn
+ $tp->recordQueryCompletion( "SQL 1", microtime( true ) - 0.01, false, 0 );
+ $tp->recordQueryCompletion( "SQL 2", microtime( true ) - 0.01, false, 0 );
+ $tp->recordQueryCompletion( "SQL 3", microtime( true ) - 0.01, false, 0 ); // warn
+ $tp->recordQueryCompletion( "SQL 4", microtime( true ) - 0.01, false, 0 ); // warn
}
public function testWriteQueryCount() {
$tp->setLogger( $logger );
$tp->setExpectation( 'writes', 2, __METHOD__ );
- $tp->recordQueryCompletion( "SQL 1", microtime( true ) - .01, false, 0 );
- $tp->recordQueryCompletion( "SQL 2", microtime( true ) - .01, false, 0 );
- $tp->recordQueryCompletion( "SQL 3", microtime( true ) - .01, false, 0 );
- $tp->recordQueryCompletion( "SQL 4", microtime( true ) - .01, false, 0 );
+ $tp->recordQueryCompletion( "SQL 1", microtime( true ) - 0.01, false, 0 );
+ $tp->recordQueryCompletion( "SQL 2", microtime( true ) - 0.01, false, 0 );
+ $tp->recordQueryCompletion( "SQL 3", microtime( true ) - 0.01, false, 0 );
+ $tp->recordQueryCompletion( "SQL 4", microtime( true ) - 0.01, false, 0 );
$tp->transactionWritingIn( 'srv1', 'db1', '123' );
- $tp->recordQueryCompletion( "SQL 1w", microtime( true ) - .01, true, 2 );
- $tp->recordQueryCompletion( "SQL 2w", microtime( true ) - .01, true, 5 );
- $tp->recordQueryCompletion( "SQL 3w", microtime( true ) - .01, true, 3 );
- $tp->recordQueryCompletion( "SQL 4w", microtime( true ) - .01, true, 1 );
+ $tp->recordQueryCompletion( "SQL 1w", microtime( true ) - 0.01, true, 2 );
+ $tp->recordQueryCompletion( "SQL 2w", microtime( true ) - 0.01, true, 5 );
+ $tp->recordQueryCompletion( "SQL 3w", microtime( true ) - 0.01, true, 3 );
+ $tp->recordQueryCompletion( "SQL 4w", microtime( true ) - 0.01, true, 1 );
$tp->transactionWritingOut( 'srv1', 'db1', '123', 1, 1 );
}
}
$db->setLBInfo( 'clusterMasterHost', 'db1052' );
$lagEst = $db->getLag();
- $this->assertGreaterThan( $lag - .010, $lagEst, "Correct heatbeat lag" );
- $this->assertLessThan( $lag + .010, $lagEst, "Correct heatbeat lag" );
+ $this->assertGreaterThan( $lag - 0.010, $lagEst, "Correct heatbeat lag" );
+ $this->assertLessThan( $lag + 0.010, $lagEst, "Correct heatbeat lag" );
}
public static function provideLagAmounts() {
* @param User|null $user The user which should be used in the context of this special page
*
* @throws Exception
- * @return array( string, WebResponse ) A two-elements array containing the HTML output
+ * @return array [ string, WebResponse ] A two-elements array containing the HTML output
* generated by the special page as well as the response object.
*/
public function executeSpecialPage(
* @param User|null $user The user which should be used in the context of this special page
*
* @throws Exception
- * @return array( string, WebResponse ) A two-elements array containing the HTML output
+ * @return array [ string, WebResponse ] A two-elements array containing the HTML output
* generated by the special page as well as the response object.
*/
protected function executeSpecialPage(
/**
* Creates an empty Content object of the type supported by this ContentHandler.
+ * @return DummyContentForTesting
*/
public function makeEmptyContent() {
return new DummyContentForTesting( '' );
/**
* Creates an empty Content object of the type supported by this ContentHandler.
+ * @return DummyNonTextContent
*/
public function makeEmptyContent() {
return new DummyNonTextContent( '' );
/**
* August 22 – The theft of the Mona Lisa is discovered in the Louvre."
* T22281
+ * @return int
*/
public function getSize() {
return 1911;