Skip to content

Commit fbe5bfb

Browse files
committed
relative path from phar fix closes: squizlabs#2776
1 parent 278b643 commit fbe5bfb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Util/Standards.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHP_CodeSniffer\Util;
1111

1212
use PHP_CodeSniffer\Config;
13+
use Phar;
1314

1415
class Standards
1516
{
@@ -33,9 +34,17 @@ public static function getInstalledStandardPaths()
3334
}
3435

3536
$resolvedInstalledPaths = [];
37+
38+
$phar = Phar::running(false);
39+
if (strlen($phar) > 0) {
40+
$baseDir = dirname($phar);
41+
} else {
42+
$baseDir = __DIR__.$ds.'..'.$ds.'..';
43+
}
44+
3645
foreach ($installedPaths as $installedPath) {
3746
if (substr($installedPath, 0, 1) === '.') {
38-
$installedPath = Common::realPath(__DIR__.$ds.'..'.$ds.'..'.$ds.$installedPath);
47+
$installedPath = Common::realPath($baseDir.$ds.$installedPath);
3948
if ($installedPath === false) {
4049
continue;
4150
}

0 commit comments

Comments
 (0)