Support » Plugin: WP-Optimize - Cache, Clean, Compress. » Error in AbstractDetector.php

  • Resolved asandco

    (@asandco)


    You cannot use AbstractDetector from ImageMimeType than redeclare it again it causes error in vscode saying you cannot redeclase class/interface
    the line use ImageMimeTypeGuesser\Detectors\AbstractDetector; seems to be redundant.

    <?php
    
    namespace ImageMimeTypeGuesser\Detectors;
    
    use ImageMimeTypeGuesser\Detectors\AbstractDetector;
    
    abstract class AbstractDetector
    {
        /**
         * Try to detect mime type of image
         *
         * Returns:
         * - mime type (string) (if it is in fact an image, and type could be determined)
         * - false (if it is not an image type that the server knowns about)
         * - null  (if nothing can be determined)
         *
         * @param  string  $filePath  The path to the file
         * @return string|false|null  mimetype (if it is an image, and type could be determined),
         *    false (if it is not an image type that the server knowns about)
         *    or null (if nothing can be determined)
         */
        abstract protected function doDetect($filePath);
    
        /**
         * Create an instance of this class
         *
         * @return static
         */
        public static function createInstance()
        {
            return new static();
        }
    
        /**
         * Detect mime type of file (for images only)
         *
         * Returns:
         * - mime type (string) (if it is in fact an image, and type could be determined)
         * - false (if it is not an image type that the server knowns about)
         * - null  (if nothing can be determined)
         *
         * @param  string  $filePath  The path to the file
         * @return string|false|null  mimetype (if it is an image, and type could be determined),
         *    false (if it is not an image type that the server knowns about)
         *    or null (if nothing can be determined)
         */
        public static function detect($filePath)
        {
            if (!@file_exists($filePath)) {
                return false;
            }
            return self::createInstance()->doDetect($filePath);
        }
    }
    
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.