From b39484510394cc9637e9ceabc5d6e09fa95ca898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=9F=8E=E9=93=AD?= <767036228@qq.com> Date: Thu, 30 Jun 2022 18:34:16 +0800 Subject: [PATCH] Removed useless `Hyperf\Di\ClassLoader::$proxies`, because merge it into `Composer\Autoload\ClassLoader::$classMap`. (#4888) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: assert Co-authored-by: 李铭昕 <715557344@qq.com> --- CHANGELOG-3.0.md | 1 + src/di/src/ClassLoader.php | 18 ++++-------------- 2 files changed, 5 insertions(+), 14 deletions(-) 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; }