From fbe5bfb8197296f7a1563168f1b553f258ff8ed2 Mon Sep 17 00:00:00 2001 From: c33s Date: Wed, 25 Dec 2019 17:49:58 +0100 Subject: [PATCH] relative path from phar fix closes: #2776 --- src/Util/Standards.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Util/Standards.php b/src/Util/Standards.php index 50f58f0294..1b97860994 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -10,6 +10,7 @@ namespace PHP_CodeSniffer\Util; use PHP_CodeSniffer\Config; +use Phar; class Standards { @@ -33,9 +34,17 @@ public static function getInstalledStandardPaths() } $resolvedInstalledPaths = []; + + $phar = Phar::running(false); + if (strlen($phar) > 0) { + $baseDir = dirname($phar); + } else { + $baseDir = __DIR__.$ds.'..'.$ds.'..'; + } + foreach ($installedPaths as $installedPath) { if (substr($installedPath, 0, 1) === '.') { - $installedPath = Common::realPath(__DIR__.$ds.'..'.$ds.'..'.$ds.$installedPath); + $installedPath = Common::realPath($baseDir.$ds.$installedPath); if ($installedPath === false) { continue; }