mirror of
https://github.com/pestphp/pest.git
synced 2026-12-07 00:02:16 +01:00
b5851d67ff
* fix(tia): run the full suite when code the project loads from outside its root changes * test(tia): cover the configuration fingerprint of a nested project * fix(tia): run the full suite when a declared external root holds files git ignores * fix(tia): track ignored inputs under external roots by content hash * fix(tia): harden external source tracking from the review loop * test: update the suite totals for the external source tests --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
818 B
PHP
34 lines
818 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pest\Support;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
final class ComposerProject
|
|
{
|
|
public static function rootPath(string $autoloadPath): string
|
|
{
|
|
$vendorPath = dirname($autoloadPath);
|
|
$vendorPath = realpath($vendorPath) ?: $vendorPath;
|
|
$rootPath = dirname($vendorPath);
|
|
$metadataPath = $vendorPath.'/composer/installed.php';
|
|
|
|
if (! is_file($metadataPath)) {
|
|
return $rootPath;
|
|
}
|
|
|
|
$installed = require $metadataPath;
|
|
$root = is_array($installed) ? ($installed['root'] ?? null) : null;
|
|
$installPath = is_array($root) ? ($root['install_path'] ?? null) : null;
|
|
|
|
if (! is_string($installPath)) {
|
|
return $rootPath;
|
|
}
|
|
|
|
return realpath($installPath) ?: $rootPath;
|
|
}
|
|
}
|