Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Optimized unit tests
  • Loading branch information
kukulich committed May 10, 2019
commit f49c9bfc0443dcf1da3a98b21d614baaf20f14d5
11 changes: 8 additions & 3 deletions tests/ReflectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}
Expand Down