Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions src/Detection/ConsumedUsageVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ private function addName(?Name $name): void
return;
}

$resolvedName = $name->getAttribute('resolvedName');
$className = $resolvedName instanceof Name ? $resolvedName->toString() : $name->toString();

$this->addUsage($className);
// NameResolver runs with replaceNodes = true, so names are already resolved
// in place and toString() yields the fully-qualified name.
$this->addUsage($name->toString());
}

private function addFunctionName(Name $name): void
Expand Down
9 changes: 5 additions & 4 deletions src/Detection/TestUsageScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

private Parser $parser;

/** @var Closure(string): ScanResult */
private Closure $scanFactory;

/**
* @param null|Closure(string): (string|false) $readFile
*/
Expand All @@ -35,14 +38,12 @@ public function __construct(
$this->consumedUsageExtractor = $consumedUsageExtractor ?? new ConsumedUsageExtractor();
$this->scanResultCache = $scanResultCache ?? new ScanResultCache();
$this->parser = (new ParserFactory())->createForNewestSupportedVersion();
$this->scanFactory = fn (string $className): ScanResult => $this->scanUncached($className);
}

public function scan(string $testClassName): ScanResult
{
return $this->scanResultCache->get(
$testClassName,
fn (string $className): ScanResult => $this->scanUncached($className)
);
return $this->scanResultCache->get($testClassName, $this->scanFactory);
}

private function scanUncached(string $testClassName): ScanResult
Expand Down
Loading