diff --git a/src/Psalm/Internal/Cli/LanguageServer.php b/src/Psalm/Internal/Cli/LanguageServer.php index 1dc16fbe5..0fa174eff 100644 --- a/src/Psalm/Internal/Cli/LanguageServer.php +++ b/src/Psalm/Internal/Cli/LanguageServer.php @@ -258,12 +258,12 @@ final class LanguageServer $options['r'] = $options['root']; } - $current_dir = (string)getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); if (isset($options['r']) && is_string($options['r'])) { $root_path = realpath($options['r']); - if (!$root_path) { + if ($root_path === false) { fwrite( STDERR, 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL, @@ -271,7 +271,7 @@ final class LanguageServer exit(1); } - $current_dir = $root_path . DIRECTORY_SEPARATOR; + $current_dir = $root_path; } $vendor_dir = CliUtils::getVendorDir($current_dir); diff --git a/src/Psalm/Internal/Cli/Plugin.php b/src/Psalm/Internal/Cli/Plugin.php index 238823826..c89cbeed5 100644 --- a/src/Psalm/Internal/Cli/Plugin.php +++ b/src/Psalm/Internal/Cli/Plugin.php @@ -12,8 +12,6 @@ use Symfony\Component\Console\Application; use function dirname; use function getcwd; -use const DIRECTORY_SEPARATOR; - // phpcs:disable PSR1.Files.SideEffects require_once __DIR__ . '/../CliUtils.php'; @@ -27,13 +25,13 @@ final class Plugin public static function run(): void { CliUtils::checkRuntimeRequirements(); - $current_dir = (string)getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); $vendor_dir = CliUtils::getVendorDir($current_dir); CliUtils::requireAutoloaders($current_dir, false, $vendor_dir); $app = new Application('psalm-plugin', PSALM_VERSION); - $psalm_root = dirname(__DIR__, 4) . DIRECTORY_SEPARATOR; + $psalm_root = dirname(__DIR__, 4); $plugin_list_factory = new PluginListFactory($current_dir, $psalm_root); diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index c354cf21a..c8a5a4ee2 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -485,7 +485,7 @@ final class Psalm */ private static function generateConfig(string $current_dir, array &$args): void { - if (file_exists($current_dir . 'psalm.xml')) { + if (file_exists($current_dir . DIRECTORY_SEPARATOR . 'psalm.xml')) { die('A config file already exists in the current directory' . PHP_EOL); } @@ -535,7 +535,7 @@ final class Psalm die($e->getMessage() . PHP_EOL); } - if (!file_put_contents($current_dir . 'psalm.xml', $template_contents)) { + if (!file_put_contents($current_dir . DIRECTORY_SEPARATOR . 'psalm.xml', $template_contents)) { die('Could not write to psalm.xml' . PHP_EOL); } @@ -779,7 +779,7 @@ final class Psalm die($e->getMessage() . PHP_EOL); } - if (!file_put_contents($current_dir . 'psalm.xml', $template_contents)) { + if (!file_put_contents($current_dir . DIRECTORY_SEPARATOR . 'psalm.xml', $template_contents)) { die('Could not write to psalm.xml' . PHP_EOL); } @@ -840,12 +840,12 @@ final class Psalm exit(1); } - $current_dir = $cwd . DIRECTORY_SEPARATOR; + $current_dir = $cwd; if (isset($options['r']) && is_string($options['r'])) { $root_path = realpath($options['r']); - if (!$root_path) { + if ($root_path === false) { fwrite( STDERR, 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL, @@ -853,7 +853,7 @@ final class Psalm exit(1); } - $current_dir = $root_path . DIRECTORY_SEPARATOR; + $current_dir = $root_path; } return $current_dir; diff --git a/src/Psalm/Internal/Cli/Psalter.php b/src/Psalm/Internal/Cli/Psalter.php index 9dd8eaf47..5b53ec0dc 100644 --- a/src/Psalm/Internal/Cli/Psalter.php +++ b/src/Psalm/Internal/Cli/Psalter.php @@ -194,16 +194,16 @@ final class Psalter exit(1); } - $current_dir = (string)getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); if (isset($options['r']) && is_string($options['r'])) { $root_path = realpath($options['r']); - if (!$root_path) { + if ($root_path === false) { die('Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL); } - $current_dir = $root_path . DIRECTORY_SEPARATOR; + $current_dir = $root_path; } $vendor_dir = CliUtils::getVendorDir($current_dir); diff --git a/src/Psalm/Internal/Cli/Refactor.php b/src/Psalm/Internal/Cli/Refactor.php index 0fca3ab46..22761b873 100644 --- a/src/Psalm/Internal/Cli/Refactor.php +++ b/src/Psalm/Internal/Cli/Refactor.php @@ -165,16 +165,16 @@ final class Refactor $options['r'] = $options['root']; } - $current_dir = (string)getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); if (isset($options['r']) && is_string($options['r'])) { $root_path = realpath($options['r']); - if (!$root_path) { + if ($root_path === false) { die('Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL); } - $current_dir = $root_path . DIRECTORY_SEPARATOR; + $current_dir = $root_path; } $vendor_dir = CliUtils::getVendorDir($current_dir); diff --git a/src/Psalm/Internal/PluginManager/Command/DisableCommand.php b/src/Psalm/Internal/PluginManager/Command/DisableCommand.php index af7b4bb90..7c1e6b9a2 100644 --- a/src/Psalm/Internal/PluginManager/Command/DisableCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/DisableCommand.php @@ -16,8 +16,6 @@ use function assert; use function getcwd; use function is_string; -use const DIRECTORY_SEPARATOR; - /** * @internal */ @@ -50,7 +48,7 @@ final class DisableCommand extends Command { $io = new SymfonyStyle($input, $output); - $current_dir = (string) getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); $config_file_path = $input->getOption('config'); if ($config_file_path !== null && !is_string($config_file_path)) { diff --git a/src/Psalm/Internal/PluginManager/Command/EnableCommand.php b/src/Psalm/Internal/PluginManager/Command/EnableCommand.php index 6278b7018..0a8df8d1d 100644 --- a/src/Psalm/Internal/PluginManager/Command/EnableCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/EnableCommand.php @@ -16,8 +16,6 @@ use function assert; use function getcwd; use function is_string; -use const DIRECTORY_SEPARATOR; - /** * @internal */ @@ -50,7 +48,7 @@ final class EnableCommand extends Command { $io = new SymfonyStyle($input, $output); - $current_dir = (string) getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); $config_file_path = $input->getOption('config'); if ($config_file_path !== null && !is_string($config_file_path)) { diff --git a/src/Psalm/Internal/PluginManager/Command/ShowCommand.php b/src/Psalm/Internal/PluginManager/Command/ShowCommand.php index a8e78a732..ecc24712c 100644 --- a/src/Psalm/Internal/PluginManager/Command/ShowCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/ShowCommand.php @@ -17,8 +17,6 @@ use function count; use function getcwd; use function is_string; -use const DIRECTORY_SEPARATOR; - /** * @internal */ @@ -44,7 +42,7 @@ final class ShowCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); - $current_dir = (string) getcwd() . DIRECTORY_SEPARATOR; + $current_dir = (string) getcwd(); $config_file_path = $input->getOption('config'); if ($config_file_path !== null && !is_string($config_file_path)) { diff --git a/src/Psalm/Internal/PluginManager/PluginListFactory.php b/src/Psalm/Internal/PluginManager/PluginListFactory.php index 950b6dd24..927d0f8c3 100644 --- a/src/Psalm/Internal/PluginManager/PluginListFactory.php +++ b/src/Psalm/Internal/PluginManager/PluginListFactory.php @@ -7,10 +7,8 @@ use RuntimeException; use function array_filter; use function json_encode; -use function rtrim; use function urlencode; -use const DIRECTORY_SEPARATOR; use const JSON_THROW_ON_ERROR; /** @@ -53,13 +51,13 @@ final class PluginListFactory if ($this->psalm_root === $this->project_root) { // managing plugins for psalm itself $composer_lock_filenames = [ - Composer::getLockFilePath(rtrim($this->psalm_root, DIRECTORY_SEPARATOR)), + Composer::getLockFilePath($this->psalm_root), ]; } else { $composer_lock_filenames = [ - Composer::getLockFilePath(rtrim($this->project_root, DIRECTORY_SEPARATOR)), - Composer::getLockFilePath(rtrim($this->psalm_root, DIRECTORY_SEPARATOR) . '/../../..'), - Composer::getLockFilePath(rtrim($this->psalm_root, DIRECTORY_SEPARATOR)), + Composer::getLockFilePath($this->project_root), + Composer::getLockFilePath($this->psalm_root . '/../../..'), + Composer::getLockFilePath($this->psalm_root), ]; }