static function parseArgs(string $argString, $argCount = null, bool $allowSingleQuotes = true) {
        if(\mb_strlen($argString) === 0) {
            return array();
        }
        
        if($argCount === 1) {
            return array($argString);
        }
        
        $regex = '/(?:(['.($allowSingleQuotes ? "'" : '').'"])(.*?)(?<!\\\\)(?>\\\\\\\)*\1|([^\\s]+))/Su';
        $results = array();
        
        $argString = \trim($argString);
        
        if($argCount === null) {
            $argCount = \mb_strlen($argString); // Large enough to get all items
        }
        
        $content = $argString;
        \preg_match_all($regex, $argString, $matches);
        
        foreach($matches[0] as $key => $val) {
            $argCount--;
            if($argCount === 0) {
                break;
            }
            
            $val = \trim(($matches[3][$key] !== '' ? $matches[3][$key] : ($matches[2][$key] !== '' ? $matches[2][$key] : $matches[1][$key])));
            $results[] = $val;
            
            $content = \trim(\preg_replace('/'.\preg_quote($val, '/').'/u', '', $content, 1));
        }
        
        // If text remains, push it to the array as-is (except for wrapping quotes, which are removed)
        if(\mb_strlen($content) > 0) {
            $results[] = \preg_replace(($allowSingleQuotes ? '/^("|\')(.*)\1$/u' : '/^(")(.*)\1$/u'), '$2', $content);
        }
        
        if(\count($results) > 0) {
            $results = \array_filter($results, function ($val) {
                return (\mb_strlen(\trim($val)) > 0);
            });
        }
        
        return $results;
    }
static function parseArgs(string $argString, $argCount = null, bool $allowSingleQuotes = true) {
        if(\mb_strlen($argString) === 0) {
            return array();
        }
        
        if($argCount === 1) {
            return array($argString);
        }
        
        $regex = '/(?:(['.($allowSingleQuotes ? "'" : '').'"])(.*?)(?<!\\\\)(?>\\\\\\\)*\1|([^\\s]+))/Su';
        $results = array();
        
        $argString = \trim($argString);
        
        if($argCount === null) {
            $argCount = \mb_strlen($argString); // Large enough to get all items
        }
        
        $content = $argString;
        \preg_match_all($regex, $argString, $matches);
        
        foreach($matches[0] as $key => $val) {
            $argCount--;
            if($argCount === 0) {
                break;
            }
            
            $val = \trim(($matches[3][$key] !== '' ? $matches[3][$key] : ($matches[2][$key] !== '' ? $matches[2][$key] : $matches[1][$key])));
            $results[] = $val;
            
            $content = \trim(\preg_replace('/'.\preg_quote($val, '/').'/u', '', $content, 1));
        }
        
        // If text remains, push it to the array as-is (except for wrapping quotes, which are removed)
        if(\mb_strlen($content) > 0) {
            $results[] = \preg_replace(($allowSingleQuotes ? '/^("|\')(.*)\1$/u' : '/^(")(.*)\1$/u'), '$2', $content);
        }
        
        if(\count($results) > 0) {
            $results = \array_filter($results, function ($val) {
                return (\mb_strlen(\trim($val)) > 0);
            });
        }
        
        return $results;
    }
static function parseArgs ( string $ argString , $ argCount = null , bool $ allowSingleQuotes = true ) { if ( \ mb_strlen ( $ argString ) === 0 ) { return array ( ) ; } if ( $ argCount === 1 ) { return array ( $ argString ) ; } $ regex = '/(?:([' . ( $ allowSingleQuotes ? "'" : '' ) . '"])(.*?)(?<!\\\\)(?>\\\\\\\)*\1|([^\\s]+))/Su' ; $ results = array ( ) ; $ argString = \ trim ( $ argString ) ; if ( $ argCount === null ) { $ argCount = \ mb_strlen ( $ argString ) ; // Large enough to get all items } $ content = $ argString ; \ preg_match_all ( $ regex , $ argString , $ matches ) ; foreach ( $ matches [ 0 ] as $ key => $ val ) { $ argCount -- ; if ( $ argCount === 0 ) { break ; } $ val = \ trim ( ( $ matches [ 3 ] [ $ key ] !== '' ? $ matches [ 3 ] [ $ key ] : ( $ matches [ 2 ] [ $ key ] !== '' ? $ matches [ 2 ] [ $ key ] : $ matches [ 1 ] [ $ key ] ) ) ) ; $ results [ ] = $ val ; $ content = \ trim ( \ preg_replace ( '/' . \ preg_quote ( $ val , '/' ) . '/u' , '' , $ content , 1 ) ) ; } // If text remains, push it to the array as-is (except for wrapping quotes, which are removed) if ( \ mb_strlen ( $ content ) > 0 ) { $ results [ ] = \ preg_replace ( ( $ allowSingleQuotes ? '/^("|\')(.*)\1$/u' : '/^(")(.*)\1$/u' ) , '$2' , $ content ) ; } if ( \ count ( $ results ) > 0 ) { $ results = \ array_filter ( $ results , function ( $ val ) { return ( \ mb_strlen ( \ trim ( $ val ) ) > 0 ) ; } ) ; } return $ results ; }
Parses an argument string into an array of arguments.
@param string          $argString
@param int|float|null  $argCount           float = \INF
@param bool            $allowSingleQuotes
@return string[]
Parses an argument string into an array of arguments .