Parses a YAML string to a PHP value.

@param string $value A YAML string
@param int    $flags A bit field of PARSE_* constants to customize the YAML parser behavior

@return mixed A PHP value

@throws ParseException If the YAML is not valid
771824
public function parse($value, $flags = 0)
    {
        if (\is_bool($flags)) {
            @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);

            if ($flags) {
                $flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
            } else {
                $flags = 0;
            }
        }

        if (\func_num_args() >= 3) {
            @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);

            if (func_get_arg(2)) {
                $flags |= Yaml::PARSE_OBJECT;
            }
        }

        if (\func_num_args() >= 4) {
            @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);

            if (func_get_arg(3)) {
                $flags |= Yaml::PARSE_OBJECT_FOR_MAP;
            }
        }

        if (Yaml::PARSE_KEYS_AS_STRINGS & $flags) {
            @trigger_error('Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.', E_USER_DEPRECATED);
        }

        if (false === preg_match('//u', $value)) {
            throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
        }

        $this->refs = array();

        $mbEncoding = null;
        $e = null;
        $data = null;

        if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('UTF-8');
        }

        try {
            $data = $this->doParse($value, $flags);
        } catch (\Exception $e) {
        } catch (\Throwable $e) {
        }

        if (null !== $mbEncoding) {
            mb_internal_encoding($mbEncoding);
        }

        $this->lines = array();
        $this->currentLine = '';
        $this->refs = array();
        $this->skippedLineNumbers = array();
        $this->locallySkippedLineNumbers = array();

        if (null !== $e) {
            throw $e;
        }

        return $data;
    }
893966
protected function parseValue($value)
    {
        if ($this->isQuoted($value)) {
            return trim(preg_replace(static::ESCAPED_QUOTE_PATTERN, '\1', $value), static::QUOTE_CHARS);
        } elseif ($this->opensQuote($value)) {
            $value = $this->parseMultilineValue(ltrim($value, static::QUOTE_CHARS));
            if ($value === false) {
                throw new \RuntimeException('Error parsing ini.');
            }

            return $value;
        } elseif (is_numeric($value)) {
            if (strpos($value, '.') !== false) {
                return floatval($value);
            }
            return intval($value);
        } elseif (in_array(strtolower($value), ['true', 'false'])) {
            return (strtolower($value) === 'true');
        } else {
            return $value;
        }
    }
1093479
public function asCode($value, $level = 0)
    {
        if ($value instanceof YAML) {
            $value = (string) $value;
        } elseif (null === $value) {
            $value = '~';
        } elseif (is_bool($value)) {
            $value = $value ? 'true' : 'false';
        } elseif (is_string($value)) {
            // nothing
        } elseif (is_array($value)) {
            $tmp = array();
            $spacer = str_repeat(' ', max(array($level * $this->getOption('indent', 1), 0)));
            if (!$this->isKeysNumeric($value)) {
                $inline = $this->getOption('inline', false);
                $inline_size = $this->getOption('inline_size', 0);
                foreach ($value as $k => $v) {
                    // skip null value
                    if (null === $v && $this->getOption('skip_null_value', false)) {
                        continue;
                    }
                    $x = $inline_size > 0 && $level >= 0 ? str_repeat(' ', $inline_size - strlen($k) - strlen($spacer)) : '';
                    if ($inline && $this->canBeInlined($v)) {
                        $v = explode("\n", $this->asCode($v, -1));
                        $tmp[] = $spacer.sprintf('%s: %s{ %s }', $k, $x, implode(", ",  $v));
                    } else {
                        if ($this->isInline($v)) {
                            if ($this->isArrayValueArray($v)) {
                                $tmp[] = $spacer.sprintf('%s:', $k);
                                $tmp[] = $this->asCode($v, $level + 1);
                            } else {
                                $tmp[] = $spacer.sprintf('%s: %s%s', $k, $x, $this->asCode($v, $level + 1));
                            }
                        } else {
                            $tmp[] = $spacer.sprintf('%s:', $k);
                            $tmp[] = $this->asCode($v, $level + 1);
                        }
                    }
                }
                $value = implode("\n", $tmp);
            } else {
                foreach ($value as $k => $v) {
                    if (is_array($v) && !$this->isKeysNumeric($v)) {
                        $v = explode("\n", $this->asCode($v, -1));
                        $tmp[] = sprintf('{ %s }', implode(", ",  $v));
                    } else {
                        $tmp[] = $this->asCode($v, $level + 1);
                    }
                }
                if ($this->isArrayValueArray($value)) {
                    $value = implode("\n", array_map(function($x) use ($spacer) {
                        return $spacer.sprintf('- %s', $x);
                    }, $tmp));
                } else {
                    $value = sprintf('[ %s ]', implode(', ', $tmp));
                }
            }
        }

        return $value;
    }
458775
public function parseBoolean($value) {
    if (is_bool($value)) return $value;

    $exportValue = var_export($value, true);
    $e = new ParseException("$exportValue could not be parsed as a boolean");

    if (!is_string($value)) throw $e;

    switch (strtolower($value)) {
      case 'true':
      case 'on':
      case 'yes':
      case 'y':
        return true;
      case 'false':
      case 'off':
      case 'no':
      case 'n':
        return false;
      default:
        throw $e;
    }
  }
1358258
public function andWhereLike($field, $value, $flags = 'imxsu', $delimiter = null)
    {
        return $this->whereLike($field, $value, $flags, $delimiter, '$and');
    }
137114
public static function parse($value) {
        if ($value instanceof Color) {
            return $value;
        }
        
        $value = strtolower("$value");
        
        if (preg_match('/^#?[0-9a-f]{3,8}$/', $value) &&
            self::parseHexColor($value, $result)
        ) {
            return $result;
        }
        
        if (preg_match(
                '/^rgba?\\(([^,]+),([^,]+),([^,]+)(?:,([^,]+))?\\)$/', 
                $value, $matches) &&
            self::parseRgbComponent($matches[1], $r) &&
            self::parseRgbComponent($matches[2], $g) &&
            self::parseRgbComponent($matches[3], $b) &&
            self::parseAlpha(isset($matches[4]) ? $matches[4] : null, $a)
        ) {
            return self::fromRgb($r, $g, $b, (int)(255 * $a));
        }
        
        if (preg_match(
                '/^hsla?\\(([^,]+),([^,]+),([^,]+)(?:,([^,]+))?\\)$/', 
                $value, $matches) &&
            self::parseHue($matches[1], $h) &&
            self::parsePercent($matches[2], $s) &&
            self::parsePercent($matches[3], $l) &&
            self::parseAlpha(isset($matches[4]) ? $matches[4] : null, $a)
        ) {
            return self::fromHsl($h, $s, $l, $a);
        }
        
        $result = self::parseNamedColor($value);
        if ($result !== null) {
            return $result;
        }
        
        throw new \InvalidArgumentException(
            "Cannot parse '$value' as a color.");
    }
386703
public static function fromValue($value) {
    if (is_array($value)) {
      $elements = [];
      foreach ($value as $k => $v) {
        $elements[] = ArrayPairNode::create(static::fromValue($k), static::fromValue($v));
      }
      return ArrayNode::create($elements);
    }
    elseif (is_string($value)) {
      return StringNode::create(var_export($value, TRUE));
    }
    elseif (is_integer($value)) {
      return new IntegerNode(T_LNUMBER, $value);
    }
    elseif (is_float($value)) {
      return new FloatNode(T_DNUMBER, $value);
    }
    elseif (is_bool($value)) {
      return BooleanNode::create($value);
    }
    elseif (is_null($value)) {
      return NullNode::create('NULL');
    }
    else {
      throw new \InvalidArgumentException();
    }
  }
560815
public function orWhereLike($field, $value, $flags = 'imxsu', $delimiter = null)
    {
        return $this->whereLike($field, $value, $flags, $delimiter, '$or');
    }
946400
protected function parseDate($value)
    {
        // Skip empty values
        if (empty($value) && !is_numeric($value)) {
            return null;
        }

        // Determine value to parse
        if (is_array($value)) {
            $source = $value; // parse array
        } elseif (is_numeric($value)) {
            $source = $value; // parse timestamp
        } else {
            // Convert US date -> iso, fix y2k, etc
            $value = $this->fixInputDate($value);
            if (is_null($value)) {
                return null;
            }
            $source = strtotime($value); // convert string to timestamp
        }
        if ($value === false) {
            return false;
        }

        // Format as iso8601
        $formatter = $this->getInternalFormatter();
        return $formatter->format($source);
    }
865762
protected function process(string $value, int $flags)
    {
        return preg_replace_callback('#\{\$(.+)\}#',
            function ($match) use ($flags) {
                return $this->get($match[1], $flags);
            },
            $value);
    }
335746
protected function parseValue($value)
  {
    if ('*' === substr($value, 0, 1)) {
      if (false !== $pos = strpos($value, '#')) {
        $value = substr($value, 1, $pos - 2);
      } else {
        $value = substr($value, 1);
      }

      if (!array_key_exists($value, $this->refs)) {
        throw new InvalidArgumentException(sprintf('Reference "%s" does not exist (%s).', $value, $this->currentLine));
      }

      return $this->refs[$value];
    }

    if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) {
      $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';

      return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers)));
    } else {
      return sfYamlInline::load($value);
    }
  }
872248
private static function parseReal($value)
    {
        if ($value == '') return null;

        $x = str_replace(',', '.', $value);
        if (static::isSignedReal($x)) return floatval($x);
        else throw new SyntaxErrorException();
    }
1285577
public static function Parse( $value, bool $fixed = false )
   {

      $res = null;

      if ( ! self::TryParse( $value, $res, $fixed ) )
      {
         return false;
      }

      return $res;

   }
536661
public function parse_value($value) {

        if (empty($this->resources)) {
            $this->resources = $this->get_resources();
        }
        if (!empty($this->resources)) {
            foreach ($this->resources as $resource) {
                $value = $resource->parse_value($value);
            }
        }

        return $value;

    }
1150508
public function parse_value($value) {
        if (strpos($value, '$ToolProxy.custom.url') !== false) {
            $value = str_replace('$ToolProxy.custom.url', parent::get_endpoint(), $value);
        }
        return $value;

    }
200651
public function parse_value($value) {
        if (strpos($value, '$ToolConsumerProfile.url') !== false) {
            $value = str_replace('$ToolConsumerProfile.url', $this->get_endpoint(), $value);
        }
        return $value;

    }
800771
public function parseString($value) {
    if (is_string($value)) {
      return $value;
    }

    $exportValue = var_export($value, true);
    throw new ParseException("'$exportValue' can not be parsed as a string");
  }