* - If there are multiple exact or range blocks at the same level, the one chosen
* is random
*
+ * @param array $blocks Array of blocks
* @param array $ipChain List of IPs (strings). This is used to determine how "close"
* a block is to the server, and if a block matches exactly, or is in a range.
* The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2,
* local-squid, ...)
- * @param array $block Array of blocks
* @return Block|null The "best" block from the list
*/
public static function chooseBlock( array $blocks, array $ipChain ) {
$wgSkipSkins[] = $wgSkipSkin;
}
-// Register a hidden "fallback" skin
-$wgValidSkinNames['fallback'] = 'Fallback'; // SkinFallback
+// Register skins
+// Use a closure to avoid leaking into global state
+call_user_func( function() use ( $wgValidSkinNames ) {
+ $factory = SkinFactory::getDefaultInstance();
+ foreach ( $wgValidSkinNames as $name => $skin ) {
+ $factory->register( $name, $skin, function() use ( $skin ) {
+ $class = "Skin$skin";
+ return new $class;
+ } );
+ }
+ // Register a hidden "fallback" skin
+ $factory->register( 'fallback', 'Fallback', function() {
+ return new SkinFallback;
+ } );
+} );
$wgSkipSkins[] = 'fallback';
if ( $wgLocalInterwiki ) {
/**
* @see self::getPossibleErrors()
* @deprecated since 1.24
- * @retun array
+ * @return array
*/
public function getFinalPossibleErrors() {
wfDeprecated( __METHOD__, '1.24' );
// create instance from factory
$instance = call_user_func( $factory, $this->mParent, $name );
- if ( ! $instance instanceof $class ) {
+ if ( !$instance instanceof $class ) {
throw new MWException( "The factory function for module $name did not return an instance of $class!" );
}
} else {
private $mSpecialTitles = array();
private $mNormalizedTitles = array();
private $mInterwikiTitles = array();
+ /** @var Title[] */
private $mPendingRedirectIDs = array();
private $mConvertedTitles = array();
private $mGoodRevIDs = array();
private $mFakePageId = -1;
private $mCacheMode = 'public';
private $mRequestedPageFields = array();
- /**
- * @var int
- */
+ /** @var int */
private $mDefaultNamespace = NS_MAIN;
/**
/**
* Get a list of redirect resolutions - maps a title to its redirect
* target, as an array of output-ready arrays
- * @return array
+ * @return Title[]
*/
public function getRedirectTitles() {
return $this->mRedirectTitles;
/**
* Get the list of titles with negative namespace
- * @return array Title
+ * @return Title[]
*/
public function getSpecialTitles() {
return $this->mSpecialTitles;
$hasInterwikiResults = false;
if ( $interwiki && $resultPageSet === null && $matches->hasInterwikiResults() ) {
$matches = $matches->getInterwikiResults();
- $iwprefixes = array();
$hasInterwikiResults = true;
// Include number of results if requested
*
* @since 1.24
* @param string|null $continue The "continue" parameter, if any
- * @param array $allModules Contains ApiBase instances that will be executed
+ * @param ApiBase[] $allModules Contains ApiBase instances that will be executed
* @param array $generatedModules Names of modules that depend on the generator
* @return array Two elements: a boolean indicating if the generator is done,
* and an array of modules to actually execute.
* @ingroup API
*/
class ApiUpload extends ApiBase {
- /** @var UploadBase */
+ /** @var UploadBase|UploadFromChunks */
protected $mUpload = null;
protected $mParams;
}
} else {
$filekey = $this->mParams['filekey'];
- /** @var $status Status */
$status = $this->mUpload->addChunk(
$chunkPath, $chunkSize, $this->mParams['offset'] );
if ( !$status->isGood() ) {
if ( isset( $warnings['duplicate'] ) ) {
$dupes = array();
+ /** @var File $dupe */
foreach ( $warnings['duplicate'] as $dupe ) {
$dupes[] = $dupe->getName();
}
if ( isset( $warnings['exists'] ) ) {
$warning = $warnings['exists'];
unset( $warnings['exists'] );
+ /** @var LocalFile $localFile */
$localFile = isset( $warning['normalizedFile'] )
? $warning['normalizedFile']
: $warning['file'];
/**
* Parsing RC_* constants to human-readable test
* @since 1.24
- * @param int $rc_type
+ * @param int $rcType
* @return string $type
*/
public static function parseFromRCType( $rcType ) {
}
/**
* Constructs an HTML representation of a JSON object.
- * @param Array $mapping
- * @return string HTML.
+ * @param array $mapping
+ * @return string HTML
*/
protected function objectTable( $mapping ) {
$rows = array();
return wfTimestamp( TS_POSTGRES, $ts );
}
- /*
+ /**
* Posted by cc[plus]php[at]c2se[dot]com on 25-Mar-2009 09:12
* to http://www.php.net/manual/en/ref.pgsql.php
*
* Fields can be retrieved with $row->fieldname, with fields acting like
* member variables.
*
- * @return object
+ * @return stdClass
* @throws DBUnexpectedError Thrown if the database returns an error
*/
function fetchObject() {
$this->db->dataSeek( $this, $row );
}
- /*********************
- * Iterator functions
+ /*
+ * ======= Iterator functions =======
* Note that using these in combination with the non-iterator functions
* above may cause rows to be skipped or repeated.
*/
}
/**
- * @return int
+ * @return stdClass|array|false
*/
function current() {
if ( is_null( $this->currentRow ) ) {
}
/**
- * @return int
+ * @return stdClass
*/
function next() {
$this->pos++;
return count( $this->result );
}
+ /**
+ * @return array|bool
+ */
function fetchRow() {
if ( $this->pos < count( $this->result ) ) {
$this->currentRow = $this->result[$this->pos];
function free() {
}
- // Callers want to be able to access fields with $this->fieldName
+ /**
+ * Callers want to be able to access fields with $this->fieldName
+ * @return false|stdClass
+ */
function fetchObject() {
$this->fetchRow();
if ( $this->currentRow ) {
$this->currentRow = null;
}
+ /**
+ * @return false|stdClass
+ */
function next() {
return $this->fetchObject();
}
* Sanitize and filter the custom headers from a $params array.
* We only allow certain Content- and X-Content- headers.
*
- * @param array $headers
+ * @param array $params
* @return array Sanitized value of 'headers' field in $params
*/
protected function sanitizeHdrs( array $params ) {
*
* STUB
* @param string $hash SHA-1 hash
- * @return array
+ * @return File[]
*/
public function findBySha1( $hash ) {
return array();
} elseif ( is_array( $triple[2] ) && isset( $triple[2]['headers'] ) ) {
$headers = $triple[2]['headers'];
}
+ // @fixme: $headers might not be defined
$operations[] = array(
'op' => FileBackend::isStoragePath( $src ) ? 'copy' : 'store',
'src' => $src,
/**
* @throws MWException
- * @param array $row
+ * @param stdClass $row
* @return LocalFile
*/
function newFileFromRow( $row ) {
$hashPath = $this->getDeletedHashPath( $key );
$path = "$root/$hashPath$key";
$dbw->begin( __METHOD__ );
- // Check for usage in deleted/hidden files and pre-emptively
+ // Check for usage in deleted/hidden files and preemptively
// lock the key to avoid any future use until we are finished.
$deleted = $this->deletedFileHasKey( $key, 'lock' );
$hidden = $this->hiddenFileHasKey( $key, 'lock' );
* Checks if there is a redirect named as $title
*
* @param Title $title Title of file
- * @return bool
+ * @return bool|Title
*/
function checkRedirect( Title $title ) {
global $wgMemc;
* SHA-1 content hash.
*
* @param string $hash A sha1 hash to look for
- * @return array
+ * @return File[]
*/
function findBySha1( $hash ) {
$dbr = $this->getSlaveDB();
/**
* Interface for FileRepo::checkRedirect()
* @param Title $title
- * @return bool
+ * @return bool|Title
*/
function checkRedirect( Title $title ) {
if ( !$this->reposInitialised ) {
* Find all instances of files with this key
*
* @param string $hash Base 36 SHA-1 hash
- * @return array Array of File objects
+ * @return File[]
*/
function findBySha1( $hash ) {
if ( !$this->reposInitialised ) {
* @note Use getWidth()/getHeight() instead of this method unless you have a
* a good reason. This method skips all caches.
*
- * @param string $fileName The path to the file (e.g. From getLocalPathRef() )
+ * @param string $filePath The path to the file (e.g. From getLocalPathRef() )
* @return array The width, followed by height, with optionally more things after
*/
function getImageSize( $filePath ) {
* @param string $tableName The table name
* @param string $oldIndexName The old index name
* @param string $newIndexName The new index name
+ * @param string $sqlPath The path to the SQL change path
* @param bool $skipBothIndexExistWarning Whether to warn if both the old
* and the new indexes exist. [facultative; by default, false]
- * @param string $sqlPath The path to the SQL change path
*/
public function renameExtensionIndex( $tableName, $oldIndexName, $newIndexName,
$sqlPath, $skipBothIndexExistWarning = false
/**
* Try to see if a given fulltext catalog exists
* We assume we already have the appropriate database selected
- * @param string $schemaName Catalog name to check
+ * @param string $catalogName Catalog name to check
* @return bool
*/
private function catalogExists( $catalogName ) {
/** Add misc metadata. Warning: atm if the metadata category
* doesn't have a priority, it will be silently discarded.
*
- * @param array $meta Array of metadata values
+ * @param array $metaArray Array of metadata values
* @param string $type Type. defaults to other. if two things have the same type they're merged
*/
function addMetadata( $metaArray, $type = 'other' ) {
return 2; // We don't need no bloddy constants!
}
- /**#@+
+ /**
* Validates if a tag value is of the type it should be according to the Exif spec
*
* @param mixed $in The input value to check
// Do nothing
}
- /*
+ /**
* True if the handler can rotate the media
* @since 1.21
* @return bool
*
* @param File $file The image object, or false if there isn't one.
* Warning, FSFile::getPropsFromPath might pass an (object)array() instead (!)
- * @param string $path The filename
+ * @param string $filename The filename
* @return string
*/
public function getMetadata( $file, $filename ) {
}
/**
- * @param string $key
* @param mixed $casToken
+ * @param string $key
* @param mixed $value
* @param int $exptime
* @return bool
* Store a value in the WinCache object cache
*
* @param string $key Cache key
- * @param mixed $valueObject Value to store
+ * @param mixed $value Value to store
* @param int $expire Expiration time
* @return bool
*/
* @param Content $content Content submitted
* @param User $user The relevant user
* @param string $comment Comment submitted
- * @param string $serialisation_format Format for storing the content in the database
* @param bool $minor Whereas it's a minor modification
+ * @param string $serialisation_format Format for storing the content in the database
*/
public function doQuickEditContent( Content $content, User $user, $comment = '', $minor = false,
$serialisation_format = null
/**
* Do something with the error, like showing it to the user.
*
- * @param $status
+ * @param Status $status
*
* @return bool
*/
/**
* @param Page $page
+ * @param ParserOptions $parserOptions ParserOptions to use for the parse
* @param int $revid ID of the revision being parsed.
* @param bool $useParserCache Whether to use the parser cache.
- * @param ParserOptions $parserOptions ParserOptions to use for the parse
* operation.
* @param Content|string $content Content to parse or null to load it; may
* also be given as a wikitext string, for BC.
* Suggest a target for the revision deletion
* @since 1.22
* @param string $typeName
- * @param Title|null $title User-supplied target
+ * @param Title|null $target User-supplied target
* @param array $ids
* @return Title|null
*/
* Factory method for loading a skin of a given type
* @param string $key 'monobook', 'vector', etc.
* @return Skin
- * @deprecated Use SkinFactory instead
+ * @deprecated since 1.24; Use SkinFactory instead
*/
static function &newFromKey( $key ) {
wfDeprecated( __METHOD__, '1.24' );
return "$numeric $type $name";
}
- /*
+ /**
* Return values for <html> element
* @return array of associative name-to-value elements for <html> element
*/
*/
private $factoryFunctions = array();
/**
- * Map of name => human readable name
+ * Map of name => fallback human-readable name, used when the 'skinname-<skin>' message is not
+ * available
+ *
* @var array
*/
private $displayNames = array();
+ /**
+ * Map of name => class name without "Skin" prefix, for legacy skins using the autodiscovery
+ * mechanism
+ *
+ * @var array
+ */
+ private $legacySkins = array();
/**
* @var SkinFactory
}
/**
- * Register a new Skin factory function
- * Will override if it's already registered
- * @param string $name
- * @param string $displayName
- * @param callable $callback That takes the skin name as an argument
+ * Register a new Skin factory function.
+ *
+ * Will override if it's already registered.
+ *
+ * @param string $name Internal skin name. Should be all-lowercase (but technically doesn't have
+ * to be).
+ * @param string $displayName For backwards-compatibility with old skin loading system. This is
+ * the text used as skin's human-readable name when the 'skinname-<skin>' message is not
+ * available. It should be the same as the skin name provided in $wgExtensionCredits.
+ * @param callable $callback Callback that takes the skin name as an argument
* @throws InvalidArgumentException If an invalid callback is provided
*/
public function register( $name, $displayName, $callback ) {
* @return array
*/
private function getLegacySkinNames() {
- global $wgValidSkinNames;
static $skinsInitialised = false;
- if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
+ if ( !$skinsInitialised || !count( $this->legacySkins ) ) {
# Get a list of available skins
# Build using the regular expression '^(.*).php$'
# Array keys are all lower case, array value keep the case used by filename
"The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " .
"See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this."
);
- $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
+ $this->legacySkins[strtolower( $aSkin )] = $aSkin;
}
}
$skinDir->close();
$skinsInitialised = true;
wfProfileOut( __METHOD__ . '-init' );
}
- return $wgValidSkinNames;
+ return $this->legacySkins;
}
}
/**
- * Get a legacy skin which uses $wgValidSkinNames
- * or autoloading
+ * Get a legacy skin which uses the autodiscovery mechanism.
*
* @param string $name
* @return Skin|bool false if the skin couldn't be constructed
*/
public function makeSkin( $name ) {
if ( !isset( $this->factoryFunctions[$name] ) ) {
- // Check the legacy method of skin loading
+ // Check the legacy autodiscovery method of skin loading
$legacy = $this->getLegacySkin( $name );
if ( $legacy ) {
return $legacy;
/**
* Add CSS via ResourceLoader
*
- * @param $out OutputPage
+ * @param OutputPage $out
*/
public function setupSkinUserCss( OutputPage $out ) {
parent::setupSkinUserCss( $out );
*/
protected $hideRights = array();
+ /**
+ * @var array
+ */
+ private $blockStatusByUid;
+
/**
* @param IContextSource $context
* @param null $group Unused
}
}
- /*
+ /**
* @param string|null $subPage
*/
public function execute( $subPage ) {
return null;
}
+ /** @var UploadBase $handler */
$handler = new $className;
$handler->initializeFromRequest( $request );
/**
* Return the local file and initializes if necessary.
*
- * @return LocalFile|null
+ * @return LocalFile|UploadStashFile|null
*/
public function getLocalFile() {
if ( is_null( $this->mLocalFile ) ) {
/**
* Divide the element name passed by the xml parser to the callback into URI and prifix.
- * @param string $name
+ * @param string $element
* @return array Containing the namespace URI and prefix
*/
private static function splitXmlNamespace( $element ) {
* Get the current status of a chunked upload (used for polling).
* The status will be read from the *current* user session.
* @param string $statusKey
- * @return array|bool
+ * @return Status[]|bool
*/
public static function getSessionStatus( $statusKey ) {
return isset( $_SESSION[self::SESSION_STATUS_KEY][$statusKey] )
protected $mChunkIndex;
protected $mFileKey;
protected $mVirtualTempPath;
+ /** @var LocalRepo */
+ private $repo;
/**
* Setup local pointers to stash, repo and user (similar to UploadFromStash)
* and the SKM (source key material) is the "data".
*
* @param string $hash The hashing function to use (e.g., sha256)
- * @param string $ikm The input keying material
* @param string $salt The salt to add to the ikm, to get the prk
+ * @param string $ikm The input keying material
* @return string Binary string (pseudorandm key) used as input to HKDFExpand
*/
private static function HKDFExtract( $hash, $salt, $ikm ) {
}
/**
- * @param array $time (UIDGenerator::millitime(), clock sequence)
+ * @param array $info (UIDGenerator::millitime(), clock sequence)
* @return string 88 bits
*/
protected function getTimestampedID88( array $info ) {
/**
* Returns true if a language code is an IETF tag known to MediaWiki.
*
- * @param string $code
+ * @param string $tag
*
* @since 1.21
* @return bool
* Checks that convertPlural was given an array and pads it to requested
* amount of forms by copying the last one.
*
- * @param int $count How many forms should there be at least
* @param array $forms Array of forms given to convertPlural
+ * @param int $count How many forms should there be at least
* @return array Padded array of forms or an exception if not an array
*/
protected function preConvertPlural( /* Array */ $forms, $count ) {
/**
* @todo Do this for real
- * @param int $ns
- * @param string $name
+ * @param int $key
+ * @param string $prefix
* @param bool $fix
* @param string $suffix
* @return bool
/**
* @dataProvider providerGetDisplayWidthHeight
- * @param array $dimensions Array [maxWidth, maxHeight, width, height]
+ * @param array $dim Array [maxWidth, maxHeight, width, height]
* @param array $expected Array [width, height] The width and height we expect to display at
*/
function testGetDisplayWidthHeight( $dim, $expected ) {
'logout',
'action',
'ApiLogout',
- function( ApiMain $main, $action ) {
- return new ApiLogout( $main, $action );
+ function ( ApiMain $main, $action ) {
+ return new ApiLogout( $main, $action );
},
),
);
),
'logout' => array(
'class' => 'ApiLogout',
- 'factory' => function( ApiMain $main, $action ) {
+ 'factory' => function ( ApiMain $main, $action ) {
return new ApiLogout( $main, $action );
},
),
),
'logout' => array(
'class' => 'ApiLogout',
- 'factory' => function( ApiMain $main, $action ) {
- return new ApiLogout( $main, $action );
- },
+ 'factory' => function ( ApiMain $main, $action ) {
+ return new ApiLogout( $main, $action );
+ },
),
);
* @param array $params Api parameters
* @param int $expectedCount Max number of iterations
* @param string $id Unit test id
- * @param bool $useContinue True to use smart continue
+ * @param bool $continue True to use smart continue
* @return Merged results data array
*/
protected function checkC( $expected, $params, $expectedCount, $id, $continue = true ) {
* @param string $titlePart
* @param int $namespace
* @param string $expected
- * @param string $description
+ * @param string $expectException
* @dataProvider provideTestTitlePartToKey
*/
function testTitlePartToKey( $titlePart, $namespace, $expected, $expectException ) {
* @dataProvider provideDataToEncode
*/
public function testBeautifyUsesFormatJson( $data ) {
- $obj = new JSONContent( FormatJson::encode( $data) );
+ $obj = new JSONContent( FormatJson::encode( $data ) );
$this->assertEquals( FormatJson::encode( $data, true ), $obj->beautifyJSON() );
}
*/
public function testPreSaveTransform( $data ) {
$obj = new JSONContent( FormatJson::encode( $data ) );
- $newObj = $obj->preSaveTransform( $this->getMockTitle(), $this->getMockUser() , $this->getMockParserOptions() );
+ $newObj = $obj->preSaveTransform( $this->getMockTitle(), $this->getMockUser(), $this->getMockParserOptions() );
$this->assertTrue( $newObj->equals( new JSONContent( FormatJson::encode( $data, true ) ) ) );
}
),
);
}
-
-}
\ No newline at end of file
+}
/**
* @param string $filename
* @param int $expectedWidth Width
- * @param int $expectedHeigh Height
+ * @param int $expectedHeight Height
* @dataProvider provideGetImageSize
* @covers XCFHandler::getImageSize
*/
protected function setUp() {
parent::setUp();
- $this->setMwGlobals( array(
- 'wgValidSkinNames' => array( 'vector' => 'Vector' ),
- ) );
+ // The return value of the closure shouldn't matter since this test should
+ // never call it
+ SkinFactory::getDefaultInstance()->register( 'vector', 'Vector', function(){});
}
/**
*/
public function testRegister() {
$factory = new SkinFactory();
- $factory->register( 'fallback', 'Fallback', function() {
+ $factory->register( 'fallback', 'Fallback', function () {
return new SkinFallback();
} );
$this->assertTrue( true ); // No exception thrown
*
* @param Page $page Page to add the revision to
* @param string $text Revisions text
- * @param string $text Revisions summare
+ * @param string $summary Revisions summare
*
* @throws MWException
*/
* Asserts that the xml reader is at the final closing tag of an xml file and
* closes the reader.
*
- * @param string $tag (optional) the name of the final tag
+ * @param string $name (optional) the name of the final tag
* (e.g.: "mediawiki" for </mediawiki>)
*/
protected function assertDumpEnd( $name = "mediawiki" ) {
* @param string $text_sha1 The base36 SHA-1 of the revision's text
* @param string|bool $text (optional) The revision's string, or false to check for a
* revision stub
+ * @param int|bool $parentid (optional) id of the parent revision
* @param string $model The expected content model id (default: CONTENT_MODEL_WIKITEXT)
* @param string $format The expected format model id (default: CONTENT_FORMAT_WIKITEXT)
- * @param int|bool $parentid (optional) id of the parent revision
*/
protected function assertRevision( $id, $summary, $text_id, $text_bytes,
$text_sha1, $text = false, $parentid = false,
*
* @param WikiPage $page The page to add the revision to
* @param string $text The revisions text
- * @param string $text The revisions summare
+ * @param string $summary The revisions summare
*
* @throws MWException
*/
* Throw an exception if it is not set, referencing current section
* and adding the current file name and line number
*
- * @param string|array $token Expected token(s) that should have been
+ * @param string|array $tokens Expected token(s) that should have been
* mentioned before closing this section
* @param bool $fatal True iff an exception should be thrown if
* the section is not found.
/**
* Similar to ParserTest object but does not run anything
* Use unleash() to really execute the hook function
- * @param string $fnHook
+ * @param string $hook
*/
public function requireTransparentHook( $hook ) {
$this->transparentHooks[] = $hook;
* file handler.
*
* @param File $file File object for file in question
- * @param array $param Array of parameters so far
+ * @param array $params Array of parameters so far
* @return array Parameters array with more parameters
*/
function wfExtractThumbParams( $file, $params ) {