summaryrefslogtreecommitdiffstats
path: root/php-laminas-zendframework-bridge-rpm.patch
blob: edc77c0cf078f7e5cff904a94313c62e6ec94865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
diff -up ./src/Autoloader.php.rpm ./src/Autoloader.php
--- ./src/Autoloader.php.rpm	2022-02-23 09:04:21.000000000 +0100
+++ ./src/Autoloader.php	2022-02-23 09:07:25.289998350 +0100
@@ -3,7 +3,6 @@
 namespace Laminas\ZendFrameworkBridge;
 
 use ArrayObject;
-use Composer\Autoload\ClassLoader;
 use RuntimeException;
 
 use function array_values;
@@ -46,15 +45,9 @@ class Autoloader
     public static function load()
     {
         $loaded = new ArrayObject([]);
-        $classLoader = self::getClassLoader();
-
-        if ($classLoader === null) {
-            return;
-        }
 
         spl_autoload_register(self::createPrependAutoloader(
             RewriteRules::namespaceReverse(),
-            $classLoader,
             $loaded
         ), true, true);
 
@@ -64,28 +57,17 @@ class Autoloader
         ));
     }
 
-    private static function getClassLoader(): ?ClassLoader
-    {
-        $composerVendorDirectory = getenv('COMPOSER_VENDOR_DIR');
-        if (is_string($composerVendorDirectory)) {
-            return self::getClassLoaderFromVendorDirectory($composerVendorDirectory);
-        }
-
-        return self::getClassLoaderFromVendorDirectory(self::UPSTREAM_COMPOSER_VENDOR_DIRECTORY)
-            ?? self::getClassLoaderFromVendorDirectory(self::LOCAL_COMPOSER_VENDOR_DIRECTORY);
-    }
-
     /**
      * @param array<string,string> $namespaces
      * @return callable(string): void
      */
-    private static function createPrependAutoloader(array $namespaces, ClassLoader $classLoader, ArrayObject $loaded)
+    private static function createPrependAutoloader(array $namespaces, ArrayObject $loaded)
     {
         /**
          * @param string $class Class name to autoload
          * @return void
          */
-        return static function ($class) use ($namespaces, $classLoader, $loaded): void {
+        return static function ($class) use ($namespaces, $loaded): void {
             if (isset($loaded[$class])) {
                 return;
             }
@@ -104,7 +86,7 @@ class Autoloader
                 return;
             }
 
-            if ($classLoader->loadClass($class)) {
+            if (\Fedora\Autoloader\Autoload::loadClass($class)) {
                 $legacy = $namespaces[$check]
                     . strtr(substr($class, strlen($check)), [
                         'ApiTools' => 'Apigility',
@@ -166,20 +148,4 @@ class Autoloader
             }
         };
     }
-
-    private static function getClassLoaderFromVendorDirectory(string $composerVendorDirectory): ?ClassLoader
-    {
-        $filename = rtrim($composerVendorDirectory, '/') . '/autoload.php';
-        if (!file_exists($filename)) {
-            return null;
-        }
-
-        /** @psalm-suppress MixedAssignment */
-        $loader = include $filename;
-        if (!$loader instanceof ClassLoader) {
-            return null;
-        }
-
-        return $loader;
-    }
 }
diff -up ./src/Replacements.php.rpm ./src/Replacements.php
--- ./src/Replacements.php.rpm	2022-02-23 09:04:21.000000000 +0100
+++ ./src/Replacements.php	2022-02-23 09:06:13.102208293 +0100
@@ -15,7 +15,7 @@ class Replacements
     public function __construct(array $additionalReplacements = [])
     {
         $this->replacements = array_merge(
-            require __DIR__ . '/../config/replacements.php',
+            require __DIR__ . '/config/replacements.php',
             $additionalReplacements
         );