diff --git a/app/FileSystem/StaticRelativeFilePathHelper.php b/app/FileSystem/StaticRelativeFilePathHelper.php index 15206f84..3f957247 100644 --- a/app/FileSystem/StaticRelativeFilePathHelper.php +++ b/app/FileSystem/StaticRelativeFilePathHelper.php @@ -4,15 +4,12 @@ namespace TomasVotruba\ClassLeak\FileSystem; -use Symfony\Component\Filesystem\Filesystem; - final class StaticRelativeFilePathHelper { public static function resolveFromCwd(string $filePath): string { - $filesystem = new Filesystem(); - $relativeFilePathFromCwd = $filesystem->makePathRelative((string) realpath($filePath), getcwd()); - - return rtrim($relativeFilePathFromCwd, '/'); + // make path relative with native PHP + $relativeFilePath = (string) realpath($filePath); + return str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $relativeFilePath); } } diff --git a/tests/FileSystem/Fixture/some-file.php b/tests/FileSystem/Fixture/some-file.php new file mode 100644 index 00000000..935b82cb --- /dev/null +++ b/tests/FileSystem/Fixture/some-file.php @@ -0,0 +1,5 @@ +assertSame('tests/FileSystem/Fixture/some-file.php', $relativeFilePath); + } +}