/**
* Returns the file system path
*
- * @return String
+ * @return string
*/
public function getPath() {
return $this->path;
/**
* @param string $fullCont
- * @param $dirRel
+ * @param string $dirRel
* @param array $params
* @return Status
*/
/**
* Get the a bitfield of extra features supported by the backend medium
*
- * @return integer Bitfield of FileBackend::ATTR_* flags
+ * @return int Bitfield of FileBackend::ATTR_* flags
* @since 1.23
*/
public function getFeatures() {
/**
* Check if the backend medium supports a field of extra features
*
- * @return integer Bitfield of FileBackend::ATTR_* flags
+ * @return int Bitfield of FileBackend::ATTR_* flags
* @return bool
* @since 1.23
*/
* $params include:
* - src : source storage path
* - latest : use the latest available data
- * @return Array|bool Returns false on failure
+ * @return array|bool Returns false on failure
* @since 1.23
*/
abstract public function getFileXAttributes( array $params );
* @param array $params Parameters include:
* - dir : storage directory
* - topOnly : only return direct child dirs of the directory
- * @return Traversable|Array|null Returns null on failure
+ * @return Traversable|array|null Returns null on failure
* @since 1.20
*/
abstract public function getDirectoryList( array $params );
*
* @param array $params Parameters include:
* - dir : storage directory
- * @return Traversable|Array|null Returns null on failure
+ * @return Traversable|array|null Returns null on failure
* @since 1.20
*/
final public function getTopDirectoryList( array $params ) {
* - dir : storage directory
* - topOnly : only return direct child files of the directory (since 1.20)
* - adviseStat : set to true if stat requests will be made on the files (since 1.22)
- * @return Traversable|Array|null Returns null on failure
+ * @return Traversable|array|null Returns null on failure
*/
abstract public function getFileList( array $params );
* @param array $params Parameters include:
* - dir : storage directory
* - adviseStat : set to true if stat requests will be made on the files (since 1.22)
- * @return Traversable|Array|null Returns null on failure
+ * @return Traversable|array|null Returns null on failure
* @since 1.20
*/
final public function getTopFileList( array $params ) {
/**
* @see FileBackendStore::doPrepare()
- * @param $container
+ * @param string $container
* @param string $dir
* @param array $params
* @return Status
/**
* @see FileBackendStore::doSecure()
- * @param $container
+ * @param string $container
* @param string $dir
* @param array $params
* @return Status
/**
* @see FileBackendStore::doPublish()
- * @param $container
+ * @param string $container
* @param string $dir
* @param array $params
* @return Status
/**
* @see FileBackendStore::doClean()
- * @param $container
+ * @param string $container
* @param string $dir
* @param array $params
* @return Status
* @param string $container Resolved container name
* @param string $dir Resolved path relative to container
* @param array $params
- * @return Traversable|Array|null Returns null on failure
+ * @return Traversable|array|null Returns null on failure
*/
abstract public function getDirectoryListInternal( $container, $dir, array $params );
* @param string $container Resolved container name
* @param string $dir Resolved path relative to container
* @param array $params
- * @return Traversable|Array|null Returns null on failure
+ * @return Traversable|array|null Returns null on failure
*/
abstract public function getFileListInternal( $container, $dir, array $params );
* Check if this operation changes files listed in $paths
*
* @param array $deps Prior path reads/writes; format of FileOp::newPredicates()
- * @return boolean
+ * @return bool
*/
final public function dependsOn( array $deps ) {
foreach ( $this->storagePathsChanged() as $path ) {
*
* @param string $fullCont
* @param string $type ('info' for a list of object detail maps, 'names' for names only)
- * @param integer $limit
+ * @param int $limit
* @param string|null $after
* @param string|null $prefix
* @param string|null $delim
* @param string $func
* @param array $params
* @param string $err Error string
- * @param integer $code HTTP status
+ * @param int $code HTTP status
* @param string $desc HTTP status description
*/
public function onError( $status, $func, array $params, $err = '', $code = 0, $desc = '' ) {
* Get an array of file change log entries.
* A starting change ID and/or limit can be specified.
*
- * @param $start integer Starting change ID or null
- * @param $limit integer Maximum number of items to return
- * @param &$next string Updated to the ID of the next entry.
+ * @param int $start Starting change ID or null
+ * @param int $limit Maximum number of items to return
+ * @param string &$next Updated to the ID of the next entry.
* @return array List of associative arrays, each having:
* id : unique, monotonic, ID for this change
* batch_uuid : UUID for an operation batch
* Checks if the DB has not recently had connection/query errors.
* This just avoids wasting time on doomed connection attempts.
*
- * @param $lockDb string
+ * @param string $lockDb
* @return bool
*/
protected function cacheCheckFailures( $lockDb ) {
/** @var FileBackend */
protected $backend;
- /** @var Array Map of zones to config */
+ /** @var array Map of zones to config */
protected $zones = array();
/** @var string URL of thumb.php */
* from the URL path, one can configure thumb_handler.php to recognize a special path on the
* same host name as the wiki that is used for viewing thumbnails.
*
- * @param string $zone one of: public, deleted, temp, thumb
+ * @param string $zone One of: public, deleted, temp, thumb
* @return string|bool String or false
*/
public function getZoneHandlerUrl( $zone ) {
*
* @param string $src Source file system path, storage path, or virtual URL
* @param string $dst Virtual URL or storage path
- * @param Array|string|null $options An array consisting of a key named headers
+ * @param array|string|null $options An array consisting of a key named headers
* listing extra headers. If a string, taken as content-disposition header.
* (Support for array of options new in 1.23)
* @return FileRepoStatus
* @param mixed $srcRel Relative path for the file to be deleted
* @param mixed $archiveRel Relative path for the archive location.
* Relative to a private archive directory.
- * @return FileRepoStatus object
+ * @return FileRepoStatus
*/
public function delete( $srcRel, $archiveRel ) {
$this->assertWritableRepo(); // fail out if read-only
* Properties should ultimately be obtained via FSFile::getProps().
*
* @param string $virtualUrl
- * @return Array
+ * @return array
*/
public function getFileProps( $virtualUrl ) {
$path = $this->resolveToStoragePath( $virtualUrl );
* Get the size of a file with a given virtual URL/storage path
*
* @param string $virtualUrl
- * @return integer|bool False on failure
+ * @return int|bool False on failure
*/
public function getFileSize( $virtualUrl ) {
$path = $this->resolveToStoragePath( $virtualUrl );
/**
* Determine if a relative path is valid, i.e. not blank or involving directory traveral
*
- * @param $filename string
+ * @param string $filename
* @return bool
*/
public function validateFilename( $filename ) {
/**
* Create a new fatal error
*
- * @param $message
+ * @param string $message
* @return FileRepoStatus
*/
public function newFatal( $message /*, parameters...*/ ) {
* Get the portion of the file that contains the origin file name.
* If that name is too long, then the name "thumbnail.<ext>" will be given.
*
- * @param $name string
+ * @param string $name
* @return string
*/
public function nameForThumb( $name ) {
/**
* @param FileRepo|bool $repo Default: false
- * @param $value
+ * @param mixed $value
* @return FileRepoStatus
*/
static function newGood( $repo = false, $value = null ) {
private $mQueryCache = array();
/**
- * @param $info array|null
+ * @param array|null $info
*/
function __construct( $info ) {
global $wgLocalFileRepo;
* If the url has been requested today, get it from cache
* Otherwise retrieve remote thumb url, check for local file.
*
- * @param string $name is a dbkey form of a title
+ * @param string $name Is a dbkey form of a title
* @param int $width
* @param int $height
* @param string $params Other rendering parameters (page number, etc)
* @see FileRepo::getZoneUrl()
* @param string $zone
* @param string|null $ext Optional file extension
- * @return String
+ * @return string
*/
function getZoneUrl( $zone, $ext = null ) {
switch ( $zone ) {
* @param string $url
* @param string $timeout
* @param array $options
- * @return bool|String
+ * @return bool|string
*/
public static function httpGet( $url, $timeout = 'default', $options = array() ) {
$options['timeout'] = $timeout;
* Construct a group of file repositories.
*
* @param array $localInfo Associative array for local repo's info
- * @param array $foreignInfo of repository info arrays.
+ * @param array $foreignInfo Array of repository info arrays.
* Each info array is an associative array with the 'class' member
* giving the class name. The entire array is passed to the repository
* constructor as the first parameter.
* Search repositories for an image.
* You can also use wfFindFile() to do this.
*
- * @param $title Title|string Title object or string
+ * @param Title|string $title Title object or string
* @param array $options Associative array of options:
* time: requested time for an archived image, or false for the
* current version. An image object will be returned which was
* @return array Map of (file name => File objects) for matches
*
* @param array $inputItems
- * @param integer $flags
+ * @param int $flags
* @return array
*/
function findFiles( array $inputItems, $flags = 0 ) {
/**
* Interface for FileRepo::checkRedirect()
- * @param $title Title
+ * @param Title $title
* @return bool
*/
function checkRedirect( Title $title ) {
* Find an instance of the file with this key, created at the specified time
* Returns false if the file does not exist.
*
- * @param string $hash base 36 SHA-1 hash
+ * @param string $hash Base 36 SHA-1 hash
* @param array $options Option array, same as findFile()
- * @return File object or false if it is not found
+ * @return File|bool File object or false if it is not found
*/
function findFileFromKey( $hash, $options = array() ) {
if ( !$this->reposInitialised ) {
* Find all instances of files with this key
*
* @param string $hash base 36 SHA-1 hash
- * @return Array of File objects
+ * @return array Array of File objects
*/
function findBySha1( $hash ) {
if ( !$this->reposInitialised ) {
* Find all instances of files with this keys
*
* @param array $hashes base 36 SHA-1 hashes
- * @return array of array of File objects
+ * @return array Array of array of File objects
*/
function findBySha1s( array $hashes ) {
if ( !$this->reposInitialised ) {
* format does not support that sort of thing, returns
* an empty array.
*
- * @return Array
+ * @return array
* @since 1.23
*/
public function getAvailableLanguages() {
* In files that support multiple language, what is the default language
* to use if none specified.
*
- * @return String lang code, or null if filetype doesn't support multiple languages.
+ * @return string Lang code, or null if filetype doesn't support multiple languages.
* @since 1.23
*/
public function getDefaultRenderLanguage() {
* Use File::THUMB_FULL_NAME to always get a name like "<params>-<source>".
* Otherwise, the format may be "<params>-<source>" or "<params>-thumbnail.<ext>".
*
- * @param array $params handler-specific parameters
+ * @param array $params Handler-specific parameters
* @param int $flags Bitfield that supports THUMB_* constants
* @return string
*/
/**
* Transform a media file
*
- * @param array $params an associative array of handler-specific parameters.
+ * @param array $params An associative array of handler-specific parameters.
* Typical keys are width, height and page.
* @param int $flags A bitfield, may contain self::RENDER_NOW to force rendering
* @return MediaTransformOutput|bool False on failure
*
* STUB
* @param int $limit Limit of rows to return
- * @param string $start timestamp Only revisions older than $start will be returned
- * @param string $end timestamp Only revisions newer than $end will be returned
+ * @param string $start Only revisions older than $start will be returned
+ * @param string $end Only revisions newer than $end will be returned
* @param bool $inc Include the endpoints of the time range
*
* @return array
/**
* Get the path of an archived file relative to the public zone root
*
- * @param bool|string $suffix if not false, the name of an archived thumbnail file
+ * @param bool|string $suffix If not false, the name of an archived thumbnail file
*
* @return string
*/
* Get the path, relative to the thumbnail zone root, of the
* thumbnail directory or a particular file if $suffix is specified
*
- * @param bool|string $suffix if not false, the name of a thumbnail file
+ * @param bool|string $suffix If not false, the name of a thumbnail file
* @return string
*/
function getThumbRel( $suffix = false ) {
* Get the path, relative to the thumbnail zone root, for an archived file's thumbs directory
* or a specific thumb if the $suffix is given.
*
- * @param string $archiveName the timestamped name of an archived image
- * @param bool|string $suffix if not false, the name of a thumbnail file
+ * @param string $archiveName The timestamped name of an archived image
+ * @param bool|string $suffix If not false, the name of a thumbnail file
* @return string
*/
function getArchiveThumbRel( $archiveName, $suffix = false ) {
/**
* Get the path of the archived file.
*
- * @param bool|string $suffix if not false, the name of an archived file.
+ * @param bool|string $suffix If not false, the name of an archived file.
* @return string
*/
function getArchivePath( $suffix = false ) {
/**
* Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified
*
- * @param string $archiveName the timestamped name of an archived image
- * @param bool|string $suffix if not false, the name of a thumbnail file
+ * @param string $archiveName The timestamped name of an archived image
+ * @param bool|string $suffix If not false, the name of a thumbnail file
* @return string
*/
function getArchiveThumbPath( $archiveName, $suffix = false ) {
/**
* Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified
*
- * @param string $archiveName the timestamped name of an archived image
+ * @param string $archiveName The timestamped name of an archived image
* @param bool|string $suffix If not false, the name of a thumbnail file
* @return string
*/
/**
* Get the URL of the zone directory, or a particular file if $suffix is specified
*
- * @param string $zone name of requested zone
+ * @param string $zone Name of requested zone
* @param bool|string $suffix If not false, the name of a file in zone
* @return string path
*/
/**
* Get the URL of the thumbnail directory, or a particular file if $suffix is specified
*
- * @param bool|string $suffix if not false, the name of a thumbnail file
+ * @param bool|string $suffix If not false, the name of a thumbnail file
* @return string path
*/
function getThumbUrl( $suffix = false ) {
* Record a file upload in the upload log and the image table
* STUB
* Overridden by LocalFile
- * @param $oldver
- * @param $desc
+ * @param string $oldver
+ * @param string $desc
* @param string $license
* @param string $copyStatus
* @param string $source
* Options to $options include:
* - headers : name/value map of HTTP headers to use in response to GET/HEAD requests
*
- * @param string $srcPath local filesystem path to the source image
+ * @param string $srcPath Local filesystem path to the source image
* @param int $flags A bitwise combination of:
* File::DELETE_SOURCE Delete the source file, i.e. move rather than copy
* @param array $options Optional additional parameters
* Is this file a "deleted" file in a private archive?
* STUB
*
- * @param int $field one of DELETED_* bitfield constants
+ * @param int $field One of DELETED_* bitfield constants
* @return bool
*/
function isDeleted( $field ) {
* and logging are caller's responsibility
*
* @param Title $target New file name
- * @return FileRepoStatus object.
+ * @return FileRepoStatus
*/
function move( $target ) {
$this->readOnlyError();
*
* @param string $reason
* @param bool $suppress Hide content from sysops?
- * @return bool on success, false on some kind of failure
+ * @return bool Boolean on success, false on some kind of failure
* STUB
* Overridden by LocalFile
*/
*
* May throw database exceptions on error.
*
- * @param array $versions set of record ids of deleted items to restore,
+ * @param array $versions Set of record ids of deleted items to restore,
* or empty to restore all revisions.
- * @param bool $unsuppress remove restrictions on content upon restoration?
- * @return int|bool the number of file revisions restored if successful,
+ * @param bool $unsuppress Remove restrictions on content upon restoration?
+ * @return int|bool The number of file revisions restored if successful,
* or false on failure
* STUB
* Overridden by LocalFile
/**
* Get an associative array containing information about a file in the local filesystem.
*
- * @param string $path absolute local filesystem path
+ * @param string $path Absolute local filesystem path
* @param string|bool $ext The file extension, or true to extract it from
* the filename. Set it to false to ignore the extension.
*
* 160 log 2 / log 36 = 30.95, so the 160-bit hash fills 31 digits in base 36
* fairly neatly.
*
- * @param $path string
+ * @param string $path
* @return bool|string False on failure
* @deprecated since 1.19
*/
protected $repoClass = 'ForeignApiRepo';
/**
- * @param $title
+ * @param Title|string|bool $title
* @param ForeignApiRepo $repo
- * @param $info
+ * @param array $info
* @param bool $exists
*/
function __construct( $title, $repo, $info, $exists = false ) {
}
/**
- * @return null|String
+ * @return null|string
*/
function getSha1() {
return isset( $this->mInfo['sha1'] )
}
/**
- * @param $oldver
- * @param $desc string
- * @param $license string
- * @param $copyStatus string
- * @param $source string
- * @param $watch bool
- * @param $timestamp bool|string
- * @param $user User object or null to use $wgUser
+ * @param string $oldver
+ * @param string $desc
+ * @param string $license
+ * @param string $copyStatus
+ * @param string $source
+ * @param bool $watch
+ * @param bool|string $timestamp
+ * @param User $user User object or null to use $wgUser
* @return bool
* @throws MWException
*/
*
* @param Title $title
* @param FileRepo $repo
- * @param $unused
+ * @param null $unused
*
* @return LocalFile
*/
/**
* Constructor.
* Do not call this except from inside a repo class.
+ * @param Title $title
+ * @param FileRepo $repo
*/
function __construct( $title, $repo ) {
parent::__construct( $title, $repo );
}
/**
- * @param $prefix string
+ * @param string $prefix
* @return array
*/
function getCacheFields( $prefix = 'img_' ) {
/**
* Decode a row from the database (either object or array) to an array
* with timestamps and MIME types decoded, and the field prefix removed.
- * @param $row
- * @param $prefix string
+ * @param object $row
+ * @param string $prefix
* @throws MWException
* @return array
*/
/**
* Load file metadata from a DB result row
+ *
+ * @param object $row
+ * @param string $prefix
*/
function loadFromRow( $row, $prefix = 'img_' ) {
$this->dataLoaded = true;
/**
* Load file metadata from cache or DB, unless already loaded
- * @param integer $flags
+ * @param int $flags
*/
function load( $flags = 0 ) {
if ( !$this->dataLoaded ) {
*
* If 'mime' is given, it will be split into major_mime/minor_mime.
* If major_mime/minor_mime are given, $this->mime will also be set.
+ *
+ * @param array $info
*/
function setProps( $info ) {
$this->dataLoaded = true;
* @todo Do we still care about this? Perhaps a maintenance script
* can be made instead. Enabling this code results in a serious
* RTT regression for wikis without 404 handling.
+ *
+ * @param string $thumbName
*/
function migrateThumbFile( $thumbName ) {
/* Old code for bug 2532
* current time
* @param User|null $user User object or null to use $wgUser
*
- * @return FileRepoStatus object. On success, the value member contains the
+ * @return FileRepoStatus On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false,
*
* May throw database exceptions on error.
*
- * @param array $versions set of record ids of deleted items to restore,
+ * @param array $versions Set of record ids of deleted items to restore,
* or empty to restore all revisions.
* @param bool $unsuppress
* @return FileRepoStatus
/**
* Removes non-existent files from a deletion batch.
- * @param $batch array
+ * @param array $batch
* @return array
*/
function removeNonexistentFiles( $batch ) {
const SESSION_STATUS_KEY = 'wsUploadStatusData';
/**
- * @param $error int
+ * @param int $error
* @return string
*/
public function getVerificationErrorCode( $error ) {
* identifying the missing permission.
* Can be overridden by subclasses.
*
- * @param $user User
+ * @param User $user
* @return bool
*/
public static function isAllowed( $user ) {
/**
* Create a form of UploadBase depending on wpSourceType and initializes it
*
- * @param $request WebRequest
- * @param $type
- * @return null
+ * @param WebRequest $request
+ * @param string|null $type
+ * @return null|UploadBase
*/
public static function createFromRequest( &$request, $type = null ) {
$type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
/**
* Check whether a request if valid for this handler
- * @param $request
+ * @param WebRequest $request
* @return bool
*/
public static function isValidRequest( $request ) {
/**
* Initialize the path information
- * @param string $name the desired destination name
- * @param string $tempPath the temporary path
- * @param int $fileSize the file size
+ * @param string $name The desired destination name
+ * @param string $tempPath The temporary path
+ * @param int $fileSize The file size
* @param bool $removeTempFile (false) remove the temporary file?
* @throws MWException
*/
/**
* Initialize from a WebRequest. Override this in a subclass.
+ *
+ * @param WebRequest $request
*/
abstract public function initializeFromRequest( &$request );
/**
* Return the file size
- * @return integer
+ * @return int
*/
public function getFileSize() {
return $this->mFileSize;
}
/**
- * @param string $srcPath the source path
- * @return string|bool the real path if it was a virtual URL Returns false on failure
+ * @param string $srcPath The source path
+ * @return string|bool The real path if it was a virtual URL Returns false on failure
*/
function getRealPath( $srcPath ) {
wfProfileIn( __METHOD__ );
/**
* Verify that the name is valid and, if necessary, that we can overwrite
*
- * @return mixed true if valid, otherwise and array with 'status'
+ * @return mixed True if valid, otherwise and array with 'status'
* and other keys
- **/
+ */
public function validateName() {
$nt = $this->getTitle();
if ( is_null( $nt ) ) {
*
* @note Only checks that it is not an evil mime. The does it have
* correct extension given its mime type check is in verifyFile.
- * @param string $mime representing the mime
- * @return mixed true if the file is verified, an array otherwise
+ * @param string $mime Representing the mime
+ * @return mixed True if the file is verified, an array otherwise
*/
protected function verifyMimeType( $mime ) {
global $wgVerifyMimeType;
/**
* Verifies that it's ok to include the uploaded file
*
- * @return mixed true of the file is verified, array otherwise.
+ * @return mixed True of the file is verified, array otherwise.
*/
protected function verifyFile() {
global $wgVerifyMimeType;
* Runs the blacklist checks, but not any checks that may
* assume the entire file is present.
*
- * @return Mixed true for valid or array with error message key.
+ * @return mixed True for valid or array with error message key.
*/
protected function verifyPartialFile() {
global $wgAllowJavaUploads, $wgDisableUploadScriptChecks;
/**
* Callback for ZipDirectoryReader to detect Java class files.
+ *
+ * @param array $entry
*/
function zipEntryCallback( $entry ) {
$names = array( $entry['name'] );
/**
* Alias for verifyTitlePermissions. The function was originally 'verifyPermissions'
* but that suggests it's checking the user, when it's really checking the title + user combination.
- * @param $user User object to verify the permissions against
+ * @param User $user User object to verify the permissions against
* @return mixed An array as returned by getUserPermissionsErrors or true
- * in case the user has proper permissions.
+ * in case the user has proper permissions.
*/
public function verifyPermissions( $user ) {
return $this->verifyTitlePermissions( $user );
* isAllowed() should be called as well for generic is-user-blocked or
* can-user-upload checking.
*
- * @param $user User object to verify the permissions against
+ * @param User $user object to verify the permissions against
* @return mixed An array as returned by getUserPermissionsErrors or true
- * in case the user has proper permissions.
+ * in case the user has proper permissions.
*/
public function verifyTitlePermissions( $user ) {
/**
*
* This should not assume that mTempPath is set.
*
- * @return Array of warnings
+ * @return array Array of warnings
*/
public function checkWarnings() {
global $wgLang;
* Really perform the upload. Stores the file in the local repo, watches
* if necessary and runs the UploadComplete hook.
*
- * @param $comment
- * @param $pageText
- * @param $watch
- * @param $user User
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
*
- * @return Status indicating the whether the upload succeeded.
+ * @return Status Indicating the whether the upload succeeded.
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
wfProfileIn( __METHOD__ );
* This method returns the file object, which also has a 'fileKey' property which can be passed through a form or
* API request to find this stashed file again.
*
- * @param $user User
- * @return UploadStashFile stashed file
+ * @param User $user
+ * @return UploadStashFile Stashed file
*/
public function stashFile( User $user = null ) {
// was stashSessionFile
/**
* Stash a file in a temporary directory, returning a key which can be used to find the file again. See stashFile().
*
- * @return String: file key
+ * @return string File key
*/
public function stashFileGetKey() {
return $this->stashFile()->getFileKey();
/**
* alias for stashFileGetKey, for backwards compatibility
*
- * @return String: file key
+ * @return string File key
*/
public function stashSession() {
return $this->stashFileGetKey();
* earlier pseudo-'extensions' to determine type and execute
* scripts, so the blacklist needs to check them all.
*
- * @param $filename string
+ * @param string $filename
* @return array
*/
public static function splitExtensions( $filename ) {
* Perform case-insensitive match against a list of file extensions.
* Returns true if the extension is in the list.
*
- * @param $ext String
- * @param $list Array
- * @return Boolean
+ * @param string $ext
+ * @param array $list
+ * @return bool
*/
public static function checkFileExtension( $ext, $list ) {
return in_array( strtolower( $ext ), $list );
* Perform case-insensitive match against a list of file extensions.
* Returns an array of matching extensions.
*
- * @param $ext Array
- * @param $list Array
- * @return Boolean
+ * @param array $ext
+ * @param array $list
+ * @return bool
*/
public static function checkFileExtensionList( $ext, $list ) {
return array_intersect( array_map( 'strtolower', $ext ), $list );
/**
* Checks if the mime type of the uploaded file matches the file extension.
*
- * @param string $mime the mime type of the uploaded file
- * @param string $extension the filename extension that the file is to be served with
- * @return Boolean
+ * @param string $mime The mime type of the uploaded file
+ * @param string $extension The filename extension that the file is to be served with
+ * @return bool
*/
public static function verifyExtension( $mime, $extension ) {
$magic = MimeMagic::singleton();
* potentially harmful. The present implementation will produce false
* positives in some situations.
*
- * @param string $file pathname to the temporary upload file
- * @param string $mime the mime type of the file
- * @param string $extension the extension of the file
- * @return Boolean: true if the file contains something looking like embedded scripts
+ * @param string $file Pathname to the temporary upload file
+ * @param string $mime The mime type of the file
+ * @param string $extension The extension of the file
+ * @return bool True if the file contains something looking like embedded scripts
*/
public static function detectScript( $file, $mime, $extension ) {
global $wgAllowTitlesInSVG;
* Check a whitelist of xml encodings that are known not to be interpreted differently
* by the server's xml parser (expat) and some common browsers.
*
- * @param string $file pathname to the temporary upload file
- * @return Boolean: true if the file contains an encoding that could be misinterpreted
+ * @param string $file Pathname to the temporary upload file
+ * @return bool True if the file contains an encoding that could be misinterpreted
*/
public static function checkXMLEncodingMissmatch( $file ) {
global $wgSVGMetadataCutoff;
}
/**
- * @param $filename string
- * @return mixed false of the file is verified (does not contain scripts), array otherwise.
+ * @param string $filename
+ * @return mixed False of the file is verified (does not contain scripts), array otherwise.
*/
protected function detectScriptInSvg( $filename ) {
$this->mSVGNSError = false;
/**
* Callback to filter SVG Processing Instructions.
- * @param $target string processing instruction name
- * @param $data string processing instruction attribute and value
+ * @param string $target processing instruction name
+ * @param string $data processing instruction attribute and value
* @return bool (true if the filter identified something bad)
*/
public static function checkSvgPICallback( $target, $data ) {
/**
* @todo Replace this with a whitelist filter!
- * @param $element string
- * @param $attribs array
+ * @param string $element
+ * @param array $attribs
* @return bool
*/
public function checkSvgScriptCallback( $element, $attribs ) {
/**
* Divide the element name passed by the xml parser to the callback into URI and prifix.
- * @param $name string
- * @return array containing the namespace URI and prefix
+ * @param string $name
+ * @return array Containing the namespace URI and prefix
*/
private static function splitXmlNamespace( $element ) {
// 'http://www.w3.org/2000/svg:script' -> array( 'http://www.w3.org/2000/svg', 'script' )
}
/**
- * @param $name string
+ * @param string $name
* @return string
*/
private function stripXmlNamespace( $name ) {
* This relies on the $wgAntivirus and $wgAntivirusSetup variables.
* $wgAntivirusRequired may be used to deny upload if the scan fails.
*
- * @param string $file pathname to the temporary upload file
- * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
- * or a string containing feedback from the virus scanner if a virus was found.
- * If textual feedback is missing but a virus was found, this function returns true.
+ * @param string $file Pathname to the temporary upload file
+ * @return mixed False if not virus is found, NULL if the scan fails or is disabled,
+ * or a string containing feedback from the virus scanner if a virus was found.
+ * If textual feedback is missing but a virus was found, this function returns true.
*/
public static function detectVirus( $file ) {
global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired, $wgOut;
* Check if there's an overwrite conflict and, if so, if restrictions
* forbid this user from performing the upload.
*
- * @param $user User
+ * @param User $user
*
- * @return mixed true on success, array on failure
+ * @return mixed True on success, array on failure
*/
private function checkOverwrite( $user ) {
// First check whether the local file can be overwritten
/**
* Check if a user is the last uploader
*
- * @param $user User object
- * @param string $img image name
- * @return Boolean
+ * @param User $user
+ * @param string $img Image name
+ * @return bool
*/
public static function userCanReUpload( User $user, $img ) {
if ( $user->isAllowed( 'reupload' ) ) {
* - File exists with normalized extension
* - The file looks like a thumbnail and the original exists
*
- * @param $file File The File object to check
+ * @param File $file The File object to check
* @return mixed False if the file does not exists, else an array
*/
public static function getExistsWarning( $file ) {
/**
* Helper function that checks whether the filename looks like a thumbnail
- * @param $filename string
+ * @param string $filename
* @return bool
*/
public static function isThumbName( $filename ) {
/**
* Get a list of blacklisted filename prefixes from [[MediaWiki:Filename-prefix-blacklist]]
*
- * @return array list of prefixes
+ * @return array List of prefixes
*/
public static function getFilenamePrefixBlacklist() {
$blacklist = array();
* 'metadata' was requested. Oddly, we have to pass the "result" object down just so it can do that
* with the appropriate format, presumably.
*
- * @param $result ApiResult:
- * @return Array: image info
+ * @param ApiResult $result
+ * @return array Image info
*/
public function getImageInfo( $result ) {
$file = $this->getLocalFile();
}
/**
- * @param $error array
+ * @param array $error
* @return Status
*/
public function convertVerifyErrorToStatus( $error ) {
}
/**
- * @param $forType null|string
+ * @param null|string $forType
* @return int
*/
public static function getMaxUploadSize( $forType = null ) {
/**
* Get the current status of a chunked upload (used for polling).
* The status will be read from the *current* user session.
- * @param $statusKey string
- * @return Array|bool
+ * @param string $statusKey
+ * @return array|bool
*/
public static function getSessionStatus( $statusKey ) {
return isset( $_SESSION[self::SESSION_STATUS_KEY][$statusKey] )
/**
* Set the current status of a chunked upload (used for polling).
* The status will be stored in the *current* user session.
- * @param $statusKey string
- * @param $value array|false
+ * @param string $statusKey
+ * @param array|bool $value
* @return void
*/
public static function setSessionStatus( $statusKey, $value ) {
/**
* Setup local pointers to stash, repo and user (similar to UploadFromStash)
*
- * @param $user User|null Default: null
- * @param $stash UploadStash|bool Default: false
- * @param $repo FileRepo|bool Default: false
+ * @param User|null $user Default: null
+ * @param UploadStash|bool $stash Default: false
+ * @param FileRepo|bool $repo Default: false
*/
public function __construct( $user = null, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
/**
* Calls the parent stashFile and updates the uploadsession table to handle "chunks"
*
+ * @param User|null $user
* @return UploadStashFile stashed file
*/
public function stashFile( User $user = null ) {
/**
* Continue chunk uploading
+ *
+ * @param string $name
+ * @param string $key
+ * @param WebRequestUpload $webRequestUpload
*/
public function continueChunks( $name, $key, $webRequestUpload ) {
$this->mFileKey = $key;
/**
* Perform the upload, then remove the temp copy afterward
- * @param $comment string
- * @param $pageText string
- * @param $watch bool
- * @param $user User
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
* @return Status
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
/**
* Returns the virtual chunk location:
- * @param $index
+ * @param int $index
* @return string
*/
function getVirtualChunkLocation( $index ) {
/**
* Get the current Chunk index
- * @return Integer index of the current chunk
+ * @return int Index of the current chunk
*/
private function getChunkIndex() {
if ( $this->mChunkIndex !== null ) {
/**
* Gets the current offset in fromt the stashedupload table
- * @return Integer current byte offset of the chunk file set
+ * @return int Current byte offset of the chunk file set
*/
private function getOffset() {
if ( $this->mOffset !== null ) {
/**
* Output the chunk to disk
*
- * @param $chunkPath string
+ * @param string $chunkPath
* @throws UploadChunkFileException
* @return FileRepoStatus
*/
protected $mUpload = null;
/**
- * @param $request WebRequest
+ * @param WebRequest $request
*/
function initializeFromRequest( &$request ) {
$upload = $request->getUpload( 'wpUploadFile' );
/**
* Initialize from a filename and a WebRequestUpload
- * @param $name
- * @param $webRequestUpload
+ * @param string $name
+ * @param WebRequestUpload $webRequestUpload
*/
function initialize( $name, $webRequestUpload ) {
$this->mUpload = $webRequestUpload;
}
/**
- * @param $request
+ * @param WebRequest $request
* @return bool
*/
static function isValidRequest( $request ) {
* user is not allowed, return the name of the user right as a string. If
* the user is allowed, have the parent do further permissions checking.
*
- * @param $user User
+ * @param User $user
*
* @return bool|string
*/
* The domains in the whitelist can include wildcard characters (*) in place
* of any of the domain levels, e.g. '*.flickr.com' or 'upload.*.gov.uk'.
*
- * @param $url string
+ * @param string $url
* @return bool
*/
public static function isAllowedHost( $url ) {
/**
* Checks whether the URL is not allowed.
*
- * @param $url string
+ * @param string $url
* @return bool
*/
public static function isAllowedUrl( $url ) {
/**
* Entry point for API upload
*
- * @param $name string
- * @param $url string
- * @param $async mixed Whether the download should be performed
+ * @param string $name
+ * @param string $url
+ * @param bool|string $async Whether the download should be performed
* asynchronous. False for synchronous, async or async-leavemessage for
* asynchronous download.
* @throws MWException
/**
* Entry point for SpecialUpload
- * @param $request WebRequest object
+ * @param WebRequest $request
*/
public function initializeFromRequest( &$request ) {
$desiredDestName = $request->getText( 'wpDestFile' );
}
/**
- * @param $request WebRequest object
+ * @param WebRequest $request
* @return bool
*/
public static function isValidRequest( $request ) {
/**
* Download the file (if not async)
*
- * @param Array $httpOptions Array of options for MWHttpRequest. Ignored if async.
+ * @param array $httpOptions Array of options for MWHttpRequest. Ignored if async.
* This could be used to override the timeout on the http request.
* @return Status
*/
/**
* Callback: save a chunk of the result of a HTTP request to the temporary file
*
- * @param $req mixed
- * @param $buffer string
- * @return int number of bytes handled
+ * @param mixed $req
+ * @param string $buffer
+ * @return int Number of bytes handled
*/
public function saveTempFileChunk( $req, $buffer ) {
$nbytes = fwrite( $this->mTmpHandle, $buffer );
* Download the file, save it to the temporary file and update the file
* size and set $mRemoveTempFile to true.
*
- * @param Array $httpOptions Array of options for MWHttpRequest
+ * @param array $httpOptions Array of options for MWHttpRequest
* @return Status
*/
protected function reallyFetchFile( $httpOptions = array() ) {
/**
* Wrapper around the parent function in order to defer checking warnings
* until the file really has been fetched.
- * @return Array
+ * @return array
*/
public function checkWarnings() {
if ( $this->mAsync ) {
/**
* Wrapper around the parent function in order to defer checking protection
* until we are sure that the file can actually be uploaded
- * @param $user User
+ * @param User $user
* @return bool|mixed
*/
public function verifyTitlePermissions( $user ) {
/**
* Wrapper around the parent function in order to defer uploading to the
* job queue for asynchronous uploads
- * @param $comment string
- * @param $pageText string
- * @param $watch bool
- * @param $user User
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
* @return Status
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
}
/**
- * @param $comment
- * @param $pageText
- * @param $watch
- * @param $user User
- * @return String
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
+ * @return string
*/
protected function insertJob( $comment, $pageText, $watch, $user ) {
$sessionKey = $this->stashSession();
* Designed to be compatible with the session stashing code in UploadBase
* (should replace it eventually).
*
- * @param $repo FileRepo
- * @param $user User (default null)
+ * @param FileRepo $repo
+ * @param User $user (default null)
*/
public function __construct( FileRepo $repo, $user = null ) {
// this might change based on wiki's configuration.
* Get a file and its metadata from the stash.
* The noAuth param is a bit janky but is required for automated scripts which clean out the stash.
*
- * @param string $key key under which file information is stored
- * @param $noAuth Boolean (optional) Don't check authentication. Used by maintenance scripts.
+ * @param string $key Key under which file information is stored
+ * @param bool $noAuth (optional) Don't check authentication. Used by maintenance scripts.
* @throws UploadStashFileNotFoundException
* @throws UploadStashNotLoggedInException
* @throws UploadStashWrongOwnerException
* Getter for file metadata.
*
* @param string $key key under which file information is stored
- * @return Array
+ * @return array
*/
public function getMetadata( $key ) {
$this->getFile( $key );
* Getter for fileProps
*
* @param string $key key under which file information is stored
- * @return Array
+ * @return array
*/
public function getFileProps( $key ) {
$this->getFile( $key );
* Does not clean up files in the repo, just the record of them.
*
* @throws UploadStashNotLoggedInException
- * @return bool success
+ * @return bool Success
*/
public function clear() {
if ( !$this->isLoggedIn ) {
* List all files in the stash.
*
* @throws UploadStashNotLoggedInException
- * @return Array
+ * @return array
*/
public function listFiles() {
if ( !$this->isLoggedIn ) {
* with an extension.
* XXX this is somewhat redundant with the checks that ApiUpload.php does with incoming
* uploads versus the desired filename. Maybe we can get that passed to us...
- * @param $path
+ * @param string $path
* @throws UploadStashFileException
* @return string
*/
*
* @param string $key
* @param int $readFromDB Constant (default: DB_SLAVE)
- * @return boolean
+ * @return bool
*/
protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
// populate $fileMetadata[$key]