1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Change die($message) to explicit exit(1)

This commit is contained in:
Matt Brown 2018-04-17 11:48:29 -04:00
parent 6ac2d22f76
commit 87be0b5863
3 changed files with 25 additions and 14 deletions

View File

@ -77,8 +77,9 @@ class FileFilter
);
foreach ($globs as $glob_index => $directory_path) {
if (!$directory_path) {
die('Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$directory['name'] . ':' . $glob_index);
echo 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$directory['name'] . ':' . $glob_index . PHP_EOL;
exit(1);
}
$filter->addDirectory($directory_path);
}
@ -87,8 +88,9 @@ class FileFilter
$directory_path = realpath($prospective_directory_path);
if (!$directory_path) {
die('Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$directory['name'] . PHP_EOL);
echo 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$directory['name'] . PHP_EOL;
exit(1);
}
$filter->addDirectory($directory_path);
@ -101,8 +103,9 @@ class FileFilter
$file_path = realpath($base_dir . DIRECTORY_SEPARATOR . (string)$file['name']);
if (!$file_path) {
die('Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$file['name'] . PHP_EOL);
echo 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR .
(string)$file['name'] . PHP_EOL;
exit(1);
}
$filter->addFile($file_path);

View File

@ -53,7 +53,8 @@ function requireAutoloaders($current_dir, $has_explicit_root, $vendor_dir)
. 'to specify a particular project to run Psalm on.';
}
die($error_message . PHP_EOL);
echo $error_message . PHP_EOL;
exit(1);
}
}
@ -170,17 +171,20 @@ function getPathsToCheck($f_paths)
foreach ($filtered_input_paths as $i => $path_to_check) {
if ($path_to_check[0] === '-') {
die('Invalid usage, expecting psalm [options] [file...]' . PHP_EOL);
echo 'Invalid usage, expecting psalm [options] [file...]' . PHP_EOL;
exit(1);
}
if (!file_exists($path_to_check)) {
die('Cannot locate ' . $path_to_check . PHP_EOL);
echo 'Cannot locate ' . $path_to_check . PHP_EOL;
exit(1);
}
$path_to_check = realpath($path_to_check);
if (!$path_to_check) {
die('Error getting realpath for file' . PHP_EOL);
echo 'Error getting realpath for file' . PHP_EOL;
exit(1);
}
$paths_to_check[] = $path_to_check;

View File

@ -43,7 +43,8 @@ if (isset($options['config'])) {
}
if (isset($options['c']) && is_array($options['c'])) {
die('Too many config files provided' . PHP_EOL);
echo 'Too many config files provided' . PHP_EOL;
exit(1);
}
if (array_key_exists('h', $options)) {
@ -118,7 +119,8 @@ HELP;
}
if (getcwd() === false) {
die('Cannot get current working directory');
echo 'Cannot get current working directory' . PHP_EOL;
exit(1);
}
if (isset($options['root'])) {
@ -131,7 +133,8 @@ if (isset($options['r']) && is_string($options['r'])) {
$root_path = realpath($options['r']);
if (!$root_path) {
die('Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL);
echo 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL;
exit(1);
}
$current_dir = $root_path . DIRECTORY_SEPARATOR;
@ -251,7 +254,8 @@ $path_to_config = isset($options['c']) && is_string($options['c']) ? realpath($o
if ($path_to_config === false) {
/** @psalm-suppress InvalidCast */
die('Could not resolve path to config ' . (string)$options['c'] . PHP_EOL);
echo 'Could not resolve path to config ' . (string)$options['c'] . PHP_EOL;
exit(1);
}
$show_info = isset($options['show-info'])