File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,9 @@ class ClassReflection implements ReflectionWithFilename
8484 /** @var array<string, bool> */
8585 private $ subclasses = [];
8686
87+ /** @var string|false|null */
88+ private $ filename ;
89+
8790 /**
8891 * @param \PHPStan\Reflection\ReflectionProvider $reflectionProvider
8992 * @param \PHPStan\Type\FileTypeMapper $fileTypeMapper
@@ -127,19 +130,23 @@ public function getNativeReflection(): \ReflectionClass
127130 */
128131 public function getFileName ()
129132 {
133+ if (isset ($ this ->filename )) {
134+ return $ this ->filename ;
135+ }
136+
130137 if ($ this ->anonymousFilename !== null ) {
131- return $ this ->anonymousFilename ;
138+ return $ this ->filename = $ this -> anonymousFilename ;
132139 }
133140 $ fileName = $ this ->reflection ->getFileName ();
134141 if ($ fileName === false ) {
135- return false ;
142+ return $ this -> filename = false ;
136143 }
137144
138145 if (!file_exists ($ fileName )) {
139- return false ;
146+ return $ this -> filename = false ;
140147 }
141148
142- return $ fileName ;
149+ return $ this -> filename = $ fileName ;
143150 }
144151
145152 public function getFileNameWithPhpDocs (): ?string
You can’t perform that action at this time.
0 commit comments