diff --git a/CHANGELOG-3.0.md b/CHANGELOG-3.0.md index 33459e14e..7359619ae 100644 --- a/CHANGELOG-3.0.md +++ b/CHANGELOG-3.0.md @@ -66,6 +66,7 @@ composer analyse - [#4874](https://github.com/hyperf/hyperf/pull/4874) Use `wait` instead of `parallel` for coroutine style tcp server. - [#4875](https://github.com/hyperf/hyperf/pull/4875) Use the original style when regenerating models. - [#4880](https://github.com/hyperf/hyperf/pull/4880) Support `ignoreAnnotations` for `Annotation Reader`. +- [#4888](https://github.com/hyperf/hyperf/pull/4888) Removed useless `Hyperf\Di\ClassLoader::$proxies`, because merge it into `Composer\Autoload\ClassLoader::$classMap`. ## Changed diff --git a/src/di/src/ClassLoader.php b/src/di/src/ClassLoader.php index 0d8f15b5c..7e155c93a 100644 --- a/src/di/src/ClassLoader.php +++ b/src/di/src/ClassLoader.php @@ -26,12 +26,6 @@ class ClassLoader { protected ComposerClassLoader $composerClassLoader; - /** - * The container to collect all the classes that would be proxy. - * [ OriginalClassName => ProxyFileAbsolutePath ]. - */ - protected array $proxies = []; - public function __construct(ComposerClassLoader $classLoader, string $proxyFileDir, string $configDir, ScanHandlerInterface $handler) { $this->setComposerClassLoader($classLoader); @@ -44,8 +38,9 @@ class ClassLoader $classLoader->addClassMap($config->getClassMap()); $scanner = new Scanner($this, $config, $handler); - - $this->proxies = $scanner->scan($this->getComposerClassLoader()->getClassMap(), $proxyFileDir); + $classLoader->addClassMap( + $scanner->scan($classLoader->getClassMap(), $proxyFileDir) + ); } public function loadClass(string $class): void @@ -112,12 +107,7 @@ class ClassLoader protected function locateFile(string $className): ?string { - if (isset($this->proxies[$className]) && file_exists($this->proxies[$className])) { - $file = $this->proxies[$className]; - } else { - $file = $this->getComposerClassLoader()->findFile($className); - } - + $file = $this->getComposerClassLoader()->findFile($className); return is_string($file) ? $file : null; }