mirror of
https://github.com/pestphp/pest.git
synced 2026-06-08 20:22:17 +02:00
wip
This commit is contained in:
@ -9,9 +9,11 @@ use Pest\Plugins\Tia\Contracts\State;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final readonly class FileState implements State
|
final class FileState implements State
|
||||||
{
|
{
|
||||||
private string $rootDir;
|
private readonly string $rootDir;
|
||||||
|
|
||||||
|
private ?string $resolvedRoot = null;
|
||||||
|
|
||||||
public function __construct(string $rootDir)
|
public function __construct(string $rootDir)
|
||||||
{
|
{
|
||||||
@ -100,9 +102,17 @@ final readonly class FileState implements State
|
|||||||
|
|
||||||
private function resolvedRoot(): ?string
|
private function resolvedRoot(): ?string
|
||||||
{
|
{
|
||||||
|
if ($this->resolvedRoot !== null) {
|
||||||
|
return $this->resolvedRoot;
|
||||||
|
}
|
||||||
|
|
||||||
$resolved = @realpath($this->rootDir);
|
$resolved = @realpath($this->rootDir);
|
||||||
|
|
||||||
return $resolved === false ? null : $resolved;
|
if ($resolved === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->resolvedRoot = $resolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function ensureRoot(): bool
|
private function ensureRoot(): bool
|
||||||
|
|||||||
@ -52,6 +52,9 @@ final class Graph
|
|||||||
/** @var array<string, true>|null */
|
/** @var array<string, true>|null */
|
||||||
private ?array $archTestFiles = null;
|
private ?array $archTestFiles = null;
|
||||||
|
|
||||||
|
/** @var array<string, string|false> */
|
||||||
|
private array $realpathCache = [];
|
||||||
|
|
||||||
public function __construct(string $projectRoot)
|
public function __construct(string $projectRoot)
|
||||||
{
|
{
|
||||||
$real = @realpath($projectRoot);
|
$real = @realpath($projectRoot);
|
||||||
@ -1331,7 +1334,11 @@ final class Graph
|
|||||||
$isAbsolute = str_starts_with($path, DIRECTORY_SEPARATOR)
|
$isAbsolute = str_starts_with($path, DIRECTORY_SEPARATOR)
|
||||||
|| (strlen($path) >= 2 && $path[1] === ':');
|
|| (strlen($path) >= 2 && $path[1] === ':');
|
||||||
if ($isAbsolute) {
|
if ($isAbsolute) {
|
||||||
$real = @realpath($path);
|
if (array_key_exists($path, $this->realpathCache)) {
|
||||||
|
$real = $this->realpathCache[$path];
|
||||||
|
} else {
|
||||||
|
$real = $this->realpathCache[$path] = @realpath($path);
|
||||||
|
}
|
||||||
|
|
||||||
if ($real === false) {
|
if ($real === false) {
|
||||||
$real = $path;
|
$real = $path;
|
||||||
|
|||||||
Reference in New Issue
Block a user