Separate runtime parameters from command-specific parameters.

@param array $mixed_args
@return array
322115
private function unmix_assoc_args( $mixed_args, $global_assoc = array(), $local_assoc = array() ) {
		$assoc_args     = array();
		$runtime_config = array();

		if ( getenv( 'WP_CLI_STRICT_ARGS_MODE' ) ) {
			foreach ( $global_assoc as $tmp ) {
				list( $key, $value ) = $tmp;
				if ( isset( $this->spec[ $key ] ) && false !== $this->spec[ $key ]['runtime'] ) {
					$this->assoc_arg_to_runtime_config( $key, $value, $runtime_config );
				}
			}
			foreach ( $local_assoc as $tmp ) {
				$assoc_args[ $tmp[0] ] = $tmp[1];
			}
		} else {
			foreach ( $mixed_args as $tmp ) {
				list( $key, $value ) = $tmp;

				if ( isset( $this->spec[ $key ] ) && false !== $this->spec[ $key ]['runtime'] ) {
					$this->assoc_arg_to_runtime_config( $key, $value, $runtime_config );
				} else {
					$assoc_args[ $key ] = $value;
				}
			}
		}

		return array( $assoc_args, $runtime_config );
	}
365681
public function command($args)
    {
        // Throw if no arguments provided and args less than 2
        if (empty($args) || count($args) < 2) {
            throw new RuntimeException("Invalid argument count");
        }

        $secondArg = $args[1];

        // Output the second argument
        return $secondArg;

    }
143612
public function getArguments(): array
    {
        // We will need to process the arguments and merge them.
        $arguments = parent::getArguments();

        // If we have outfile setup don't act!
        foreach ($arguments as $argument) {
            if (strstr($argument, '-outfile') !== false) {
                return $arguments;
            }
        }

        if ($this->isOutSourceEqual()) // Check if not already specified
        {
            $this->outFileTemp = tempnam(sys_get_temp_dir(), 'img-prfy-');
            $arguments[] = '-outfile '.escapeshellarg($this->outFileTemp);
        } else {
            $arguments[] = '-outfile '.escapeshellarg($this->getOutFile());
        }

        return $arguments;
    }
543688
static function get_arguments()
    {
        global $argv;
        $_ARG = array();
        foreach ($argv as $arg) {
            $temp_arg = explode('=', $arg);
            $_ARG[$temp_arg[0]] = null;
            if (isset($temp_arg[1])) {
                $_ARG[$temp_arg[0]] = $temp_arg[1];
            }
        }
        return $_ARG;
    }
430963
private function buildArrayOfArgs($args)
  {
    $result = array();
    
    foreach($args as $arg)
      if ( is_array($arg) )
        $result = array_merge($result, $arg);
      else if ( is_string($arg) )
        if (false !== strpos($arg, ','))
          $result = array_merge($result, array_map('trim', explode(',',$arg)));
        else
          $result[] = $arg;
      else
        $this->debug && trigger_error(sprintf('Argument "%s" of type %s is skipped.', $arg, gettype($arg)), E_USER_WARNING);
        
    return $result;
  }
576965
protected function _processArguments( $arguments )
    {
        //	Process command line arguments
        $_className = array_shift( $arguments );
        $_options = $this->getArguments( $arguments );
        $arguments = array_merge( array($_className), $_options['rebuilt'] );

        //	Set our values based on options...
        $this->set( $_options );

        return $arguments;
    }
161083
private function extractArguments(): array
    {
        $parameters = [];

        //Use the Reflection API to create Parameter Value object
        foreach ($this->getReflectionInstance()->getParameters() as $param) {
            $name = $param->getName();
            $hasDefault = $param->isDefaultValueAvailable();

            //Default value. To null if the parameter has no default value
            $defaultValue = null;
            if (true === $hasDefault) {
                $defaultValue = $param->getDefaultValue();
            }
            $class = $param->getClass();

            $parameters[$name] = new Parameter($name, $hasDefault, $defaultValue, $class);
        }

        return $parameters;
    }
48395
public function parse_args( $arguments ) {
		list( $positional_args, $mixed_args, $global_assoc, $local_assoc ) = self::extract_assoc( $arguments );
		list( $assoc_args, $runtime_config )                               = $this->unmix_assoc_args( $mixed_args, $global_assoc, $local_assoc );
		return array( $positional_args, $assoc_args, $runtime_config );
	}
1070804
public function formatArgs(array $args)
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
                $parts = explode('\\', $item[1]);
                $short = array_pop($parts);
                $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
            } elseif ('string' === $item[0]) {
                $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
            }

            $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
        }

        return implode(', ', $result);
    }
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;
    }
509599
private function getParams(array $args)
    {
        if (count($args) == 0) {
            return [];
        }

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

        return is_array($params) ? $params : [];
    }
458015
public static function buildParameters(array $args)
    {
        $parameters = [];

        if (count($args) > 2) {
            $parameters[] = $args[0];
            foreach ($args[1] as $param) {
                $parameters[] = $param;
            }
        } else {
            foreach ($args[0] as $param) {
                $parameters[] = $param;
            }
        }

        return $parameters;
    }
1289670
private function parseArgs(): array
    {
        if (null === $this->options && count($this->longopts) === 0 && null === $this->userInput) {
            return $this->fixArgs($_SERVER['argv']);
        }

        if (null !== $this->userInput) {
            $this->collectOptionsFromUserInputClass();
        }

        $parseCommandLineOptions = $this->cliOptionParser;
        $parsedVars = $parseCommandLineOptions($this->options, $this->longopts);
        if (false === $parsedVars) {
            throw new \RuntimeException(
                    'Error parsing "' . join(' ', $_SERVER['argv'])
                    . '" with ' . $this->options
                    . ' and ' . join(' ', $this->longopts)
            );
        }

        return $this->fixArgs($_SERVER['argv'], $parsedVars);
    }
454616
public static function GetRequestParameterList () {
		if ($_SERVER['argc'] < 1) {
			return [];
		}
		$current_key = 0;
		$parameter_list = [];

		$args = array_slice($_SERVER['argv'], 1);
		$argc = count($args);

		for ($i = 0;$i < $argc;$i++) {
			$argv = $args[$i];
			if (substr($argv, 0, 1) === '-') {
				$current_key = substr($argv, 1);
				$parameter_list[$current_key] = '';
				if (isset($args[$i + 1]) && substr($args[$i + 1], 0, 1) !== '-') {
					$parameter_list[$current_key] = $args[$i + 1];
					$i++;
				}
				continue;
			}
			if (isset($parameter_list[$current_key])) {
				if (!is_array($parameter_list[$current_key])) {
					$parameter_list[$current_key] = (array) $parameter_list[$current_key];
				}
				$parameter_list[$current_key][] = $argv;
			} else {
				$parameter_list[$current_key] = $argv;
			}
		}

		return $parameter_list;
	}
606067
public function unknown_assoc( $assoc_args ) {
		$generic = $this->query_spec(
			array(
				'type' => 'generic',
			)
		);

		if ( count( $generic ) ) {
			return array();
		}

		$known_assoc = array();

		foreach ( $this->spec as $param ) {
			if ( in_array( $param['type'], array( 'assoc', 'flag' ), true ) ) {
				$known_assoc[] = $param['name'];
			}
		}

		return array_diff( array_keys( $assoc_args ), $known_assoc );
	}
1076844
private function parseParameters(): array
    {
        $arguments = [];
        $options = [];
        $signatureArguments = $this->getParameters();

        foreach ($signatureArguments as $value) {
            $item = [];
            $matches = [];
            $exploded = explode(':', $value);

            if (count($exploded) > 0 && preg_match($this->argumentsMatcher, $exploded[0], $matches)) {
                $item['name'] = $matches[1];
                $item['type'] = $this->defineType($matches[2] === '[]', $matches[3] === '=');
                $item['default'] = $matches[4] !== '' ? $matches[4] : null;
                $item['description'] = count($exploded) === 2 ? $exploded[1] : null;

                if ($matches[2] === '[]' && $item['default'] !== null) {
                    $item['default'] = explode(',', $item['default']);
                }

                if (substr($exploded[0], 0, 2) === '--') {
                    $options[] = $item;
                } else {
                    $arguments[] = $item;
                }
            }
        }

        return [
            'arguments' => $arguments,
            'options' => $options,
        ];
    }
1300001
public static function extractArgs(array $args, ?PaginationType $paginationType, ?int $paginateMaxCount): array
    {
        if ($paginationType->isConnection()) {
            /** @var int $first */
            $first = $args['first'];
            $page = self::calculateCurrentPage(
                $first,
                Cursor::decode($args)
            );
        } else {
            /** @var int $first */
            $first = $args[config('lighthouse.pagination_amount_argument')];
            $page = Arr::get($args, 'page', 1);
        }

        if ($first <= 0) {
            throw new Error(
                "Requested pagination amount must be more than 0, got $first"
            );
        }

        // Make sure the maximum pagination count is not exceeded
        if (
            $paginateMaxCount !== null
            && $first > $paginateMaxCount
        ) {
            throw new Error(
                "Maximum number of {$paginateMaxCount} requested items exceeded. Fetch smaller chunks."
            );
        }

        return [$first, $page];
    }