mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 07:15:38 +08:00
deduplicate those to make it more readable
This commit is contained in:
@@ -245,6 +245,16 @@ function clean_spaces(string $string): string
|
||||
return trim(preg_replace('/\s+/', ' ', $string));
|
||||
}
|
||||
|
||||
function deduplicate_flags(string $flags): string
|
||||
{
|
||||
$tokens = preg_split('/\s+/', trim($flags));
|
||||
|
||||
// Reverse, unique, reverse back - keeps last occurrence of duplicates
|
||||
$deduplicated = array_reverse(array_unique(array_reverse($tokens)));
|
||||
|
||||
return implode(' ', $deduplicated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback function to handle keyboard interrupts (Ctrl+C).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user