Merge "Remove all instances of the word "iff""
[lhc/web/wiklou.git] / includes / filebackend / FileOp.php
index 80afcf2..fe83308 100644 (file)
@@ -57,14 +57,14 @@ abstract class FileOp {
        /**
         * Build a new batch file operation transaction
         *
-        * @param $backend FileBackendStore
-        * @param $params Array
+        * @param FileBackendStore $backend
+        * @param Array $params
         * @throws MWException
         */
        final public function __construct( FileBackendStore $backend, array $params ) {
                $this->backend = $backend;
                list( $required, $optional ) = $this->allowedParams();
-               // @TODO: normalizeAnyStoragePaths() calls are overzealous, use a parameter list
+               // @todo normalizeAnyStoragePaths() calls are overzealous, use a parameter list
                foreach ( $required as $name ) {
                        if ( isset( $params[$name] ) ) {
                                // Normalize paths so the paths to the same file have the same string
@@ -85,7 +85,7 @@ abstract class FileOp {
        /**
         * Normalize $item or anything in $item that is a valid storage path
         *
-        * @param $item string|array
+        * @param string $item|array
         * @return string|Array
         */
        protected function normalizeAnyStoragePaths( $item ) {
@@ -105,7 +105,7 @@ abstract class FileOp {
        /**
         * Normalize a string if it is a valid storage path
         *
-        * @param $path string
+        * @param string $path
         * @return string
         */
        protected static function normalizeIfValidStoragePath( $path ) {
@@ -119,7 +119,7 @@ abstract class FileOp {
        /**
         * Set the batch UUID this operation belongs to
         *
-        * @param $batchId string
+        * @param string $batchId
         * @return void
         */
        final public function setBatchId( $batchId ) {
@@ -129,7 +129,7 @@ abstract class FileOp {
        /**
         * Get the value of the parameter with the given name
         *
-        * @param $name string
+        * @param string $name
         * @return mixed Returns null if the parameter is not set
         */
        final public function getParam( $name ) {
@@ -240,7 +240,7 @@ abstract class FileOp {
         * This must update $predicates for each path that the op can change
         * except when a failing status object is returned.
         *
-        * @param $predicates Array
+        * @param Array $predicates
         * @return Status
         */
        final public function precheck( array &$predicates ) {
@@ -317,7 +317,7 @@ abstract class FileOp {
        /**
         * Adjust params to FileBackendStore internal file calls
         *
-        * @param $params Array
+        * @param Array $params
         * @return Array (required params list, optional params list)
         */
        protected function setFlags( array $params ) {
@@ -347,7 +347,7 @@ abstract class FileOp {
         * Also set the destExists, overwriteSameCase and sourceSha1 member variables.
         * A bad status will be returned if there is no chance it can be overwritten.
         *
-        * @param $predicates Array
+        * @param Array $predicates
         * @return Status
         */
        protected function precheckDestExistence( array $predicates ) {
@@ -384,7 +384,7 @@ abstract class FileOp {
 
        /**
         * precheckDestExistence() helper function to get the source file SHA-1.
-        * Subclasses should overwride this iff the source is not in storage.
+        * Subclasses should overwride this if the source is not in storage.
         *
         * @return string|bool Returns false on failure
         */
@@ -396,7 +396,7 @@ abstract class FileOp {
         * Check if a file will exist in storage when this operation is attempted
         *
         * @param string $source Storage path
-        * @param $predicates Array
+        * @param Array $predicates
         * @return bool
         */
        final protected function fileExists( $source, array $predicates ) {
@@ -412,7 +412,7 @@ abstract class FileOp {
         * Get the SHA-1 of a file in storage when this operation is attempted
         *
         * @param string $source Storage path
-        * @param $predicates Array
+        * @param Array $predicates
         * @return string|bool False on failure
         */
        final protected function fileSha1( $source, array $predicates ) {
@@ -438,7 +438,7 @@ abstract class FileOp {
        /**
         * Log a file operation failure and preserve any temp files
         *
-        * @param $action string
+        * @param string $action
         * @return void
         */
        final public function logFailure( $action ) {
@@ -488,9 +488,6 @@ class CreateFileOp extends FileOp {
                return $status; // safe to call attempt()
        }
 
-       /**
-        * @return Status
-        */
        protected function doAttempt() {
                if ( !$this->overwriteSameCase ) {
                        // Create the file at the destination
@@ -499,16 +496,10 @@ class CreateFileOp extends FileOp {
                return Status::newGood();
        }
 
-       /**
-        * @return bool|String
-        */
        protected function getSourceSha1Base36() {
                return wfBaseConvert( sha1( $this->params['content'] ), 16, 36, 31 );
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsChanged() {
                return array( $this->params['dst'] );
        }
@@ -519,18 +510,11 @@ class CreateFileOp extends FileOp {
  * Parameters for this operation are outlined in FileBackend::doOperations().
  */
 class StoreFileOp extends FileOp {
-       /**
-        * @return array
-        */
        protected function allowedParams() {
                return array( array( 'src', 'dst' ),
                        array( 'overwrite', 'overwriteSame', 'headers' ) );
        }
 
-       /**
-        * @param $predicates array
-        * @return Status
-        */
        protected function doPrecheck( array &$predicates ) {
                $status = Status::newGood();
                // Check if the source file exists on the file system
@@ -560,9 +544,6 @@ class StoreFileOp extends FileOp {
                return $status; // safe to call attempt()
        }
 
-       /**
-        * @return Status
-        */
        protected function doAttempt() {
                if ( !$this->overwriteSameCase ) {
                        // Store the file at the destination
@@ -571,9 +552,6 @@ class StoreFileOp extends FileOp {
                return Status::newGood();
        }
 
-       /**
-        * @return bool|string
-        */
        protected function getSourceSha1Base36() {
                wfSuppressWarnings();
                $hash = sha1_file( $this->params['src'] );
@@ -594,18 +572,11 @@ class StoreFileOp extends FileOp {
  * Parameters for this operation are outlined in FileBackend::doOperations().
  */
 class CopyFileOp extends FileOp {
-       /**
-        * @return array
-        */
        protected function allowedParams() {
                return array( array( 'src', 'dst' ),
                        array( 'overwrite', 'overwriteSame', 'ignoreMissingSource', 'headers' ) );
        }
 
-       /**
-        * @param $predicates array
-        * @return Status
-        */
        protected function doPrecheck( array &$predicates ) {
                $status = Status::newGood();
                // Check if the source file exists
@@ -637,9 +608,6 @@ class CopyFileOp extends FileOp {
                return $status; // safe to call attempt()
        }
 
-       /**
-        * @return Status
-        */
        protected function doAttempt() {
                if ( $this->overwriteSameCase ) {
                        $status = Status::newGood(); // nothing to do
@@ -656,16 +624,10 @@ class CopyFileOp extends FileOp {
                return $status;
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsRead() {
                return array( $this->params['src'] );
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsChanged() {
                return array( $this->params['dst'] );
        }
@@ -676,18 +638,11 @@ class CopyFileOp extends FileOp {
  * Parameters for this operation are outlined in FileBackend::doOperations().
  */
 class MoveFileOp extends FileOp {
-       /**
-        * @return array
-        */
        protected function allowedParams() {
                return array( array( 'src', 'dst' ),
                        array( 'overwrite', 'overwriteSame', 'ignoreMissingSource', 'headers' ) );
        }
 
-       /**
-        * @param $predicates array
-        * @return Status
-        */
        protected function doPrecheck( array &$predicates ) {
                $status = Status::newGood();
                // Check if the source file exists
@@ -721,9 +676,6 @@ class MoveFileOp extends FileOp {
                return $status; // safe to call attempt()
        }
 
-       /**
-        * @return Status
-        */
        protected function doAttempt() {
                if ( $this->overwriteSameCase ) {
                        if ( $this->params['src'] === $this->params['dst'] ) {
@@ -748,16 +700,10 @@ class MoveFileOp extends FileOp {
                return $status;
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsRead() {
                return array( $this->params['src'] );
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsChanged() {
                return array( $this->params['src'], $this->params['dst'] );
        }
@@ -768,17 +714,10 @@ class MoveFileOp extends FileOp {
  * Parameters for this operation are outlined in FileBackend::doOperations().
  */
 class DeleteFileOp extends FileOp {
-       /**
-        * @return array
-        */
        protected function allowedParams() {
                return array( array( 'src' ), array( 'ignoreMissingSource' ) );
        }
 
-       /**
-        * @param $predicates array
-        * @return Status
-        */
        protected function doPrecheck( array &$predicates ) {
                $status = Status::newGood();
                // Check if the source file exists
@@ -805,17 +744,11 @@ class DeleteFileOp extends FileOp {
                return $status; // safe to call attempt()
        }
 
-       /**
-        * @return Status
-        */
        protected function doAttempt() {
                // Delete the source file
                return $this->backend->deleteInternal( $this->setFlags( $this->params ) );
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsChanged() {
                return array( $this->params['src'] );
        }
@@ -826,17 +759,10 @@ class DeleteFileOp extends FileOp {
  * Parameters for this operation are outlined in FileBackend::doOperations().
  */
 class DescribeFileOp extends FileOp {
-       /**
-        * @return array
-        */
        protected function allowedParams() {
                return array( array( 'src' ), array( 'headers' ) );
        }
 
-       /**
-        * @param $predicates array
-        * @return Status
-        */
        protected function doPrecheck( array &$predicates ) {
                $status = Status::newGood();
                // Check if the source file exists
@@ -857,17 +783,11 @@ class DescribeFileOp extends FileOp {
                return $status; // safe to call attempt()
        }
 
-       /**
-        * @return Status
-        */
        protected function doAttempt() {
                // Update the source file's metadata
                return $this->backend->describeInternal( $this->setFlags( $this->params ) );
        }
 
-       /**
-        * @return array
-        */
        public function storagePathsChanged() {
                return array( $this->params['src'] );
        }