Remove PEAR support from file type detection
authorChristian Weiske <cweiske@cweiske.de>
Tue, 21 Mar 2023 18:57:23 +0000 (19:57 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 22 Mar 2023 21:21:03 +0000 (22:21 +0100)
src/phorkie/Tool/MIME/Type/PlainDetect.php

index 235046e5cd62b1a1bacaa195b62a7cd78f79a27f..b5c730d9a6097e5920e67185b709e082010406be 100644 (file)
@@ -12,22 +12,18 @@ class Tool_MIME_Type_PlainDetect extends \MIME_Type_PlainDetect
     public static function getMagicFile()
     {
         $rootdir = __DIR__ . '/../../../../../';
-        if (file_exists($rootdir . '/lib/PEAR.php')) {
-            if (!\Phar::running()) {
-                return $rootdir . '/lib/data/programming.magic';
-            } else {
-                //magic file within a .phar does not work:
-                // https://bugs.php.net/bug.php?id=67556
-                //put it outside
-                $target = '/tmp/phorkie-programming.magic';
-                if (!file_exists($target)) {
-                    copy(
-                        $rootdir . '/lib/data/programming.magic',
-                        $target
-                    );
-                }
-                return $target;
+        $magicPath = $rootdir . '/lib/cweiske/mime_type_plaindetect/data/programming.magic';
+        if (!\Phar::running()) {
+            return $magicPath;
+        } else {
+            //magic file within a .phar does not work:
+            // https://bugs.php.net/bug.php?id=67556
+            //put it outside
+            $target = '/tmp/phorkie-programming.magic';
+            if (!file_exists($target)) {
+                copy($magicPath, $target);
             }
+            return $target;
         }
         return parent::getMagicFile();
     }