|
@@ -23,7 +23,6 @@ use PhpCsFixer\Console\Application;
|
|
|
*/
|
|
|
final class ToolInfo
|
|
|
{
|
|
|
- const COMPOSER_INSTALLED_FILE = '/../../composer/installed.json';
|
|
|
const COMPOSER_PACKAGE_NAME = 'friendsofphp/php-cs-fixer';
|
|
|
|
|
|
public static function getComposerVersion()
|
|
@@ -35,7 +34,7 @@ final class ToolInfo
|
|
|
}
|
|
|
|
|
|
if (null === $result) {
|
|
|
- $composerInstalled = json_decode(file_get_contents(self::getScriptDir().self::COMPOSER_INSTALLED_FILE), true);
|
|
|
+ $composerInstalled = json_decode(file_get_contents(self::getComposerInstalledFile()), true);
|
|
|
|
|
|
foreach ($composerInstalled as $package) {
|
|
|
if (self::COMPOSER_PACKAGE_NAME === $package['name']) {
|
|
@@ -73,33 +72,14 @@ final class ToolInfo
|
|
|
static $result;
|
|
|
|
|
|
if (null === $result) {
|
|
|
- $result = !self::isInstalledAsPhar() && file_exists(self::getScriptDir().self::COMPOSER_INSTALLED_FILE);
|
|
|
+ $result = !self::isInstalledAsPhar() && file_exists(self::getComposerInstalledFile());
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- private static function getScriptDir()
|
|
|
+ private static function getComposerInstalledFile()
|
|
|
{
|
|
|
- static $result;
|
|
|
-
|
|
|
- if (null === $result) {
|
|
|
- $script = $_SERVER['SCRIPT_NAME'];
|
|
|
-
|
|
|
- if (is_link($script)) {
|
|
|
- $linkTarget = readlink($script);
|
|
|
-
|
|
|
- // If the link target is relative to the link
|
|
|
- if (false === realpath($linkTarget)) {
|
|
|
- $linkTarget = dirname($script).'/'.$linkTarget;
|
|
|
- }
|
|
|
-
|
|
|
- $script = $linkTarget;
|
|
|
- }
|
|
|
-
|
|
|
- $result = dirname($script);
|
|
|
- }
|
|
|
-
|
|
|
- return $result;
|
|
|
+ return __DIR__.'/../../../composer/installed.json';
|
|
|
}
|
|
|
}
|