Extracts the params from the arguments passed

@param $args array

@return array
509599
private function getParams(array $args)
    {
        if (count($args) == 0) {
            return [];
        }

        $params = array_slice($args, -1)[0];

        return is_array($params) ? $params : [];
    }
751276
private function prepare($args)
    {
        $bindings = array();

        // Two parameters (key, value).
        if (count($args) == 2) {
            $bindings[$args[0]] = $args[1];
        }
        // Array of parameters.
        elseif (is_array($args[0])) {
            $bindings = $args[0];
        }

        return $bindings;
    }
533259
public function parseArguments(array $args)
    {
        $this->action = null;
        $this->arguments = array();
        $parsed = array();
        $argument = reset($args);
        while ($argument) {
            if (strpos($argument, '=') > 0) {
                $arg = explode('=', $argument);
                $argKey = ltrim($arg[0], '-');
                $argValue = trim($arg[1], '"');
                $parsed[$argKey] = $argValue;
            } else {
                $parsed[ltrim($argument, '-')] = true;
            }
            $argument = next($args);
        }
        if (!isset($parsed['action']) || empty($parsed['action'])) {
            if (isset($parsed['version']) ||  isset($parsed['V'])) {
                $this->action = 'Version';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            if (isset($parsed['help']) || isset($parsed['h'])) {
                $this->action = 'Help';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            throw new RequestException($this, "No valid action argument specified.");
        }
        $this->action = $parsed['action'];
        unset($parsed['action']);
        $this->arguments = $parsed;
        return $this->arguments;
    }
590006
protected function getServiceByArgs($args) {
		$args = $this->normalizeArgs($args);
		$id   = $this->getIdByArgs($args);
		$args = $this->processArgs($args);
			
		if (! isset($this->servicesByArgs[$id])) {
			$this->servicesByArgs[$id] = $this->initService($args);
		}

		return $this->servicesByArgs[$id];
	}
1242030
protected function parseArgs(string $arg)
    {
        if ($this->_lastVariadic) {
            return $this->set($this->_lastVariadic, $arg, true);
        }

        if (!$argument = \reset($this->_arguments)) {
            return $this->set(null, $arg);
        }

        $this->setValue($argument, $arg);

        // Otherwise we will always collect same arguments again!
        if (!$argument->variadic()) {
            \array_shift($this->_arguments);
        }
    }
41137
public function getParams()
    {
        if ($this->cachedParams) {
            return $this->cachedParams;
        }

        $CMDS = [];
        $KEYS = [];
        $ARGV = [];
        $KEYNUM = 0;
        $ARGNUM = 0;

        foreach ($this->stack as $part) {
            list($cmd, $keys, $argv) = $part;

            if (!empty($keys)) {
                $cmd = preg_replace_callback('~KEYS\[(\d+)\]~', function ($m) use (&$KEYS, &$KEYNUM, $keys) {
                    $key = $keys[$m[1] - 1];
                    if (!isset($KEYS[$key])) {
                        $KEYS[$key] = ++$KEYNUM;
                    }
                    return 'KEYS[' . $KEYS[$key] . ']';
                }, $cmd);
            }

            if (!empty($argv)) {
                $cmd = preg_replace_callback('~ARGV\[(\d+)\]~', function ($m) use (&$ARGV, &$ARGNUM, $argv) {
                    $arg = $argv[$m[1] - 1];
                    if (!isset($ARGV[$arg])) {
                        $ARGV[$arg] = ++$ARGNUM;
                    }
                    return 'ARGV[' . $ARGV[$arg] . ']';
                }, $cmd);
            }

            $CMDS[] = $cmd;
        }

        return $this->cachedParams = array_merge(
            [implode(';', $CMDS), count($KEYS)],
            array_keys($KEYS),
            array_keys($ARGV)
        );
    }
216094
private function collection($args = null) {

        static $data = [];


        if(isset($args[1])) {
            
            if(preg_match('/(.*)\[(.*)\]/', $args[0], $matches)) {

                $data[$matches[1]][$matches[2]] = $args[1];

            } else {

                $data[$args[0]] = $args[1];

                return $args[1];
            }
        }

        return $data;
    }
212275
protected function normalizeMailArgs(array $args): array
    {
        // If the first argument is an array, use it as the mail configuration
        if (is_array($args[0])) {
            return $args[0];
        }
        $result = [];
        $length = count($args);
        // FIXME This is a weak way to handle the arguments, since a change in the order will break it
        for ($i = 0; $i < $length; $i++) {
            $result[$this->argumentsMapping[$i]] = $args[$i];
        }
        return $result;
    }
900004
protected function _parse($arg)
    {
        $pos = strpos($arg, '=');
        if ($pos !== false) {
            $name = substr($arg, 0, $pos);
            $value = substr($arg, $pos + 1);
        } else {
            $name = $arg;
            $value = true;
        }
        return [$name, $value];
    }
1157792
private function getArguments($matches)
	{
		$arguments = array();

		foreach ($matches as $key => $match) {
			if ($key === 0) continue;

			if (strlen($match) > 0) {
				$arguments[] = $match;
			}
		}

		return $arguments;
	}
1137951
public function normalizeArgs(array $args): array
    {
        $normalized = [];

        foreach ($args as $arg) {
            if (\preg_match('/^\-\w{2,}/', $arg)) {
                $splitArg   = \implode(' -', \str_split(\ltrim($arg, '-')));
                $normalized = \array_merge($normalized, \explode(' ', '-' . $splitArg));
            } elseif (\preg_match('/^\-\-\w{2,}\=/', $arg)) {
                $normalized = \array_merge($normalized, explode('=', $arg));
            } else {
                $normalized[] = $arg;
            }
        }

        return $normalized;
    }
1283400
protected function evaluatePathValueArguments($args)
    {
        $hasSecondArgument = $args[1] !== self::NULL_ARGUMENT;
        return array(!$hasSecondArgument ? '' : $args[0], !$hasSecondArgument ? $args[0] : $args[1]);
    }
1370781
protected function getCliParams() {
		if (empty($_SERVER['argv'])) {
			return [];
		}
		
		$params = preg_grep('/^\-\-zdebug:/', $_SERVER['argv']);
		
		if (empty($params)) {
			return [];
		}
		
		return array_map(function($in) {
			return str_replace('--zdebug:', '', $in);
		}, $params);
	}
1314902
public function parse_query_args( $args ) {
		$query_args = [
			'frontend' => $args,
			'backend'  => $args,
		];

		if ( isset( $args['frontend'] ) || isset( $args['backend'] ) ) {
			foreach ( [ 'frontend', 'backend' ] as $query_type ) {
				$query_args[ $query_type ] = isset( $args[ $query_type ] )
					? $args[ $query_type ]
					: [];
			}
		}

		return $query_args;
	}
400169
private function extractArguments(string $argumentList): array
    {
        $arguments = [];

        foreach (array_map('trim', explode(',', $argumentList)) as $rawArgument) {
            if ($rawArgument === '') {
                continue;
            }

            list ($argumentName, $argumentValue) = array_map('trim', explode('=', $rawArgument, 2) + [
                null,
                null
            ]);

            $arguments[$argumentName] = $argumentValue;
        }

        return $arguments;
    }
515806
public static function arguments(array $args) : array
    {
        putenv("CODGER_DRY=1");
        foreach ($args as $key => $value) {
            if ($value === '-w') {
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-o') {
                putenv("CODGER_OVERWRITE=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-d') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_DUMP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-s') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_SKIP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
        }
        return array_values($args);
    }
639537
protected function parseArgument($arg)
    {
        $arg = ltrim($arg, '-');
        
        $key = $arg;
        $value = true;
        
        if (strpos($arg, '=') !== false) {
            $key = substr($arg, 0, strpos($arg, '='));
            $value = substr($arg, strpos($arg, '=') + 1);
        
            if (is_numeric($value)) {
                // Transform the value into the correct data type
                $value = $value * 1;
            }
        }
        
        return array($key, $value);
    }