Title: Error in AbstractDetector.php
Last modified: August 3, 2023

---

# Error in AbstractDetector.php

 *  Resolved [asandco](https://wordpress.org/support/users/asandco/)
 * (@asandco)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-in-abstractdetector-php/)
 * 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.
 *     ```wp-block-code
       <?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)

 *  Plugin Support [Kowsar Hossain](https://wordpress.org/support/users/kowsar89/)
 * (@kowsar89)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-in-abstractdetector-php/#post-16947309)
 * Thank you for your findings. We are looking into this matter.

Viewing 1 replies (of 1 total)

The topic ‘Error in AbstractDetector.php’ is closed to new replies.

 * ![](https://ps.w.org/wp-optimize/assets/icon-256x256.png?rev=1552899)
 * [WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance](https://wordpress.org/plugins/wp-optimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-optimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-optimize/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-optimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-optimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-optimize/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Kowsar Hossain](https://wordpress.org/support/users/kowsar89/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/error-in-abstractdetector-php/#post-16947309)
 * Status: resolved