protected static function normalizePaths(array $paths)
{
$new_paths = [];
$excluded = false;
foreach ($paths as $path) {
// Path starting with '-' has special meaning (excluding it)
if (substr($path, 0, 1) === '-') {
$excluded = true;
$path = ltrim($path, '-');
}
$real_path = realpath($path);
if ($real_path === FALSE) {
throw new RuntimeException($path . ' does not exist?');
}
if (is_dir($real_path)) {
// Must use DIRECTORY_SEPARATOR for Windows
$real_path = $real_path . DIRECTORY_SEPARATOR;
}
$new_paths[] = $excluded ? '-' . $real_path : $real_path;
}
array_unique($new_paths, SORT_STRING);
sort($new_paths, SORT_STRING);
return $new_paths;
}