diff --git a/tests/ReflectorFactory.php b/tests/ReflectorFactory.php index 139b365a..284676e6 100644 --- a/tests/ReflectorFactory.php +++ b/tests/ReflectorFactory.php @@ -26,11 +26,16 @@ final class ReflectorFactory { + /** + * @var AggregateSourceLocator + */ + private static $sourceLocator; + public static function create(string $code): Reflector { $astLocator = (new BetterReflection())->astLocator(); - $sourceLocator = new AggregateSourceLocator([ + self::$sourceLocator = self::$sourceLocator ?? new AggregateSourceLocator([ new PhpInternalSourceLocator( $astLocator, new PhpStormStubsSourceStubber( @@ -42,9 +47,9 @@ public static function create(string $code): Reflector new StringSourceLocator($code, $astLocator), ]); - $classReflector = new ClassReflector($sourceLocator); + $classReflector = new ClassReflector(self::$sourceLocator); - $functionReflector = new FunctionReflector($sourceLocator, $classReflector); + $functionReflector = new FunctionReflector(self::$sourceLocator, $classReflector); return new Reflector($classReflector, $functionReflector); }