Parse argument value

@param array $out

@return boolean
352659
protected function argValue(&$out)
    {
        $s = $this->count;

        $keyword = null;

        if (! $this->variable($keyword) || ! $this->matchChar(':')) {
            $this->seek($s);
            $keyword = null;
        }

        if ($this->genericList($value, 'expression')) {
            $out = [$keyword, $value, false];
            $s = $this->count;

            if ($this->literal('...', 3)) {
                $out[2] = true;
            } else {
                $this->seek($s);
            }

            return true;
        }

        return false;
    }
1322054
public static function TryParse( $value, &$output ) : bool
   {

      if ( \is_null( $value ) )
      {
         return false;
      }

      if ( $value instanceof Point )
      {
         $output = $value;
         return true;
      }

      if ( $value instanceof Rectangle )
      {
         $output = $value->Point;
         return true;
      }

      if ( \is_string( $value ) )
      {
         $hits = null;
         if ( \preg_match( '~^x=(\d{1,4});\s*y=(\d{1,4})$~', $value, $hits ) )
         {
            $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) );
            return true;
         }
         if ( \preg_match( '~^(\d{1,4}),\s*(\d{1,4})$~', $value, $hits ) )
         {
            $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) );
            return true;
         }
         return false;
      }

      if ( \is_array( $value ) )
      {
         if ( isset( $value[ 'x' ] ) && isset( $value[ 'y' ] ) )
         {
            $output = new Point( \intval( $value[ 'x' ] ), \intval( $value[ 'y' ] ) );
            return true;
         }
         if ( isset( $value[ 'X' ] ) && isset( $value[ 'Y' ] ) )
         {
            $output = new Point( \intval( $value[ 'X' ] ), \intval( $value[ 'Y' ] ) );
            return true;
         }
         if ( \count( $value ) != 2 )
         {
            return false;
         }
         if ( isset( $value[ 0 ] ) && isset( $value[ 1 ] ) )
         {
            $output = new Point( \intval( $value[ 0 ] ), \intval( $value[ 1 ] ) );
            return true;
         }
         return false;
      }

      $type = new Type( $value );
      if ( $type->hasAssociatedString() )
      {
         $hits = null;
         if ( \preg_match( '~^x=(\d{1,4});\s*y=(\d{1,4})$~', $type->getStringValue(), $hits ) )
         {
            $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) );
            return true;
         }
         if ( \preg_match( '~^(\d{1,4}),\s*(\d{1,4})$~', $type->getStringValue(), $hits ) )
         {
            $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) );
            return true;
         }
      }

      return false;

   }
871051
public static function parse(array $arguments):array
    {
        if (count($arguments) < 1) {
            throw new Server500(new \ArrayObject(array("explain" => "Cannot parse value without commands",
                "solution" => "Please set an command to parse it")));
        }
        $exec = self::parseExecutable($arguments);

        if (isset($arguments[0])) {
            unset($arguments[0]);
        }

        $com = self::parseCommands($arguments);
        $opt = self::parseOptions($arguments);

        return (["global" => $exec, "commands" => $com, "options" => $opt]);
    }
1225335
protected function value(&$out)
    {
        $s = $this->seek();

        if ($this->literal('not', false) && $this->whitespace() && $this->value($inner)) {
            $out = [Type::T_UNARY, 'not', $inner, $this->inParens];

            return true;
        }

        $this->seek($s);

        if ($this->literal('not', false) && $this->parenValue($inner)) {
            $out = [Type::T_UNARY, 'not', $inner, $this->inParens];

            return true;
        }

        $this->seek($s);

        if ($this->literal('+') && $this->value($inner)) {
            $out = [Type::T_UNARY, '+', $inner, $this->inParens];

            return true;
        }

        $this->seek($s);

        // negation
        if ($this->literal('-', false) &&
            ($this->variable($inner) ||
            $this->unit($inner) ||
            $this->parenValue($inner))
        ) {
            $out = [Type::T_UNARY, '-', $inner, $this->inParens];

            return true;
        }

        $this->seek($s);

        if ($this->parenValue($out) ||
            $this->interpolation($out) ||
            $this->variable($out) ||
            $this->color($out) ||
            $this->unit($out) ||
            $this->string($out) ||
            $this->func($out) ||
            $this->progid($out)
        ) {
            return true;
        }

        if ($this->keyword($keyword)) {
            if ($keyword === 'null') {
                $out = [Type::T_NULL];
            } else {
                $out = [Type::T_KEYWORD, $keyword];
            }

            return true;
        }

        return false;
    }
103746
protected function parseArguments()
	{
		// Get the list of argument values from the environment.
		$args = $_SERVER['argv'];

		// Set the path used for program execution and remove it form the program arguments.
		$this->executable = array_shift($args);

		// We use a for loop because in some cases we need to look ahead.
		for ($i = 0; $i < count($args); $i++)
		{
			// Get the current argument to analyze.
			$arg = $args[$i];

			// First let's tackle the long argument case.  eg. --foo
			if (strlen($arg) > 2 && substr($arg, 0, 2) == '--')
			{
				// Attempt to split the thing over equals so we can get the key/value pair if an = was used.
				$arg = substr($arg, 2);
				$parts = explode('=', $arg);
				$this->data[$parts[0]] = true;

				// Does not have an =, so let's look ahead to the next argument for the value.
				if (count($parts) == 1 && isset($args[$i + 1]) && preg_match('/^--?.+/', $args[$i + 1]) == 0)
				{
					$this->data[$parts[0]] = $args[$i + 1];

					// Since we used the next argument, increment the counter so we don't use it again.
					$i++;
				}
				elseif (count($parts) == 2)
				// We have an equals sign so take the second "part" of the argument as the value.
				{
					$this->data[$parts[0]] = $parts[1];
				}
			}

			// Next let's see if we are dealing with a "bunch" of short arguments.  eg. -abc
			elseif (strlen($arg) > 2 && $arg[0] == '-')
			{
				// For each of these arguments set the value to TRUE since the flag has been set.
				for ($j = 1; $j < strlen($arg); $j++)
				{
					$this->data[$arg[$j]] = true;
				}
			}

			// OK, so it isn't a long argument or bunch of short ones, so let's look and see if it is a single
			// short argument.  eg. -h
			elseif (strlen($arg) == 2 && $arg[0] == '-')
			{
				// Go ahead and set the value to TRUE and if we find a value later we'll overwrite it.
				$this->data[$arg[1]] = true;

				// Let's look ahead to see if the next argument is a "value".  If it is, use it for this value.
				if (isset($args[$i + 1]) && preg_match('/^--?.+/', $args[$i + 1]) == 0)
				{
					$this->data[$arg[1]] = $args[$i + 1];

					// Since we used the next argument, increment the counter so we don't use it again.
					$i++;
				}
			}

			// Last but not least, we don't have a key/value based argument so just add it to the arguments list.
			else
			{
				$this->args[] = $arg;
			}
		}
	}
525867
public function parseValue($buffer, &$out)
    {
        $this->count           = 0;
        $this->env             = null;
        $this->inParens        = false;
        $this->eatWhiteDefault = true;
        $this->buffer          = (string) $buffer;

        $this->saveEncoding();

        $list = $this->valueList($out);

        $this->restoreEncoding();

        return $list;
    }
1117780
protected function argumentValues(&$args, $delim = ',')
    {
        $s = $this->seek();
        if (!$this->literal('(')) {
            return false;
        }

        $values = array();
        while (true) {
            if ($this->expressionList($value)) {
                $values[] = $value;
            }
            if (!$this->literal($delim)) {
                break;
            } else {
                if ($value == null) {
                    $values[] = null;
                }
                $value = null;
            }
        }

        if (!$this->literal(')')) {
            $this->seek($s);

            return false;
        }

        $args = $values;

        return true;
    }
447208
protected function parseType( array $args )
	{
		$type = $args['type'];

		return false !== stripos( $type, '_inline' )
			? str_replace( '_inline', '', $type )
			: $type;
	}
516923
function arg($pos)
    {
        if (array_key_exists($pos, $this->parsedNamedArgs)) {
            return $this->parsedNamedArgs[$pos];
        }

        if (array_key_exists($pos, $this->parsedArgs)) {
            return $this->parsedArgs[$pos];
        }
    }
1002341
protected function parsevalue($value)
    {
        //make sure the whole value can be mapped
        if (!is_array($value) && !$value instanceof \ArrayAccess && !is_object($value)) {
            return false;
        }

        return $this->rParseValue($value);
    }
690430
protected function parse($output)
    {
        $lines = explode(PHP_EOL, $output);
        $stats = array();
        foreach ($lines as $line) {
            $data = explode(' ', $line);
            array_walk($data, 'trim');
            $stats[] = array_values(array_filter($data, function ($value) {
                return strlen($value) > 0;
            }));
        }

        return $stats;
    }
604397
protected function progid(&$out)
    {
        $s = $this->count;

        if ($this->literal('progid:', 7, false) &&
            $this->openString('(', $fn) &&
            $this->matchChar('(')
        ) {
            $this->openString(')', $args, '(');

            if ($this->matchChar(')')) {
                $out = [Type::T_STRING, '', [
                    'progid:', $fn, '(', $args, ')'
                ]];

                return true;
            }
        }

        $this->seek($s);

        return false;
    }
734858
protected function selector(&$out)
    {
        $selector = [];

        for (;;) {
            if ($this->match('[>+~]+', $m)) {
                $selector[] = [$m[0]];
                continue;
            }

            if ($this->selectorSingle($part)) {
                $selector[] = $part;
                $this->match('\s+', $m);
                continue;
            }

            if ($this->match('\/[^\/]+\/', $m)) {
                $selector[] = [$m[0]];
                continue;
            }

            break;
        }

        if (count($selector) === 0) {
            return false;
        }

        $out = $selector;
        return true;
    }
96751
public static function getArgs($args)
    {
        $out = [];
        $last_arg = null;

        for ($i = 1, $il = sizeof($args); $i < $il; ++$i) {
            if (preg_match('~^--(.+)~', $args[$i], $match)) {
                $parts = explode('=', $match[1]);
                $key = preg_replace('~[^a-z0-9]+~', '', $parts[0]);

                if (isset($parts[1])) {
                    $out[$key] = $parts[1];
                } else {
                    $out[$key] = true;
                }

                $last_arg = $key;
            } elseif (preg_match('~^-([a-zA-Z0-9]+)~', $args[$i], $match)) {
                $key = null;
                for ($j = 0, $jl = mb_orig_strlen($match[1]); $j < $jl; ++$j) {
                    $key = $match[1]{$j};
                    $out[$key] = true;
                }

                $last_arg = $key;
            } elseif ($last_arg !== null) {
                $out[$last_arg] = $args[$i];
            }
        }

        return $out;
    }
1219151
public function parse(array $args = []) : string
    {
        $strAux = $this->str;
        $params = $this->getParameters();

        foreach ($args as $argKey => $argValue) {
            if (in_array($argKey, $params)) {
                $strAux = str_replace("{{$argKey}}", $argValue, $strAux);
            }
        }

        return $strAux;
    }
475491
private function parseHeader($header)
    {
        if (!\preg_match_all('/(?:[^,"]*+(?:"[^"]*+")?)+[^,"]*+/', $header, $matches)) {
            throw new InvalidArgumentException('Failed to parse accept header: "' . $header . '"');
        }

        return \array_values(\array_filter(\array_map('\trim', $matches[0])));
    }
605217
public function parse(array $input): bool
    {
        $this->resetAggregators();

        $this
            ->validateType($input)
            ->validateId($input)
            ->validateAttributes($input)
            ->validateRelationships($input);

        $hasNoErrors = $this->getJsonApiErrorCollection()->count() <= 0;

        return $hasNoErrors;
    }