1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

additional places with inconsistent trailing slash

This commit is contained in:
kkmuffme 2024-02-01 08:46:18 +01:00
parent d4a5909e1f
commit f185f3d985
9 changed files with 24 additions and 34 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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)) {

View File

@ -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)) {

View File

@ -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)) {

View File

@ -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),
];
}