@@ -54,6 +54,10 @@ class GlobClassExplorer implements ClassExplorerInterface
5454 * @var string
5555 */
5656 private $ rootPath ;
57+ /**
58+ * @var string|null
59+ */
60+ private $ key ;
5761
5862 public function __construct (string $ namespace , CacheInterface $ cache , ?int $ cacheTtl = null , ?ClassNameMapper $ classNameMapper = null , bool $ recursive = true , ?string $ rootPath = null )
5963 {
@@ -78,23 +82,25 @@ public function getClasses(): array
7882 /**
7983 * Returns an array mapping the fully qualified class name to the file path.
8084 *
81- * @return array<string,SplFileInfo >
85+ * @return array<string,string >
8286 */
8387 public function getClassMap (): array
8488 {
85- $ key = 'globClassExplorer_ ' .str_replace ('\\' , '_ ' , $ this ->namespace );
86- $ classes = $ this ->cache ->get ($ key );
89+ if ($ this ->key === null ) {
90+ $ this ->key = 'globClassExplorer_ ' .hash ('md4 ' , $ this ->namespace .'___ ' .$ this ->recursive .$ this ->rootPath );
91+ }
92+ $ classes = $ this ->cache ->get ($ this ->key );
8793 if ($ classes === null ) {
8894 $ classes = $ this ->doGetClassMap ();
89- $ this ->cache ->set ($ key , $ classes , $ this ->cacheTtl );
95+ $ this ->cache ->set ($ this -> key , $ classes , $ this ->cacheTtl );
9096 }
9197 return $ classes ;
9298 }
9399
94100 /**
95101 * Returns an array of fully qualified class names, without the cache.
96102 *
97- * @return array<string,SplFileInfo >
103+ * @return array<string,string >
98104 */
99105 private function doGetClassMap (): array
100106 {
@@ -115,7 +121,7 @@ private function doGetClassMap(): array
115121 foreach ($ filesForDir as $ file ) {
116122 // Trim the root directory name and the PHP extension
117123 $ fileTrimPrefixSuffix = \substr ($ file , $ dirLen , -4 );
118- $ classes [$ namespace .\str_replace ('/ ' , '\\' , $ fileTrimPrefixSuffix )] = $ file ;
124+ $ classes [$ namespace .\str_replace ('/ ' , '\\' , $ fileTrimPrefixSuffix )] = $ file-> getRealPath () ;
119125 }
120126 }
121127 chdir ($ oldCwd );
0 commit comments