Don't use `phpcs:ignoreFile` to selectively ignore sniffs
[lhc/web/wiklou.git] / includes / utils / MWFileProps.php
index b8ecd4c..9d05c6a 100644 (file)
@@ -30,9 +30,9 @@ class MWFileProps {
        private $magic;
 
        /**
-        * @param MimeMagic $magic
+        * @param MimeAnalyzer $magic
         */
-       public function __construct( MimeMagic $magic ) {
+       public function __construct( MimeAnalyzer $magic ) {
                $this->magic = $magic;
        }
 
@@ -63,7 +63,7 @@ class MWFileProps {
        public function getPropsFromPath( $path, $ext ) {
                $fsFile = new FSFile( $path );
 
-               $info = FSFile::placeholderProps();
+               $info = $this->newPlaceholderProps();
                $info['fileExists'] = $fsFile->exists();
                if ( $info['fileExists'] ) {
                        $info['size'] = $fsFile->getSize(); // bytes
@@ -112,4 +112,34 @@ class MWFileProps {
 
                return $info;
        }
+
+       /**
+        * Empty place holder props for non-existing files
+        *
+        * Resulting array fields include:
+        *   - fileExists
+        *   - size (filesize in bytes)
+        *   - mime (as major/minor)
+        *   - media_type (value to be used with the MEDIATYPE_xxx constants)
+        *   - metadata (handler specific)
+        *   - sha1 (in base 36)
+        *   - width
+        *   - height
+        *   - bits (bitrate)
+        *   - file-mime
+        *   - major_mime
+        *   - minor_mime
+        *
+        * @return array
+        * @since 1.28
+        */
+       public function newPlaceholderProps() {
+               return FSFile::placeholderProps() + [
+                       'metadata' => '',
+                       'width' => 0,
+                       'height' => 0,
+                       'bits' => 0,
+                       'media_type' => MEDIATYPE_UNKNOWN
+               ];
+       }
 }